我想在Tensorflow中创建一个histogram2d。如下所示:

最好是在Tensorboard中,但如果有一个没有tensorboard的简单解决方案就可以了。
Tensorboard似乎只绘制了一维直方图/分布。我有一个使用np.histogram2d和图像的解决方案,我将添加它们作为答案,但它远非理想,因为我不能显示轴或观察量化值。
发布于 2017-11-01 23:12:37
我的解决方案包括使用numpy的np.histogram2d,使用tf.py_func将其嵌入到tensorflow中,然后使用tf.summary_image将“height”绘制为图像中的grey_scale。
def _histogram_2d(a,b):
"""
takes two tensors of the same shape and computes the 2d histogram of their pairs
"""
ar = a.reshape(-1)
br = b.reshape(-1)
aux = np.histogram2d(ar, br)
return aux[0].astype(np.float32), aux[1].astype(np.float32), aux[2].astype(np.float32)
[H, xedges, yedges] = tf.py_func(_histogram_2d, [a, b], [tf.float32, tf.float32, tf.float32])
tf.summary.image('/2d_hist', tf.expand_dims(tf.expand_dims(H,0),-1))你会得到类似这样的结果:

它可以完成这项工作,但也可能有更好的方法。
https://stackoverflow.com/questions/47058011
复制相似问题