Visualize Convolutional layer of Alexnet

Hello All,
I am newbie into this field. I was trying to visualize the feature map/activation map of Alexnet.
I am working on cifar-10 dataset and was trying to visualize the kernels and feature map.

AlexNet(
(features): Sequential(
(0): Conv2d(3, 64, kernel_size=(11, 11), stride=(4, 4), padding=(2, 2))
(1): ReLU(inplace)
(2): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)
(3): Conv2d(64, 192, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2))
(4): ReLU(inplace)
(5): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)
(6): Conv2d(192, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(7): ReLU(inplace)
(8): Conv2d(384, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(9): ReLU(inplace)
(10): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
(11): ReLU(inplace)
(12): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)
)
(avgpool): AdaptiveAvgPool2d(output_size=(6, 6))
(classifier): Sequential(
(0): Dropout(p=0.5)
(1): Linear(in_features=9216, out_features=4096, bias=True)
(2): ReLU(inplace)
(3): Dropout(p=0.5)
(4): Linear(in_features=4096, out_features=2048, bias=True)
(5): ReLU(inplace)
(6): Linear(in_features=2048, out_features=1024, bias=True)
(7): ReLU(inplace)
(8): Linear(in_features=1024, out_features=10, bias=True)
)
)

I have few questions on visualization.

  1. How do I visualize feature map of Alexnet?
  2. Is there any supporting code for visualizing the convolutional layers of Alexnet?

Thanks in advance…

You could use forward hooks to get the activation maps and visualize them as described here. The topic also includes another post to visualize kernels.