tf6. Tensorboard 图
2017-08-01 07:56
141 查看
import sys print(sys.version) ''' 3.5.3 |Continuum Analytics, Inc.| (default, May 15 2017, 10:43:23) [MSC v.1900 64 bit (AMD64)] ''' import tensorflow as tf import numpy as np def add_layer(inputs, in_size, out_size, activation_function=None): with tf.name_scope('layer'): with tf.name_scope('weights'): Weights = tf.Variable( tf.random_normal([in_size, out_size]), name='W') with tf.name_scope('biases'): biases = tf.Variable( tf.zeros([1, out_size]) + 0.1, name='b') with tf.name_scope('Wx_plus_b'): Wx_plus_b = tf.add( tf.matmul(inputs, Weights), biases) if activation_function is None: outputs = Wx_plus_b else: outputs = activation_function(Wx_plus_b) return outputs x_data = np.linspace(-1,1,300, dtype=np.float32)[:, np.newaxis] noise = np.random.normal(0, 0.05, x_data.shape).astype(np.float32) y_data = np.square(x_data) - 0.5 + noise #这里的None代表无论输入有多少都可以,因为输入只有一个特征,所以这里是1 with tf.name_scope('inputs'): xs = tf.placeholder(tf.float32, [None, 1],name='x_in') ys = tf.placeholder(tf.float32, [None, 1],name='y_in') #通常神经层都包括输入层、隐藏层和输出层。这里的输入层只有一个属性, 所以我们就只有一个输入;隐藏层我们可以自己假设,这里我们假设隐藏层有10个神经元; # 输出层和输入层的结构是一样的,所以我们的输出层也是只有一层。 所以,我们构建的是——输入层1个、隐藏层10个、输出层1个的神经网络。 l1 = add_layer(xs, 1, 10, activation_function=tf.nn.relu) #接着,定义输出层。此时的输入就是隐藏层的输出——l1,输入有10层(隐藏层的输出层),输出有1层。 prediction = add_layer(l1, 10, 1, activation_function=None) #对二者差的平方求和再取平均 with tf.name_scope('loss'): loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction),reduction_indices=[1])) #接下来,是很关键的一步,如何让机器学习提升它的准确率。tf.train.GradientDescentOptimizer()中的值通常都小于1,这里取的是0.1,代表以0.1的效率来最小化误差loss。 with tf.name_scope('train'): train_step = tf.train.GradientDescentOptimizer(0.1).minimize(loss) init = tf.global_variables_initializer() sess = tf.Session() writer = tf.summary.FileWriter("logs/", sess.graph) sess.run(init)
切换到logs父目录
http://localhost:6006/#graphs
相关文章推荐
- 学习笔记TF039:TensorBoard
- 学习笔记TF047:PlayGround、TensorBoard
- Lenet-5 MNIST Tensorboard 参数可视化 直方图 tf.Summary.histogram,tf.Summary.scalar,tf.Summary.image
- TF之RNN:TensorBoard可视化之基于顺序的RNN回归案例实现蓝色正弦虚线预测红色余弦实线—Jason niu
- TF:利用sklearn自带数据集使用dropout解决学习中overfitting的问题+Tensorboard显示变化曲线—Jason niu
- TensorFlow高级API(tf.contrib.learn)及可视化工具TensorBoard的使用
- TensorBoard对训练过程可视化(不用tf.summaries.merge_all)
- TensorBoard tf.summary.merge_all() AttributeError: 'NoneType' object has no attribute 'bucket 错误
- 解决根据tensorboard调用events.out.tfevents文件得到网址出现No dashboards are active for the current data set问题
- TF:Tensorflow之Tensorboard可视化使用总结—Jason niu
- TF:TF之Tensorboard实践:将神经网络Tensorboard形式得到events.out.tfevents文件+dos内运行该文件本地服务器输出到网页可视化—Jason niu
- TensorFlow高级API(tf.contrib.learn)及可视化工具TensorBoard的使用
- Tensorflow实现Mnist的Tensorboard
- 【TensorBoard】如何启动tensorboard的详尽步骤
- tensorflow tensorboard相关的资料
- TensorFlow MNIST TensorBoard版本
- keras tensorboard的使用, 设置指定GPU及其内存, 强制只使用cpu
- Jupyter notebook import tensorflow as tf 出错
- TensotFlow 应用实例:08-使用tensorboard可视化神经网络结构和训练结果
- 两个卷积神经的tensorboard图表对比