根据

https://github.com/tensorflow/tensorflow/issues/1824

简单进行了测试

修改运行的脚本增加如下关键代码

例如mnist_softmax.py

from __future__ import absolute_import
 
from __future__ import division
 
from __future__ import print_function
 
# Import data
 
from tensorflow.examples.tutorials.mnist import input_data
 
from tensorflow.python.client import timeline
 
 
import tensorflow as tf
 
 
flags = tf.app.flags
 
FLAGS = flags.FLAGS
 
flags.DEFINE_string('data_dir''/tmp/data/''Directory for storing data')
 
mnist = input_data.read_data_sets(FLAGS.data_dir, one_hot=True)
 
# Create the model
 
= tf.placeholder(tf.float32, [None784])
 
= tf.Variable(tf.zeros([78410]))
 
= tf.Variable(tf.zeros([10]))
 
= tf.nn.softmax(tf.matmul(x, W) + b)
 
# Define loss and optimizer
 
y_ = tf.placeholder(tf.float32, [None10])
 
cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))
 
train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)
 
# Train
 
intiOp = tf.initialize_all_variables()
 
# Init run_metadata
 
run_metadata = tf.RunMetadata()
 
# Open file to save trace
 
trace_file = open('/tmp/timeline.ctf.json''w')
 
sess = tf.Session()
 
sess.run(intiOp)
 
for in range(500):
 
  batch_xs, batch_ys = mnist.train.next_batch(100)
 
  sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys},
 
           options=tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE),
 
           run_metadata=run_metadata)
 
# Test trained model
 
correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))
 
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
 
print(sess.run(accuracy, feed_dict={x: mnist.test.images, y_: mnist.test.labels}))
 
#timeline
 
trace = timeline.Timeline(step_stats=run_metadata.step_stats)
 
trace_file.write(trace.generate_chrome_trace_format())

打开chrome浏览器输入

chrome://tracing/

选择Load按钮加载输出的json文件

W,S按键可以缩放,A,D按键可以移动,具体帮助点击右上角“?”按钮

Tensorflow timeline trace的更多相关文章

  1. caffe, caffe2, paddlepaddle, tensorflow对于cuda,cudnn,protobuf依赖的纠葛

    由于在学习神经网络,为了尝试各种深度学习框架,电脑上目前安装了caffe, caffe2, paddlepaddle, tensorflow三款主流框架,但是安装过程中真是痛不欲生. 且不说单单安装一 ...

  2. web前端自动化测试/爬虫利器puppeteer介绍

    web前端自动化测试/爬虫利器puppeteer介绍 Intro Chrome59(linux.macos). Chrome60(windows)之后,Chrome自带headless(无界面)模式很 ...

  3. puppeteer UI自动化测试demo(一)

    一.简介 这个不大常见,比较常见的是selenium和weddriver: 所以就增加一个说明,来自官网的. Puppeteer 是一个 Node 库,它提供了一个高级 API 来通过 DevTool ...

  4. puppeteerExamples

    What can I do? Most things that you can do manually in the browser can be done using Puppeteer! Here ...

  5. Puppeteer学习笔记 (1)- 什么是Puppeteer

    本文链接:https://www.cnblogs.com/hchengmx/p/11006263.html 1. phantomjs介绍 在介绍puppeteer之前必须介绍一下phantomjs,p ...

  6. 学习笔记TF062:TensorFlow线性代数编译框架XLA

    XLA(Accelerated Linear Algebra),线性代数领域专用编译器(demain-specific compiler),优化TensorFlow计算.即时(just-in-time ...

  7. Xperf Basics: Recording a Trace(转)

    http://randomascii.wordpress.com/2011/08/18/xperf-basics-recording-a-trace/   This post is obsolete ...

  8. 双显卡笔记本安装CUDA+theano、tensorflow环境

    原文出处:http://www.cnblogs.com/jacklu/p/6377820.html 个人知乎主页欢迎关注:https://www.zhihu.com/people/jack_lu,相信 ...

  9. TensorFlow anaconda命令备忘

    [查看tensorflow安装的版本] anaconda search -t conda tensorflow [选择版本安装] conda install -c anaconda tensorflo ...

随机推荐

  1. JsonDataObjects基本演示

    下载地址https://github.com/ahausladen/JsonDataObjects 执行程序截图 Json数据 { "name": "张三", ...

  2. MyBatis——一对多、一对一关系,collection、association

    实体类两个: user类: package com.pojo; /** *用户 */ public class User{ private int userId;//用户ID private Stri ...

  3. mac上mysql root密码忘记或权限错误的解决办法

    以下方法亲测有效,过程使用的工具只有mac的终端无需workbench 当我们通过终端连接mysql数据库时候我们会看到这样的信息 ERROR 1045: Access denied for user ...

  4. Eclipse中git上如何把自己的分支保存到远端

    1   Team——>remote——>push 2  next 3  选择自己的分支,然后点击 Add Spec 4  查看是否是自己的分支——>自己的分支,然后Finish PS ...

  5. Nginx参数调优

    (1)nginx运行工作进程个数,一般设置cpu的核心或者核心数x2 如果不了解cpu的核数,可以top命令之后按1看出来,也可以查看/proc/cpuinfo文件 grep ^processor / ...

  6. SQL _ Create Procedure

    -- ================================================ -- Template generated from Template Explorer usi ...

  7. ida6.8 android so调试

    献给还不会的同学. 我的设备 1.魅族手机,自带root功能 2.ida6.8 1.上传ida 目录下dbgsrv/android_server 到 手机上,这个目录自己可以修改,网上都用的adb p ...

  8. ASP.NET Core 启动流程图

    简洁描述: 一   WebHostBuilder.Build() =>1注入公共的实例 2创建WebHost实例 3注入自定义实例 4创建IServer 5添加中间件(_components集合 ...

  9. C++ 使用openssl库实现 DES 加密——CBC模式 && RSA加密——公加私解——私加公解

    之前工作上需要用C++把软件生成的用户序列号用des加密cbc的模式,加密后为二进制,转化为十六进制,然后提供给java写的授权码管理平台. java平台会根据用户序列号,生成一个授权码,授权码是用r ...

  10. install Maven

    工欲善其事,必先利其器.咱们也来玩玩 Maven 这货吧!先得去下载一个. 准备工作 java开发环境(JDK) maven下载地址:http://maven.apache.org/release-n ...