今天学习tensorboard中直方图的使用。首先了解下直方图的含义:
GB/T3358.1—2009对“直方图”的定义是:频数分布的一种图形表示,由一些相邻的长方形组成,每个长方形的底宽等于组距,面积与组的频数成比例。
也就是说,直方图是表示频次分布情况的一种图像,在tensorboard中,用直方图显示张量,主要就是显示张量中每个值的出现频次。
一、代码添加
首先在层的应用函数中加入数据采集代码。
def get_output(self, inputs, is_training=True):
with tf.name_scope('%s_cal' % (self.name)) as scope:
# hidden states
self.hidden = self.conv(inputs=inputs)
tf.summary.histogram('histogram', self.conv.weights)
#self.variable_summaries(self.conv.weights)
# batch normalization 技术
if self.batch_normal:
self.hidden = self.bn(self.hidden, training=is_training)
# activation
if self.activation == 'relu':
self.output = tf.nn.relu(self.hidden)
elif self.activation == 'tanh':