I am a little bit confused about the connection between the model and its optimizer. I am initializing the optimizer with the model’s parameters, e.g.:
optimizer = Adam(task_model.parameters(), lr=0.003)
When performing the optimizer step, how does the optimizer know which model to update?
I always was of the opinion that through initialization, the optimizer is somehow connected to the model. S.t. when performing an optimizer step, it will update the model’s parameter, meaning when checking the values of the model’s parameters (list(model.parameters()))
, the values should be different before and after performing the backward pass and optimizer step.
Is this correct? This also means that an optimizer is always tied to a specific model, correct?