根据

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. Dockerfile语法解析

    Dockfile介绍 从上到下依次执行 每次执行一条指令就创建一个镜像层 第一条指令必须是FROM    表示需要构建的镜像是由哪个镜像为基础镜像   后续的指令运行于此基准镜像所提供的运行环境 可以 ...

  2. wx工具栏,菜单栏,状态栏

    #!/usr/bin/env python # -*- coding: utf- -*- import wx import wx.py.images class ToolbarFrame(wx.Fra ...

  3. CentOS6.5安装Scrapy

    1.安装命令超级简单: [root@mycentos ~]# pip install Scrapy 建立软链接: [root@mycentos ~]# ln -s /usr/local/python3 ...

  4. 2sum,3sum,4sum,ksum

    1. 2sum 题目:给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标.你可以假设每种输入只会对应一个答案.但是,你不能重复利 ...

  5. php 获取 mime type 类型,fileinfo扩展

    背景: version < php-5.3 没有API能够查看文件的 mime_type, 故需要编译扩展 fileinfo 来扩展PHP的API(finfo_*系列函数).php-5.3 以后 ...

  6. SEO--质量监测

    日志分析 1.每个搜索引擎的总体抓取量 2.记录搜索引擎蜘蛛的不重复抓取量 3.每个目录.每个搜索引擎的抓取量 4.统计搜索引擎抓取的状态码(通过查看欧化300,404,500等分析那些页面需要优化) ...

  7. 3.C#的访问权限修饰符

    C#里类及类成员的修饰符有以下五个如下:public 公开 类及类成员的修饰符 对访问成员没有级别限制private 私有 类成员的修饰符 只能在类的内部访问protected 受保护的 类成员的修饰 ...

  8. python shutil.copytree 解决目标目录存在的情况

    直接修改copytree的实现即可,如下: #copytree中找到 os.makedirs(dst),加入判断,就这么简单 if not os.path.exists(dst): os.makedi ...

  9. cocos2d JS-(JavaScript) 动态生成方法的例子

    function User(properties) { for (var i in properties) { (function (which) { var p = i; which["g ...

  10. cocosStudio制作ScrollView并在cocos2dx 3.0中使用。

    使用cocosStudio制作界面基本已成为基础了,之前都是拖动一些 Image.Button的小控件,再用到层容器和滚动层的时候,习惯性的用拖动来改变控件的大小.但是你在把其他的控件拖动到上面的时候 ...