# -*- coding: utf-8 -*-
"""
Created on Sun Nov 5 09:29:36 2017

@author: Admin
"""

import tensorflow as tf

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

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')

l1 = add_layer(xs, 1, 10, activation_function = tf.nn.relu)
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, name='square'), reduction_indices = [1], name='reduce_sum'),
name='reduce_mean')
with tf.name_scope('train'):
train_step = tf.train.GradientDescentOptimizer(0.1).minimize(loss)

sess = tf.Session()
#writer = tf.train.SummaryWriter("/logs",sess.graph)
writer = tf.summary.FileWriter("D://path/to/log", sess.graph)
sess.run(tf.global_variables_initializer())

cmd  >>  tensorboard --logdir=D://path/to/log

浏览器:http://localhost:6006/#graphs

(控制台每运行一次,train一个神经网络进行可视化)

(控制台每多run一个文件,多可视化一个文件的图像,清除  ->  关闭控制台重启)

(D://path/to/log  表示在D盘下生成path文件夹,关闭控制台后才可以删除该文件夹)

Tensorboard可视化的更多相关文章

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

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

  2. 学习TensorFlow,TensorBoard可视化网络结构和参数

    在学习深度网络框架的过程中,我们发现一个问题,就是如何输出各层网络参数,用于更好地理解,调试和优化网络?针对这个问题,TensorFlow开发了一个特别有用的可视化工具包:TensorBoard,既可 ...

  3. tensorboard可视化节点却没有显示图像的解决方法---注意路径问题加中文文件名

    问题:完成graph中的算子,并执行tf.Session后,用tensorboard可视化节点时,没有显示图像 1. tensorboard 1.10 我是将log文件存储在E盘下面的,所以直接在E盘 ...

  4. 在Keras中使用tensorboard可视化acc等曲线

    1.使用tensorboard可视化ACC,loss等曲线 keras.callbacks.TensorBoard(log_dir='./Graph', histogram_freq= 0 , wri ...

  5. 超简单tensorflow入门优化程序&&tensorboard可视化

    程序1 任务描述: x = 3.0, y = 100.0, 运算公式 x×W+b = y,求 W和b的最优解. 使用tensorflow编程实现: #-*- coding: utf-8 -*-) im ...

  6. 使用TensorBoard可视化工具

    title: 使用TensorBoard可视化工具 date: 2018-04-01 13:04:00 categories: deep learning tags: TensorFlow Tenso ...

  7. 利用tensorboard可视化checkpoint模型文件参数分布

    写在前面: 上周微调一个文本检测模型seglink,将特征提取层进行冻结,只训练分类回归层,然而查看tensorboard发现里面有histogram显示模型各个参数分布,看了目前这个训练模型参数分布 ...

  8. 【猫狗数据集】利用tensorboard可视化训练和测试过程

    数据集下载地址: 链接:https://pan.baidu.com/s/1l1AnBgkAAEhh0vI5_loWKw提取码:2xq4 创建数据集:https://www.cnblogs.com/xi ...

  9. 使用 TensorBoard 可视化模型、数据和训练

    使用 TensorBoard 可视化模型.数据和训练 在 60 Minutes Blitz 中,我们展示了如何加载数据,并把数据送到我们继承 nn.Module 类的模型,在训练数据上训练模型,并在测 ...

  10. tensorflow Tensorboard可视化-【老鱼学tensorflow】

    tensorflow自带了可视化的工具:Tensorboard.有了这个可视化工具,可以让我们在调整各项参数时有了可视化的依据. 本次我们先用Tensorboard来可视化Tensorflow的结构. ...

随机推荐

  1. sublime text3输出窗口中文显示乱码问题解决方案

    1 前言 略 2 方案 修改Python3.sublime-build内容为 { "cmd": ["C:/Users/Administrator/AppData/Loca ...

  2. 工具篇之GIT知识整理(一)

    目录 项目工具篇(一)GIT 说在前面 背景 与其他版本控制产品对比 Git下载地址及安装 下载地址 安装 在案例中简单使用Git命令 git clone git log git diff git c ...

  3. SpringJUnit4ClassRunner (单元测试)

    1.在Maven的pom.xml中加入 <dependency> <groupId>junit</groupId> <artifactId>junit& ...

  4. JSP & EL & JSTL

    JSP 什么是JSP 用户角度看待 ,就是是一个网页,从程序员角度看待 ,是继承了servlet的java类,所以可以直接说jsp 就是一个Servlet. 为什么用JSP 用于显示一些动态数据,可以 ...

  5. luoguP1941-

    飞扬的小鸟 20分&50分: #include<iostream> #include<cstdio> #include<cstring> #include& ...

  6. Hive学习笔记 --Permission denied: user=anonymous, access=READ

    执行select语句报错 Error: java.io.IOException: org.apache.hadoop.security.AccessControlException: Permissi ...

  7. [原创]Modelsim后仿真

    因调试需要,进行后仿真,ISE生成的sim文件和sdf文件 `timescale ns/ ps module lut_dly ( clkout, fpga_clk, config_in ); outp ...

  8. 利用MMdnn对比keras和mxnet

    关键字 MMdnn,keras,mxnet,resnet50 需求:想测试一下keras下model转到MXNet框架下对于同一张图片各中间层输出结果有什么差异. 一. 前期准备 1. 依赖库的选择 ...

  9. hadoop部署

    [root@xiong ~]# hostnamectl set-hostname hadoop001 [root@xiong ~]# vim /etc/hostnamehadoop001 vim /e ...

  10. LOJ#6374 网格

    题解: 挺好的一道题 两次容斥+一次二项式反演 首先考虑部分分不存在k的限制 然后我们发现两维之间是互相独立的 下面以x轴为例 然后问题就变成了 $$\sum\limits_{i=1}^{R} {xi ...