Hi, I would like to use just the beginnig part of resnet, so I did the thing below:
feature_map_extractor = torch.hub.load('pytorch/vision:v0.10.0', 'resnet50', pretrained=True)
feature_map_extractor.layer1 = nn.Sequential()
feature_map_extractor.layer2 = nn.Sequential()
feature_map_extractor.layer3 = nn.Sequential()
feature_map_extractor.layer4 = nn.Sequential()
feature_map_extractor.fc = nn.Sequential()
feature_map_extractor.avgpool = nn.Sequential()
feature_map_extractor.maxpool = nn.Sequential()
and the model is like this as I expected:
ResNet(
(conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)
(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(relu): ReLU(inplace=True)
(maxpool): Sequential()
(layer1): Sequential()
(layer2): Sequential()
(layer3): Sequential()
(layer4): Sequential()
(avgpool): Sequential()
(fc): Sequential()
and I would like to get the things that has a shape like square cause my image has square shape and resnet applies conv2d. But I got the shape below:
image = torch.randn((1,3,256,256))
a = feature_map_extractor(image)
a.shape
torch.Size([1, 1048576])
Why is that ?