torch.optim.Optimizer.load_state_dict¶
- Optimizer.load_state_dict(state_dict)[source][source]¶
Load the optimizer state.
- Parameters
state_dict (dict) – optimizer state. Should be an object returned from a call to
state_dict()
.
Note
The names of the parameters (if they exist under the “param_names” key of each param group in
state_dict()
) will not affect the loading process. To use the parameters’ names for custom cases (such as when the parameters in the loaded state dict differ from those initialized in the optimizer), a customregister_load_state_dict_pre_hook
should be implemented to adapt the loaded dict accordingly. Ifparam_names
exist in loaded state dictparam_groups
they will be saved and override the current names, if present, in the optimizer state. If they do not exist in loaded state dict, the optimizerparam_names
will remain unchanged.