utkuozbulak / pytorch-cnn-visualizations

Pytorch implementation of convolutional neural network visualization techniques
MIT License
7.78k stars 1.49k forks source link

Wrong dimension for the first layer visualization #52

Closed zhangyu2ustc closed 4 years ago

zhangyu2ustc commented 4 years ago

Hi, I was using the guided backpropagation to visualize my own pretrained models and found out the resultant gradient maps did not have the same dimension as the input image, but the ouput shape of the first layer. For instance, I have the input of [batch, 1000, 17] and the ouput of the first layer is [batch,1000,32] Then, the gradient maps has the shape of [1000,32] with the elements from 17~32 as non zeros.

I have also tried to print the shape of the gradient in the hook function, which is also [batch, 1000, 32] Can you help me to figure out what went wrong?

Thank you very much. Best, Yu.

utkuozbulak commented 4 years ago

The example code here does not use any batch. You should modify the code to enable batches.