Thanks for your answer. The context around this is I’m serializing the model and optimizer and deserializing in another context where I don’t know the architecture of model and the initial call to SGD’s constructor
Since I’m already saving model.state_dict() entirely, it seems that I do not need to save optimizer.state_dict(), but only the param_groups.
For example, when there is only one param_group, SGD([*model.parameters()],**opt.state_dict()['param_groups'][0]) reconstructs the inital optimizer nicely, and I am trying to generalize this to more than one param_groups.
A Sequential model does not have a layer attribute, but not sure what you meant even after trying different calls. but yes, I would need a function that takes an id of a parameter that I would call. Then I would be able to call the optimizer’s constructor in the same way as I initially do, with a list of dictionaries.