Tuturial pytorch_with_examples, parameters passed to torch.optim

Hi, I am going through the beginners examples, and on the part of PyTorch: optim, it is not clear to me why the optimisation package receives all model parameters (including the Tensors that describe the states of the layers) instead of only the Tensors that describe the weights. Maybe I am missing a more fundamental concept, but it was my understanding that we just wanted to updated the weights.

optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate)

Thank you!

model.parameters() will return all registered nn.Parameters not the arguments to layers.
You can check it via:

print(list(model.parameters()))
# or
print(dict(model.named_parameters()))