Hey!
A quick question regarding the code snippet below from the PyTorch Autograd Mechanics Tutorial:
model = torchvision.models.resnet18(pretrained=True)
for param in model.parameters():
    param.requires_grad = False
# Replace the last fully-connected layer
# Parameters of newly constructed modules have requires_grad=True by default
model.fc = nn.Linear(512, 100)

# Optimize only the classifier
optimizer = optim.SGD(model.fc.parameters(), lr=1e-2, momentum=0.9)

What would be the difference if I were to just pass in the entire model’s parameters? E.g.:
optimizer = optim.SGD(model.parameters(), lr=1e-2, momentum=0.9)

instead of
optimizer = optim.SGD(model.fc.parameters(), lr=1e-2, momentum=0.9)

I am a bit confused why this would matter, since we are setting requires_grad=False to every parameter of the model, besides the model.fc layer (because this layer is created as a new module, which has requires_grad=True by default.
Thanks and I apologize if this has been asked already,
Epoching