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. 浅谈lowbit运算

    关于lowbit运算的相关知识 本篇随笔简单讲解一下计算机中位运算的一类重要运算方式--\(lowbit\)运算. lowbit的概念 我们知道,任何一个正整数都可以被表示成一个二进制数.如: \[ ...

  2. C语言中,如何输出一个菱形!

    int zh,zl,h,l;                                                  //zh:行的总数 zl:列的总数  h:当前行  l:当前列 for( ...

  3. 5个你可能不知道的html5语义化标签

    1.<ruby>:该标签作用为注释(中文注音或字符),比如可实现下面样式  详见:https://www.w3cschool.cn/html5/html5-ruby.html 2.< ...

  4. 知识图谱与Bert结合

    论文题目: ERNIE: Enhanced Language Representation with Informative Entities(THU/ACL2019) 本文的工作也是属于对BERT锦 ...

  5. python随机选取目录下的若干个文件

    个人记录用. python模块random argparse shutil import argparse parser = argparse.ArgumentParser() parser.add_ ...

  6. 5种mysql日志分析工具比拼

    5种mysql日志分析工具比拼 摘自: linux.chinaitlab.com  被阅读次数: 79 由 yangyi 于 2009-08-13 22:18:05 提供 mysql slow log ...

  7. C# SmtpClient 发邮件

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  8. (九)分布式服务----Zookeeper注册中心

    ==>>点击查看本系列文章目录 首先看一下几种注册中心: 最老的就是Zookeeper了, 比较新的有Eureka,Consul 都可以做注册中心.可以自行搜索对比三者的优缺点. Zook ...

  9. windows7系统 执行应用程序报 Error accessing specified device (Error: 2)

    --------------------------- ---------------------------Error accessing specified device (Error: 2) - ...

  10. javascript 关于赋值、浅拷贝、深拷贝的个人理解

    关于赋值.浅拷贝.深拷贝,以前也思考良久,很多时候都以为记住了,但是,我太难了.今天我特地写下笔记,希望可以完全掌握这个东西,也希望可以帮助到任何想对学习这个东西的同学. 一.栈.堆.指针地址 栈内存 ...