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. 使用system V实现读者写者问题

    #include <stdio.h> #include <sys/sem.h> #include <sys/ipc.h> #include <string.h ...

  2. AtCoder Grand Contest 037

    Preface 这篇咕了可能快一个月了吧,正好今天晚上不想做题就来补博客 现在还不去复习初赛我感觉我还是挺刚的(微笑) A - Dividing a String 考虑最好情况把每个字符串当作一个来看 ...

  3. 大话OI

    本文将收录一切我认为对我十分有帮助的他人的博文以及我认为有价值的我自己的原创文章. 引言 有人说:程序=算法+数据结构,所以OI=程序=算法+数据结构. 在我看来,这句话的前半句是对的,但后半句则有本 ...

  4. Laravel5 --- QQ邮箱发送邮件

    1. 在此之前先确认QQ邮箱是否开启了POP3/SMTP服务,如果未开启则须开启 QQ邮箱->设置->账户->POP3/IMAP/SMTP/Exchange/CardDAV/CalD ...

  5. 爬虫——爬取Ajax动态加载网页

    常见的反爬机制及处理方式 1.Headers反爬虫 :Cookie.Referer.User-Agent 解决方案: 通过F12获取headers,传给requests.get()方法 2.IP限制 ...

  6. Spring Cloud 新一代Web框架微服务翘楚(一)

    序言 springcloud是微服务架构的集大成者,将一系列优秀的组件进行了整合.基于springboot构建,对我们熟悉spring的程序员来说,上手比较容易. 通过一些简单的注解,我们就可以快速的 ...

  7. Elastic Beats介绍

    需要学习的地方:概念,用法,模块使用 Elastic Beats介绍 Elastic Stack传统上由三个主要组件(Elasticsearch,Logstash和Kibana)组成,早已脱离了这种组 ...

  8. ASP.NET MVC IOC 之 Autofac 系列开篇

    本系列主要讲述Autofac在.NET MVC项目以及webform中的使用. autofac为IOC组件,实现控制反转,主要结合面向接口编程,完成较大程度的解耦工作. 作为初学者,将学习到的每一步, ...

  9. Python【day 12】生成器和推导式

    一.生成器和生成器函数1.生成器和生成器函数的概念 1.生成器的本质是迭代器 2.函数中包含yield,就是生成器函数 2.生成器函数的写法 def func(): a =10 yield 20 ge ...

  10. Django的路由系统:URL

    一. URLconf配置 基本格式 from django.conf.urls import url urlpatterns = [ url(正则表达式, views视图,参数,别名), ] 参数说明 ...