Windows下坑太多......

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

       1、我没找不到log文件?!
             答:所谓的log文件其实就是在你train过程中保存的关于你train的所有详尽信息。
                    文件的格式是:events.out.tfevents.1493741531.DESKTOP-CJI9GBL
                    你只需要找出events.out.tfevents开头的文件即可,后面的那个是跟你的电脑有关的一个标识,不用管。
  2.打开了TensorBoard,但是没有显示。例如下面的情况:
  

       这种情况,其实我也遇到过。明明能打开的,但是为什么就是不对呢?
  原因主要有这几个:
       1、路径不对。在路径不对的情况下,按照上面的步骤也能打开TensorBoard,但不是我想要的信息。
       2、文件出错。在train阶段,发生了错误,所以没法在TensorBoard上显示出train的信息。
 

查看指定端口并kill

也可以使用lsof命令:

lsof -i:8888

若要关闭使用这个端口的程序,使用kill + 对应的pid

kill -9 PID号

启动jupyter notebook

 

通过windows远程调用写一个Demo

启动tensorboard并通过web访问:

sudo tensorboard --logdir='.' --port=8811

  1. """
  2. Please note, this code is only for python 3+. If you are using python 2+, please modify the code accordingly.
  3. """
  4. #-*-coding:utf8-*-
  5.  
  6. import tensorflow as tf
  7. import numpy as np
  8.  
  9. def add_layer(inputs, in_size, out_size, n_layer, activation_function=None):
  10. # add one more layer and return the output of this layer
  11. layer_name = 'layer%s' % n_layer
  12. with tf.name_scope(layer_name):
  13. with tf.name_scope('weights'):
  14. Weights = tf.Variable(tf.random_normal([in_size, out_size]), name='W')
  15. tf.summary.histogram(layer_name + '/weights', Weights)
  16. with tf.name_scope('biases'):
  17. biases = tf.Variable(tf.zeros([1, out_size]) + 0.1, name='b')
  18. tf.summary.histogram(layer_name + '/biases', biases)
  19. with tf.name_scope('Wx_plus_b'):
  20. Wx_plus_b = tf.add(tf.matmul(inputs, Weights), biases)
  21. if activation_function is None:
  22. outputs = Wx_plus_b
  23. else:
  24. outputs = activation_function(Wx_plus_b, )
  25. tf.summary.histogram(layer_name + '/outputs', outputs)
  26. return outputs
  1. # Make up some real data
  2. x_data = np.linspace(-1, 1, 300)[:, np.newaxis]
  3. noise = np.random.normal(0, 0.05, x_data.shape)
  4. y_data = np.square(x_data) - 0.5 + noise
  5. # define placeholder for inputs to network
  6. with tf.name_scope('inputs'):
  7. xs = tf.placeholder(tf.float32, [None, 1], name='x_input')
  8. ys = tf.placeholder(tf.float32, [None, 1], name='y_input')
  9.  
  10. # add hidden layer
  11. l1 = add_layer(xs, 1, 10, n_layer=1, activation_function=tf.nn.relu)
  12. # add output layer
  13. prediction = add_layer(l1, 10, 1, n_layer=2, activation_function=None)
  14.  
  15. # the error between prediciton and real data
  16. with tf.name_scope('loss'):
  17. loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction),
  18. reduction_indices=[1]))
  19. tf.summary.scalar('loss', loss)
  20.  
  21. with tf.name_scope('train'):
  22. train_step = tf.train.GradientDescentOptimizer(0.1).minimize(loss)
  23. sess = tf.Session()
  24. merged = tf.summary.merge_all()
  25.  
  26. writer = tf.summary.FileWriter("./tensorlogs/", sess.graph)
  27. init = tf.global_variables_initializer()
  28. sess.run(init)

下面代码在python3中正常,在python2中需要更改

  1. for i in range(1000):
  2. sess.run(train_step, feed_dict={xs: x_data, ys: y_data})
  3. if i % 50 == 0:
  4. result = sess.run(merged,feed_dict={xs: x_data, ys: y_data})
  5. writer.add_summary(result, i)
  6.  
  7. # direct to the local dir and run this in terminal:
  8. # $ tensorboard --logdir logs

web页面显示

 
 
 
 

1.tTensorboard的更多相关文章

随机推荐

  1. Java从控制台接受输入字符

    创建一个类,在该类的主方法中创建Scanner扫描起来封装System类的in输入流,然后提示用户输入身份证号码,并输入身份证号码的位数. 代码如下: import java.util.Scanner ...

  2. SPREAD for Windows Forms 代码片段

    'スクロールバーの移動 FpSpread1.ShowColumn(, , HorizontalPosition.Left) 'SetActiveCellの後.LeaveCellを呼び出す Dim ss ...

  3. c# new的三种用法

    在 C# 中,new 关键字可用作运算符.修饰符或约束. 1)new 运算符:用于创建对象和调用构造函数.这种大家都比较熟悉,没什么好说的了. 2)new 修饰符:在用作修饰符时,new 关键字可以显 ...

  4. vue-resource和vue-axios的简单使用方法

    两者其实差别不大,都是基于es6的Promise对象实现的方法 vue-resource: main.js => import Vue from 'vue'; import VueResourc ...

  5. spring + Mybatis + pageHelper + druid 整合源码分享

    springMvc + spring + Mybatis + pageHelper + druid 整合 spring 和druid整合,spring 整合druid spring 和Mybatis  ...

  6. 【Python】TF环境

    1.pip show pip 2.python -m pip install --upgrade pip 3.conda list 4.pip install tensorflow 5.pip ins ...

  7. 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 ...

  8. 最短路径——Dijkstra算法和Floyd算法

    Dijkstra算法概述 Dijkstra算法是由荷兰计算机科学家狄克斯特拉(Dijkstra)于1959 年提出的,因此又叫狄克斯特拉算法.是从一个顶点到其余各顶点的最短路径算法,解决的是有向图(无 ...

  9. Git和GitHub入门基础

    -----------------------------------------//cd F:/learngit // 创建仓库git init  // 在当前目录下创建空的git仓库------- ...

  10. 微信小程序 禁止ios页面下拉下滑滚动 出现空白的情况

    项目需要做了一个图片拖动指定组件上删除,和排序的功能android测试正常, ios会出现拖动图片页面也跟着下滑的尴尬情况. 查文档下拉刷新配置默认是关闭的,后经查找文档发现在本页面page.json ...