根据

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. git基础知识

    Git的两大功能 1.协作开发 2.版本控制 版本库 版本库又名仓库,英文名repository,你可以简单理解成一个目录,这个目录里面的所有文件都可以被Git管理起来,每个文件的修改.删除,Git都 ...

  2. sed 操作命令

    sed介绍 grep 只能过滤文件内容,sed既能过滤文件内容同时还能对文件内容进行修改.  sed 算是一种编程语言,它有自己的固定语法. sed是一种行编辑器,sed会在内存中开辟一块独立的空间( ...

  3. 最少步数(bfs)

    最少步数 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 这有一个迷宫,有0~8行和0~8列: 1,1,1,1,1,1,1,1,1 1,0,0,1,0,0,1,0,1 ...

  4. OpenCV矩形检测

    OpenCV矩形检测 需求:提取图像中的矩形,图像存在污染现象,即矩形区域不是完全规则的矩形. 思路一:轮廓法 OpenCV里提取目标轮廓的函数是findContours,它的输入图像是一幅二值图像, ...

  5. [py]初始化dict结构和json.dump使用

    1.json.dump使用 http://python3-cookbook.readthedocs.io/zh_CN/latest/c06/p02_read-write_json_data.html ...

  6. 2019.03.20 mvt,Django分页

    MVT模式   MVT各部分的功能:   M全拼为Model,与MVC中的M功能相同,负责和数据库交互,进行数据处理.       V全拼为View,与MVC中的C功能相同,接收请求,进行业务处理,返 ...

  7. [LeetCode] 系统刷题5_Dynamic Programming

    Dynamic Programming 实际上是[LeetCode] 系统刷题4_Binary Tree & Divide and Conquer的基础上,加上记忆化的过程.就是说,如果这个题 ...

  8. vue--项目文件

    build config:webpack的配置文件 node_modules: 依赖的npm包 src: 项目代码 static:依赖的第三方库 ps:static中有个文件.gitkeep 因为新建 ...

  9. fill和memset的区别

    https://blog.csdn.net/xs18952904/article/details/75195412 memset只能初始化成为0或者-1,其他都要用fill来完成. #include& ...

  10. Amber TUTORIAL B1: Simulating a DNA polyA-polyT Decamer

    Section 1: Introduction The input files required (using their default file names): prmtop - a file c ...