Visualize Intermediate activations for VGG16

Hello, I’m doing a work to classify some problems of conveyor belt structures using images.
For now, I’m trying to identify the accumulation of dirt on the structutres just with RGB images. I’m training a network using transfer learning from vgg16. My dataset is short, yet. But I’m applying the data augmentation.

I would like to see what my network is recognizing, but I don’t know how to visualize the intermediate activitions of my network and create images from them. Is there some method of pytorch to do that or I have to create a new code from scratch?

they are called hookers, https://pytorch.org/tutorials/beginner/former_torchies/nn_tutorial.html#forward-and-backward-function-hooks

Here is another thread about extracting intermediate layer feature.

Thanks!

I was not able to use the hookers, I did something wrong… But I tried to create a new network based on the values from my trained model and it worked. I created a new network from layer one to the layer I desired. Then I got the output and plot the image with plt.imshow().

I can see the images, but it’s gonna be almost impossible analyze all the layers and the resolution of the image is small because the vgg16 original model.

Just another question: the plot with imshow is the best option to plot something like that?