根据

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. MySQL 从库down机

    MySQL 从库down机中午突然down机,重启后,从库同步报主键重复的错误. Could not execute Write_rows event on table operation_maste ...

  2. 多线程2.md

    # 多线程  VS 多进程 - 程序:一堆代码以文本形式存入一个文档 - 进程: 程序运行的一个状态 - 包含地址空间.内存.数据栈等 - 每个进程由自己完全独立的运行环境,多进程共享数据是一个问题 ...

  3. sap 提供服务

    1: https://blog.csdn.net/stone0823/article/details/81661261?utm_source=blogxgwz1 https://blog.csdn.n ...

  4. Vim的6种基本模式及基本操作

    说明:文章所有内容截选自实验楼教程[Vim编辑器]~ Vim 快速入门 一.实验介绍 1.1 实验内容 本次实验将学习vim中的不同模式和一些基本操作. 1.2 实验知识点 Vim中的六种基本模式 V ...

  5. Docker ssh server

    这个话题真让我气愤啊,在家里的mac上我已经全部摆平了,结果在公司的Linux上就给堵住了 原因不祥,但最后在错误提示里,有个移除(remove)信息,我照做了,就没问题了,全通了 大概是linux里 ...

  6. Go linux 实践4

    这是目前学习的最难的Go demo例子 ***************************************** 如果能看懂,你就出师了,我的任务也就结束了 **************** ...

  7. cocos2d-x C++ 判断当前平台宏定义大全

    /**************************************************************************** Copyright (c) 2010-201 ...

  8. 多模块项目提示“Module ** must not contain source root **. The root already belongs to module **”的解决办法

    从Project Structure里添加模块,完了点击Apply时弹出提示: Module "paycode"must not contain source root " ...

  9. Javascript-for循环案例-打印1-100之间所有的数字

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  10. hbase-java-api002(flush)

    package api; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apa ...