Tensorboard v1.0-直方图选项卡解释 [英] Tensorboard v1.0 - Histogram tab interpretation

查看:51
本文介绍了Tensorboard v1.0-直方图选项卡解释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习通过张量板可视化张量,但是,我不知道如何在直方图"选项卡中解释图表.我使用下面的代码进行可视化:

  sess = tf.Session()tf.summary.histogram('test',tf.constant([1,1,2,2,3,4,4,4,4]))摘要= tf.summary.merge_all()train_writer = tf.summary.FileWriter('../tmp/train',sess.graph)对于我在范围(10)中:sum = sess.run(摘要)train_writer.add_summary(求和,i) 

我从张量板得到了这张图:

直方图模式:偏移

直方图模式:重叠

我知道x轴是值,y轴是时间步长,我不知道是z轴的值.根据

现在,您的循环中出现了从0到9开始的10个堆叠直方图.它们都是一样的,因为 a 值没有任何作用.在实际工作中,您将看到每次训练后张量的直方图.

关于您的图像,我认为它们使输出平滑,这就是为什么您看到这种结果的原因.

I am learning to visualize tensor via tensorboard, however, I don't know how to interpret chart in Histogram tab. I used below code to visualize:

sess = tf.Session()
tf.summary.histogram('test', tf.constant([1, 1, 2, 2, 3, 4, 4, 4, 4]))
summary = tf.summary.merge_all()

train_writer = tf.summary.FileWriter('../tmp/train', sess.graph)
for i in range(10):
    sum = sess.run(summary)
    train_writer.add_summary(sum, i)

I got this chart from tensorboard:

Histogram mode: offset

Histogram mode: overlay

I know the x-axis is the value, y-axis is time step, what I don't know is the value of z-axis. According to this issue,

It's a normalized density. I wouldn't describe it as a probability density, although I think calling it one would be justifiable.

Can anyone explain more (i.e. how the density is calculated)?

解决方案

The plot here shows approximately what it should have shown. Spikes at the values 1, 2, 3, 4. The biggest spike is at the value 4, the smallest at 3. You see such a strange results because you selected to see the distribution of the output which is hard to visualize as a distribution (the same way as it would not be impressive to look at the circle in 3-d program).

Plot the actual distribution and it will be easier to understand. Here is an example:

import tensorflow as tf
import numpy as np

v = np.random.normal(loc=5,  scale=3.0, size=100000)
a = tf.constant(v)
s = tf.summary.histogram('normal', a)

merged = tf.summary.merge_all()
with tf.Session() as sess:
    writer = tf.summary.FileWriter('logs', sess.graph)
    for i in xrange(10):
        summary = sess.run(merged)
        writer.add_summary(summary, i)

    writer.close()

Here you see the normal distribution with mean 5 and std=3.

Now 10 stacked histograms starting from 0 to 9 are coming from your loop. They are all the same because there is nothing going on with the value a. In real work you will see the histogram of your tensors that evolve after each time of the training.

Regarding your image, I assume they smoothen the output and this is why you see such results.

这篇关于Tensorboard v1.0-直方图选项卡解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆