How to visualize feature map in Tensorboard?

I'm using tensorflow 1.13 and want to know how I can show my feature maps on tensorboard. I want to visualize middel layers' output feature maps of my network.

tensorflowtensorboardvisualize
3 votesJW229.00
1 Answers
NN132.00
3

There is a summary type for tensorboard to visualize images. You just need to use that function for your layer.

layer = tf.get_default_graph().get_tensor_by_name('tensor_layer:0')
# image can visualize 1, 3 and 4 channel images
tf.summary.image('layer output', layer[:, :, :, 0:3], max_output=3)

This means, in your tensorboard you will see 3 images from 0 to 3 channels. The tensor should be 4th dimensional with the shape of [batch, width, height, channels]. Or if you want to plot every channel then you can use this

layer = tf.get_default_graph().get_tensor_by_name('tensor_layer:0')
# image can visualize 1, 3 and 4 channel images
tf.summary.image('layer output channel_0', tf.expand_dims(layer[:, :, :, 0], axis=3), max_output=3)
tf.summary.image('layer output channel_1', tf.expand_dims(layer[:, :, :, 1], axis=3), max_output=3)
tf.summary.image('layer output channel_2', tf.expand_dims(layer[:, :, :, 2], axis=3), max_output=3)
...

Take a look at the doc https://www.tensorflow.org/api_docs/python/tf/summary/image

Reply
Couldn't find what you were looking for?and we will find an expert to answer.
How helpful was this page?