Which parameters will the optimizer actually update?
model = torchvision.models.resnet18(weights="DEFAULT")
for p in model.parameters():
p.requires_grad = False
model.fc = nn.Linear(512, 3)
- Only the new fc layer
- Every layer in the net
- Only the first conv layer
- No parameters at all
The backbone is frozen, and the freshly created fc layer has requires_grad=True by default.
Play AI & ML ▸