I want to get the feature maps of each input image from each layer after an activation function. The underlying model is ResNet50 (pytorch-cifar100/resnet.py at master · weiaicunzai/pytorch-cifar100 · GitHub)
In contrast, the VGG Net (pytorch-cifar100/vgg.py at master · weiaicunzai/pytorch-cifar100 · GitHub) has a
self.features variable where the feature map extraction is easy.
I cannot use this
self.features variable, because I also need to extract features within the
nn.Sequential block, which is not possible with
self.features on my point of view.
After googling, I have two possibilities:
- Iterating through the graph by using
model.children()as here Use Pytorch and Matplotlib to visualize the features of convolutional neural networks - Programmer Sought
Can someone tell me, what is the best way to the get the feature maps of a ResNet50? I need these features for further computations.