5

In the conv-nets model, I know how to visualize the filters, we can do itorch.image(model:get(1).weight)

But how could I efficiently visualize the output images after the convolution? especially those images in the second or third layer in a deep neural network?

Thanks.

James LT
  • 733
  • 2
  • 12
  • 23
  • The second answer is more appropriate, please re select the answer so it would be easier for people who find the better and correct answer – Anuj Dec 31 '16 at 07:26

2 Answers2

13

Similarly to weight, you can use:

itorch.image(model:get(1).output)
smhx
  • 2,246
  • 18
  • 22
5

To visualize the weights:

-- visualizing weights
n = nn.SpatialConvolution(1,64,16,16)
itorch.image(n.weight)

To visualize the feature maps:

-- initialize a simple conv layer
n = nn.SpatialConvolution(1,16,12,12)

-- push lena through net :)
res = n:forward(image.rgb2y(image.lena())) 

-- res here is a 16x501x501 volume. We view it now as 16 separate sheets of size 1x501x501 using the :view function
res = res:view(res:size(1), 1, res:size(2), res:size(3))
itorch.image(res)

For more: https://github.com/torch/tutorials/blob/master/1_get_started.ipynb

anh_ng8
  • 1,100
  • 10
  • 16