# -*- 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文件夹,关闭控制台后才可以删除该文件夹)

最新文章

  1. Javascript一些实用技巧
  2. 小div布局之卡片堆叠(card-stacking)
  3. 如何删除datatable中的一行数据
  4. NPOI读取Excel 数据 转。。。
  5. debug不过的程序
  6. Intellij IDEA 根据数据库自动生成pojo和hbm
  7. leetcode 6
  8. UVaLive 6698 Sightseeing Bus Drivers (水题,贪心)
  9. mysqldump 备份原理8
  10. weixin
  11. 桌面浏览器实现滑动翻页效果(Swiper)
  12. SQL GROUP BY 语句
  13. 百度地图API-覆盖物
  14. vue项目通过webpack打包生成的dist文件放到express环境里运行(vue+webpack+express)
  15. CF1097G Vladislav and a Great Legend
  16. selenium处理元素定位到了点击无效问题
  17. Centos7搭建SS以及加速配置的操作记录 (转载)
  18. day15(PYTHON)推导式{生成器,字典,列表,集合}
  19. windows配置远程桌面连接到ubuntu
  20. Hive记录-配置客户端可视化管理工具远程连接

热门文章

  1. 让你的Spring Boot应用快速运行在Docker上面
  2. (转)理解maven命令package、install、deploy的联系与区别
  3. java的方法重写 ,多态和关键字 instanceof和final
  4. 用Mysql进行emp、dept、salgrade表的相关查询操作
  5. java爬虫实现爬取百度风云榜Top10
  6. JIRA API 对接
  7. java web项目部署到tomcat 8.5 此驱动程序不支持 Java Runtime Environment (JRE) 1.8 版。请使用支持 JDBC 4.0 的 sqljdbc4.jar 类库
  8. ASP.NET Core快速入门学习笔记(第3章:依赖注入)
  9. Core在类中注入
  10. dynamic动态类型的扩展方法