How optimizer changes weights

take look at my code:


how does optimizer changes net parameters? it is passed once and then they don’t have any there any pointer stuff there?or i missed something while learning pytorch\python.

The optimizer will use the references to all passed parameters and update them in the step function.
You could check the id of each parameter in e.g. optimizer.param_groups[0]['params'] and will see that the ids match the parameter ids in the model.

1 Like