$ ./guess_the_languageAI & ML
AI & ML · medium · #52

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)
  1. Only the new fc layer
  2. Every layer in the net
  3. Only the first conv layer
  4. No parameters at all
The backbone is frozen, and the freshly created fc layer has requires_grad=True by default.
Play AI & ML ▸