I use VGG19 for train model but I’m curious that I should use which one and what is different
- model.features.eval()
- for param in model.features.parameters():
param.requires_grad = False - with torch.no_grad():
example
# fix the weight of convolution layers
model.features.eval()
# modify classifier
model.classifier = torch.nn.Sequential(
nn.Linear(25088, 4096),
nn.ReLU(inplace=True),
nn.Dropout(p=0.5, inplace=False),
nn.Linear(4096, 4096),
nn.ReLU(inplace=True),
nn.Dropout(p=0.5, inplace=False),
torch.nn.Linear(4096, 2))