I am new to pytorch and doing style transfer. I want to have the features of vgg fc1 layer (1x1x4096 weights). I can get features of convolution layer easily by recreating the model structure (from pytorch tutorial):
"""Select conv1_1 ~ conv5_1 activation maps."""
self.select = ['0', '5', '10', '19', '28']
self.vgg = models.vgg19(pretrained=True).features
def forward(self, x):
"""Extract 5 conv activation maps from an input image.
x: 4D tensor of shape (1, 3, height, width).
features: a list containing 5 conv activation maps.
features = 
for name, layer in self.vgg._modules.items():
x = layer(x)
if name in self.select:
I found the fc layers are only in classifier. I can do something like
new_classifer=nn.Sequential(*list(model.classifier.children())[:-6]) according to this post
But how do I get the features of vgg fc1 layer? Thank you in advance!