import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt 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') # hang lie 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.matmul(inputs, Weights) + biases if activation_function is None:
outputs = Wx_plus_b
else:
outputs = activation_function(Wx_plus_b)
return outputs #define placeholder
with tf.name_scope('inputs'):
xs = tf.placeholder(tf.float32, [None, 1], name = 'x_input')
ys = tf.placeholder(tf.float32, [None, 1], name = 'y_input') #add hidden layer
l1 = add_layer(xs, 1, 10, activation_function = tf.nn.relu)
#add output layer
prediction = add_layer(l1, 10, 1, activation_function = None) #the error between prediction and real data
with tf.name_scope('loss'):
loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction),
reduction_indices=[1] ))
with tf.name_scope('train'):
train_step = tf.train.GradientDescentOptimizer(0.1).minimize(loss) sess = tf.Session()
writer = tf.summary.FileWriter("logs/", sess.graph) #import step
sess.run(tf.global_variables_initializer() )

  

注意:有些浏览器可能支持的不好,推荐使用最新的Chrome

命令行输入:

tensorboard --logdir=logs/

莫烦TensorFlow_07 tensorboard可视化的更多相关文章

  1. 莫烦TensorFlow_08 tensorboard可视化进阶

    import tensorflow as tf import numpy as np import matplotlib.pyplot as plt # # add layer # def add_l ...

  2. 莫烦TensorFlow_06 plot可视化

    import tensorflow as tf import numpy as np import matplotlib.pyplot as plt def add_layer(inputs, in_ ...

  3. 莫烦大大TensorFlow学习笔记(9)----可视化

      一.Matplotlib[结果可视化] #import os #os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' import tensorflow as tf i ...

  4. tensorflow学习笔记-bili莫烦

    bilibili莫烦tensorflow视频教程学习笔记 1.初次使用Tensorflow实现一元线性回归 # 屏蔽警告 import os os.environ[' import numpy as ...

  5. tensorflow 莫烦教程

    1,感谢莫烦 2,第一个实例:用tf拟合线性函数 import tensorflow as tf import numpy as np # create data x_data = np.random ...

  6. Tensorflow 搭建神经网络及tensorboard可视化

    1. session对话控制 matrix1 = tf.constant([[3,3]]) matrix2 = tf.constant([[2],[2]]) product = tf.matmul(m ...

  7. scikit-learn学习笔记-bili莫烦

    bilibili莫烦scikit-learn视频学习笔记 1.使用KNN对iris数据分类 from sklearn import datasets from sklearn.model_select ...

  8. 莫烦pytorch学习笔记(八)——卷积神经网络(手写数字识别实现)

    莫烦视频网址 这个代码实现了预测和可视化 import os # third-party library import torch import torch.nn as nn import torch ...

  9. Tensorflow学习笔记3:TensorBoard可视化学习

    TensorBoard简介 Tensorflow发布包中提供了TensorBoard,用于展示Tensorflow任务在计算过程中的Graph.定量指标图以及附加数据.大致的效果如下所示, Tenso ...

随机推荐

  1. Mybatis工作原理(九)

    mybatis工作流程: (1) SqlSessionFactoryBuilder 从 XML 配置文件或通过Java的方式构建出 SqlSessionFactory 的实例. (2) SqlSess ...

  2. mysql里的insert

    insert不跟where 比如 insert into table (name) value('******')where id =1 肯定不行的 insert 语句 是插入语句,不跟条件的. 如果 ...

  3. c++负数下标

    如何使用负数下标呢? 让数组前面有东西 int y[100]; int *z = y + 50; 这样的话调用\(z[-50]\)就变成了调用\(y[0]\) z[-50] = y[0]; 然后这样就 ...

  4. xLua 学习

    xLua https://github.com/Tencent/xLua 文档 https://tencent.github.io/xLua/public/v1/guide/index.html FA ...

  5. bootstrap-switch使用

    bootstrap 的开关. 引入相关文件: <link href="https://cdn.bootcss.com/bootstrap-switch/4.0.0-alpha.1/cs ...

  6. Jupyter notebook中的.ipynb文件转换成python的.py文件

    转自:https://blog.csdn.net/wyr_rise/article/details/82656555 Jupyter notebook中.py与.ipynb文件的import问题   ...

  7. centos7彻底卸载mysql和通过yum安装mysql

    彻底卸载mysql 查看是否有安装的mysql rpm -qa | grep -i mysql // 查看命令1 1 这里写图片描述 yum list install mysql* // 查看命令2 ...

  8. 【Zabbix】zabora批量部署

    zabora简化批量部署 目的:简化部署zabora,批量监控数据库的常用指标 1 数据库用户赋权 上传cre_arp_monitor.sh,并且部署用户. [root@oradb ~]# chown ...

  9. ubuntu16.04 下anaconda3安装教程

    贴一个成功的连接: https://blog.csdn.net/u012243626/article/details/82469174

  10. jQuery 源码分析(一) 代码结构

    jQuery是一个Javascript库,它支持链式操作方式,即对发生在同一个JQuery对象上的一组动作,可以直接接连写无需要重复获取对象.这一特点使得JQuery的代码无比优雅,而且有强大的选择器 ...