model_resnet = models.resnet18(pretrained=True)
if model is not None:
self.resnet_layer =  nn.Sequential(*list(model.children())[:-1])
self.num_ftrs = self.model.fc.in_features
self.fc = nn.Linear(self.num_ftrs, 10)
Above is a part of my code, I wanna use pretrained resnet to train a new model by changing its last fully connected layer. During the training process, I don’t want any weight from resnet except the last fc layer change, I want to know, if I add a command like model.train() before the training process, will all the weights in the resnet be set requires_grad to True?