I am a beginner and I am trying to create a new model using the layers of the pretrained network AlexNet. I would like to remove the avgpool layer, Add normalization layers in between the convolutional layers and add addtional fully connected layer to “classifier” part.
class MyAlexNet(nn.Module):
def __init__(self, my_pretrained_model):
super(MyAlexNet, self).__init__()
self.conv = my_pretrained_model.features
self.my_new_layers = nn.Sequential(nn.Linear(1000, 100),
nn.ReLU(),
nn.Linear(100, 6))
def forward(self, x):
x = self.pretrained(x)
x = self.my_new_layers(x)
return x
pretrained = models.alexnet(pretrained=use_pretrained)
model_ft= MyAlexNet(pretrained)
I suppose I have to use a structure as above but I do not how and if it is possible to add the before cited layers