torch.optim.Optimizer.register_load_state_dict_post_hook¶
- Optimizer.register_load_state_dict_post_hook(hook, prepend=False)[source][source]¶
- Register a load_state_dict post-hook which will be called after - load_state_dict()is called. It should have the following signature:- hook(optimizer) -> None - The - optimizerargument is the optimizer instance being used.- The hook will be called with argument - selfafter calling- load_state_dicton- self. The registered hook can be used to perform post-processing after- load_state_dicthas loaded the- state_dict.- Parameters
- hook (Callable) – The user defined hook to be registered. 
- prepend (bool) – If True, the provided post - hookwill be fired before all the already registered post-hooks on- load_state_dict. Otherwise, the provided- hookwill be fired after all the already registered post-hooks. (default: False)
 
- Returns
- a handle that can be used to remove the added hook by calling - handle.remove()
- Return type
- torch.utils.hooks.RemoveableHandle