深度学习(二)---tflearn分类,tensorboard安装、使用

几个概念

batch_size、epoch

sample_size = 20000; //样本为20000个
batch_size = 64;//64个样本为一批进行一次训练
epoch = 200; //全部样本训练完一次,记1个epoch

深度机器学习中的batch的大小对学习效果有何影响?

Tensorflow训练

TensorFlow系列03——TensorFlow基本概念Tensor理解

tflearn分类-17flower
Deep Learning-TensorFlow (10) CNN卷积神经网络_ TFLearn 快速搭建深度学习模型

tensorboard使用

安装

安装tensorflow库后,就包含tensorboard。如果没有tensorboard.exe,重新卸载并安装tensorflow。

pip uninstall tensorflow
pip install tensorflow

数据准备

保存代码为test.py.

import tensorflow as tf
import numpy as np

## prepare the original data
with tf.name_scope('data'):
     x_data = np.random.rand(100).astype(np.float32)
     y_data = 0.3*x_data+0.1
##creat parameters
with tf.name_scope('parameters'):
     weight = tf.Variable(tf.random_uniform([1],-1.0,1.0))
     bias = tf.Variable(tf.zeros([1]))
##get y_prediction
with tf.name_scope('y_prediction'):
     y_prediction = weight*x_data+bias
##compute the loss
with tf.name_scope('loss'):
     loss = tf.reduce_mean(tf.square(y_data-y_prediction))
##creat optimizer
optimizer = tf.train.GradientDescentOptimizer(0.5)
#creat train ,minimize the loss 
with tf.name_scope('train'):
     train = optimizer.minimize(loss)
#creat init
with tf.name_scope('init'): 
     init = tf.global_variables_initializer()
##creat a Session 
sess = tf.Session()
##initialize
##注意设置数据输出目录 D:/logs
writer = tf.summary.FileWriter("D:/logs", sess.graph) 
sess.run(init)
## Loop
for step  in  range(101):
    sess.run(train)
    if step %10==0 :
        print step ,'weight:',sess.run(weight),'bias:',sess.run(bias)

运行结果为:
这里写图片描述

使用tensorboard

执行命令运行服务器
以下任一种方式都可以:

/*方式一*/
tensorboard --logdir=d:/logs
/*方式二*/
python main.py --logdir=d:/logs

这里写图片描述

访问
从上图执行结果中可以看出,打开浏览器访问:localhost:6006,就可以看到图形了。
这里写图片描述

出现的问题

网页显示空白
A:这个原因是浏览器版本太低,我之前用的4.9版本不行,更新到6.3可以了。

网页没有数据“No graph…”
A:数据路径设置不对。可以设置到D盘根目录。

参考:tensorflow笔记(三)之 tensorboard的使用

TensorFlow深度学习笔记 Tensorboard入门

TensorBoard–TensorFlow可视化

Caffe训练

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值