莫烦PYTHON | Tensorflow教程——可视化好助手Tensorboard(第四章)

本文详细介绍了如何使用Tensorboard进行神经网络结构的可视化和训练过程的监控。通过Event、Scalar、Image、Audio、Histogram等功能展示训练数据,并提供了解决Tensorboard端口被占用问题的方法。
摘要由CSDN通过智能技术生成

4.1 Tensorboard 可视化好帮手 1

Event / Scalar: 展示训练过程中的统计数据(最值,均值等)变化情况
Image: 展示训练过程中记录的图像
Audio: 展示训练过程中记录的音频
Histogram: 展示训练过程中记录的数据的分布图
Graphs: 展示神经网络结构图

可视化整个神经网络的结构

代码是前几节的截取

from __future__ import print_function
import tensorflow as tf


def add_layer(inputs, in_size, out_size, activation_function=None):
    # add one more layer and return the output of this layer
    with tf.name_scope('layer888'): #为隐藏层添加名字layer888(大框架)
        with tf.name_scope('WWWWWWWWW'): #为weights层添加名字WWWWWWWW(小部件)
            Weights = tf.Variable(tf.random_normal([in_size, out_size]), name='W') #为weights取名为W
        with tf.name_scope('biasesss'):
            biases = tf.Variable(tf.zeros([1, out_size]) + 0.1, name='b')
        with tf.name_scope('Wx_plus_bbbb'):
            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


# define placeholder for inputs to network
with tf.name_scope('inputsss'):
    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, activation_function=tf.nn.relu)
# add output layer
prediction = add_layer(l1, 10, 1, activation_function=None)

# the error between prediciton and real data
with tf.name_scope('losssss'):
    loss = tf.reduce_mean(tf.reduce_sum(tf.square(ys - prediction),
                                        reduction_indices&
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值