TensorBoard 实践 1
从新查看图的时候,删除旧的logs/下面的文件
tf.scalar_summary('loss',self.loss)
AttributeError: 'module' object has no attribute 'scalar_summary'
解决:
tf.scalar_summary('images', images)改为:tf.summary.scalar('images', images)
tf.image_summary('images', images)改为:tf.summary.image('images', images)
类似的有:
tf.train.SummaryWriter改为:tf.summary.FileWriter()
tf.merge_all_summaries()改为:summary_op = tf.summaries.merge_all()
tf.histogram_summary(var.op.name, var)改为: tf.summaries.histogram()
concated = tf.concat(1, [indices, sparse_labels])改为:concated = tf.concat([indices, sparse_labels], 1)
通过对命名空间管理,改进代码,使得可视化效果图更加清晰。 #coding=utf8 import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data import mnist_inference BATCH_SIZE = 100 LEARNING_RATE_BASE = 0.8 LEARNING_RATE_DECAY = 0.99 REGULARIZATION_RATE = 0.0001 TRAINING_STEPS = 3000 MOVING_AVERAGE_DECAY = 0.99 def train(mnist): # 输入数据的命名空间。 with tf.name_scope('input'): x = tf.placeholder(tf.float32, [None, mnist_inference.INPUT_NODE], name='x-input') y_ = tf.placeholder(tf.float32, [None, mnist_inference.OUTPUT_NODE], name='y-input') regularizer = tf.contrib.layers.l2_regularizer(REGULARIZATION_RATE) y = mnist_inference.inference(x, regularizer) global_step = tf.Variable(0, trainable=False) # 处理滑动平均的命名空间。 with tf.name_scope("moving_average"): variable_averages = tf.train.ExponentialMovingAverage(MOVING_AVERAGE_DECAY, global_step) variables_averages_op = variable_averages.apply(tf.trainable_variables()) # 计算损失函数的命名空间。 with tf.name_scope("loss_function"): cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(logits=y, labels=tf.argmax(y_, 1)) cross_entropy_mean = tf.reduce_mean(cross_entropy) loss = cross_entropy_mean + tf.add_n(tf.get_collection('losses')) # 定义学习率、优化方法及每一轮执行训练的操作的命名空间。 with tf.name_scope("train_step"): learning_rate = tf.train.exponential_decay( LEARNING_RATE_BASE, global_step, mnist.train.num_examples / BATCH_SIZE, LEARNING_RATE_DECAY, staircase=True) train_step = tf.train.GradientDescentOptimizer(learning_rate).minimize(loss, global_step=global_step) with tf.control_dependencies([train_step, variables_averages_op]): train_op = tf.no_op(name='train') writer = tf.summary.FileWriter("./log/modified_mnist_train.log", tf.get_default_graph()) # 训练模型。 with tf.Session() as sess: tf.global_variables_initializer().run() for i in range(TRAINING_STEPS): xs, ys = mnist.train.next_batch(BATCH_SIZE) if i % 1000 == 0: # 配置运行时需要记录的信息。 run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE) # 运行时记录运行信息的proto。 run_metadata = tf.RunMetadata() _, loss_value, step = sess.run( [train_op, loss, global_step], feed_dict={x: xs, y_: ys}, options=run_options, run_metadata=run_metadata) writer.add_run_metadata(run_metadata=run_metadata, tag=("tag%d" % i), global_step=i) print("After %d training step(s), loss on training batch is %g." % (step, loss_value)) else: _, loss_value, step = sess.run([train_op, loss, global_step], feed_dict={x: xs, y_: ys}) writer.close() def main(argv=None): mnist = input_data.read_data_sets("MNIST_data", one_hot=True) train(mnist) if __name__ == '__main__': main()
可视化效果图:
TensorBoard 实践 1的更多相关文章
- TF:TF之Tensorboard实践:将神经网络Tensorboard形式得到events.out.tfevents文件+dos内运行该文件本地服务器输出到网页可视化—Jason niu
import tensorflow as tf import numpy as np def add_layer(inputs, in_size, out_size, n_layer, activat ...
- tensorflow笔记(三)之 tensorboard的使用
tensorflow笔记(三)之 tensorboard的使用 版权声明:本文为博主原创文章,转载请指明转载地址 http://www.cnblogs.com/fydeblog/p/7429344.h ...
- 学习笔记TF039:TensorBoard
首先向大家和<TensorFlow实战>的作者说句不好意思.我现在看的书是<TensorFlow实战>.但从TF024开始,我在学习笔记的参考资料里一直写的是<Tenso ...
- 4. Tensorflow的Estimator实践原理
1. Tensorflow高效流水线Pipeline 2. Tensorflow的数据处理中的Dataset和Iterator 3. Tensorflow生成TFRecord 4. Tensorflo ...
- ML平台_小米深度学习平台的架构与实践
(转载:http://www.36dsj.com/archives/85383)机器学习与人工智能,相信大家已经耳熟能详,随着大规模标记数据的积累.神经网络算法的成熟以及高性能通用GPU的推广,深度学 ...
- Ubuntu环境下TensorBoard 可视化 不显示数据问题 No scalar data was found...(作者亲测有效)(转)
TensorBoard:Tensorflow自带的可视化工具.利用TensorBoard进行图表可视化时遇到了图表不显示的问题. 环境:Ubuntu系统 运行代码,得到TensorFlow的事件文件l ...
- 3.keras实现-->高级的深度学习最佳实践
一.不用Sequential模型的解决方案:keras函数式API 1.多输入模型 简单的问答模型 输入:问题 + 文本片段 输出:回答(一个词) from keras.models import M ...
- FasterRCNN目标检测实践纪实
首先声明参考博客:https://blog.csdn.net/beyond_xnsx/article/details/79771690?tdsourcetag=s_pcqq_aiomsg 实践过程主线 ...
- Python玩转人工智能最火框架 TensorFlow应用实践 ☝☝☝
Python玩转人工智能最火框架 TensorFlow应用实践 (一个人学习或许会很枯燥,但是寻找更多志同道合的朋友一起,学习将会变得更加有意义✌✌) 全民人工智能时代,不甘心只做一个旁观者,那就现在 ...
随机推荐
- Eclipse如何快速改变主题颜色
厌倦了Eclipse的白底黑子,我们来更换下Eclipse的主题颜色,让眼睛更舒服一点 首先先进入网址:http://eclipsecolorthemes.org/ 选择一个主题进入,点击进入如下: ...
- php 四种基础排序
1. 冒泡排序算法 * 思路分析:法如其名,就是像冒泡一样,每次从数组当中 冒一个最大的数出来. * 比如:2,4,1 // 第一次 冒出的泡是4 * ...
- C#实现的UDP收发请求工具类实例
本文实例讲述了C#实现的UDP收发请求工具类.分享给大家供大家参考,具体如下: 初始化: ListeningPort = int.Parse(ConfigurationManager.AppSetti ...
- 【转】ArcGIS API for Silverlight/WPF 2.1学习笔记(三)
六.Feature Layer Feature Layer是一种特殊的Graphics layer(继承自Graphics layer),除了像Graphics layer一样包含和显示Graphic ...
- 23 正则表达式和re模块
一.正则1.字符组 [a-zA-Z0-9]字符组中的 [^a] 除了字符组的 2. 3. 4. 二.re模块 re.S 设置 .的换行 obj=re 1.ret=re.search(正则,conten ...
- zzuli 1432(二进制特点)
1432: 背包again Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 222 Solved: 65 SubmitStatusWeb Board ...
- 关于vue Unexpected identifier 问题
vue对于es6虽然自带babel转换 但是在index.html文件中并不会发生转换 因此在index.html中使用新的语法会导致低版本浏览器不识别代码因此报出Unexpected identif ...
- Oracle 小函数的使用
1.Oracle 正则表达式 经常会有一种需求是查询某个字符在字符串中的数量,可以使用正则表达式regexp_count函数 比如 SELECT regexp_count('0,1,1',',') f ...
- springboot + swagger的实体类属性注解
@Api:用在类上,说明该类的作用 @ApiOperation:用在方法上,说明方法的作用 @ApiImplicitParams:用在方法上包含一组参数说明 @ApiImplicitParam:用在@ ...
- PHP:第二章——PHP中的break一continue一return语句
知识点一:break语句 break 结束当前 for,foreach,while,do-while 或者 switch 结构的执行. break 可以接受一个可选的数字参数来决定跳出 ...