1.tTensorboard
Windows下坑太多......
在启动TensorBoard的过程,还是遇到了一些问题。接下来简单的总结一下我遇到的坑。

查看指定端口并kill
也可以使用lsof命令:
lsof -i:8888
若要关闭使用这个端口的程序,使用kill + 对应的pid
kill -9 PID号

启动jupyter notebook

通过windows远程调用写一个Demo
启动tensorboard并通过web访问:
sudo tensorboard --logdir='.' --port=8811
- """
- Please note, this code is only for python 3+. If you are using python 2+, please modify the code accordingly.
- """
- #-*-coding:utf8-*-
- import tensorflow as tf
- import numpy as np
- def add_layer(inputs, in_size, out_size, n_layer, activation_function=None):
- # add one more layer and return the output of this layer
- layer_name = 'layer%s' % n_layer
- with tf.name_scope(layer_name):
- with tf.name_scope('weights'):
- Weights = tf.Variable(tf.random_normal([in_size, out_size]), name='W')
- tf.summary.histogram(layer_name + '/weights', Weights)
- with tf.name_scope('biases'):
- biases = tf.Variable(tf.zeros([1, out_size]) + 0.1, name='b')
- tf.summary.histogram(layer_name + '/biases', biases)
- 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, )
- tf.summary.histogram(layer_name + '/outputs', outputs)
- return outputs
- # Make up some real data
- x_data = np.linspace(-1, 1, 300)[:, np.newaxis]
- noise = np.random.normal(0, 0.05, x_data.shape)
- y_data = np.square(x_data) - 0.5 + noise
- # define placeholder for inputs to network
- 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, n_layer=1, activation_function=tf.nn.relu)
- # add output layer
- prediction = add_layer(l1, 10, 1, n_layer=2, activation_function=None)
- # the error between prediciton and real data
- with tf.name_scope('loss'):
- loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction),
- reduction_indices=[1]))
- tf.summary.scalar('loss', loss)
- with tf.name_scope('train'):
- train_step = tf.train.GradientDescentOptimizer(0.1).minimize(loss)
- sess = tf.Session()
- merged = tf.summary.merge_all()
- writer = tf.summary.FileWriter("./tensorlogs/", sess.graph)
- init = tf.global_variables_initializer()
- sess.run(init)
下面代码在python3中正常,在python2中需要更改
- for i in range(1000):
- sess.run(train_step, feed_dict={xs: x_data, ys: y_data})
- if i % 50 == 0:
- result = sess.run(merged,feed_dict={xs: x_data, ys: y_data})
- writer.add_summary(result, i)
- # direct to the local dir and run this in terminal:
- # $ tensorboard --logdir logs
web页面显示
1.tTensorboard的更多相关文章
随机推荐
- Java从控制台接受输入字符
创建一个类,在该类的主方法中创建Scanner扫描起来封装System类的in输入流,然后提示用户输入身份证号码,并输入身份证号码的位数. 代码如下: import java.util.Scanner ...
- SPREAD for Windows Forms 代码片段
'スクロールバーの移動 FpSpread1.ShowColumn(, , HorizontalPosition.Left) 'SetActiveCellの後.LeaveCellを呼び出す Dim ss ...
- c# new的三种用法
在 C# 中,new 关键字可用作运算符.修饰符或约束. 1)new 运算符:用于创建对象和调用构造函数.这种大家都比较熟悉,没什么好说的了. 2)new 修饰符:在用作修饰符时,new 关键字可以显 ...
- vue-resource和vue-axios的简单使用方法
两者其实差别不大,都是基于es6的Promise对象实现的方法 vue-resource: main.js => import Vue from 'vue'; import VueResourc ...
- spring + Mybatis + pageHelper + druid 整合源码分享
springMvc + spring + Mybatis + pageHelper + druid 整合 spring 和druid整合,spring 整合druid spring 和Mybatis ...
- 【Python】TF环境
1.pip show pip 2.python -m pip install --upgrade pip 3.conda list 4.pip install tensorflow 5.pip ins ...
- Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:25:5-27:41 to override.
记录下来少走些坑吧 一:不管用 tools:replace="android:icon,android:theme" xmlns:tools="http://schema ...
- 最短路径——Dijkstra算法和Floyd算法
Dijkstra算法概述 Dijkstra算法是由荷兰计算机科学家狄克斯特拉(Dijkstra)于1959 年提出的,因此又叫狄克斯特拉算法.是从一个顶点到其余各顶点的最短路径算法,解决的是有向图(无 ...
- Git和GitHub入门基础
-----------------------------------------//cd F:/learngit // 创建仓库git init // 在当前目录下创建空的git仓库------- ...
- 微信小程序 禁止ios页面下拉下滑滚动 出现空白的情况
项目需要做了一个图片拖动指定组件上删除,和排序的功能android测试正常, ios会出现拖动图片页面也跟着下滑的尴尬情况. 查文档下拉刷新配置默认是关闭的,后经查找文档发现在本页面page.json ...