根据

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. 在字符编码格式选项里UTF-8(无BOM)

    BOM——Byte Order Mark,就是字节序标记 在UCS 编码中有一个叫做”ZERO WIDTH NO-BREAK SPACE“的字符,它的编码是FEFF.而FFFE在UCS中是不存在的字符 ...

  2. mac-破解2018 webstorm

    参考链接:https://blog.csdn.net/pariese/article/details/77540069 后续待整理

  3. js篇-json字符串与json对象相互转化

    回调返回结果是 json字符串还是json对象一定要看清楚哦,状态不好的时候,感觉眼神也不好使了, var a = "{"name":"jenny", ...

  4. Spark之数据倾斜 --采样分而治之解决方案

    1 采样算法解决数据倾斜的思想 2 采样算法在spark数据倾斜中的具体操作

  5. 58A

    #include <stdio.h> #include <string.h> int main() { char hel[6]="hello"; char ...

  6. Lua 随机数生成问题

    原文链接:http://blog.csdn.net/zhangxaochen/article/details/8095007 Lua 生成随机数需要用到两个函数: math.randomseed(xx ...

  7. Pytorch快速入门及在线体验

    本文搭配了Pytorch在线环境,可以直接在线体验. Pytorch是Facebook 的 AI 研究团队发布了一个基于 Python的科学计算包,旨在服务两类场合: 1.替代numpy发挥GPU潜能 ...

  8. 17-Python3 循环语句

    2018-11-21 18:23:56 print('pass语句') for letter in 'Runoob': if letter=='o': pass else: print(letter) ...

  9. [LeetCode] 704. Binary Search_Easy tag: Binary Search

    Given a sorted (in ascending order) integer array nums of n elements and a target value, write a fun ...

  10. Mysql 数据库导入及导出

    Mysql 数据库导入及导出 数据库导出: 1.导出整个数据库 mysqldump -u 用户名 -p 数据库名 > 导出的文件名 mysqldump -u root -p dataname & ...