[docs]@runtime_checkableclassStateful(Protocol):""" Stateful protocol for objects that can be checkpointed and restored. """
[docs]defstate_dict(self)->Dict[str,Any]:""" Objects should return their state_dict representation as a dictionary. The output of this function will be checkpointed, and later restored in `load_state_dict()`. .. warning:: Because of the inplace nature of restoring a checkpoint, this function is also called during `torch.distributed.checkpoint.load`. Returns: Dict: The objects state dict """...
[docs]defload_state_dict(self,state_dict:Dict[str,Any])->None:""" Restore the object's state from the provided state_dict. Args: state_dict: The state dict to restore from """...
StatefulT=TypeVar("StatefulT",bound=Stateful)
Docs
Access comprehensive developer documentation for PyTorch
To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.