r""" Returns the state of the ExponentialMovingAverage as a dict. This method is used by accelerate during checkpointing to save the ema state dict.
(self)
| 508 | ] |
| 509 | |
| 510 | def state_dict(self) -> dict: |
| 511 | r""" |
| 512 | Returns the state of the ExponentialMovingAverage as a dict. This method is used by accelerate during |
| 513 | checkpointing to save the ema state dict. |
| 514 | """ |
| 515 | # Following PyTorch conventions, references to tensors are returned: |
| 516 | # "returns a reference to the state and not its copy!" - |
| 517 | # https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict |
| 518 | return { |
| 519 | "decay": self.decay, |
| 520 | "min_decay": self.min_decay, |
| 521 | "optimization_step": self.optimization_step, |
| 522 | "update_after_step": self.update_after_step, |
| 523 | "use_ema_warmup": self.use_ema_warmup, |
| 524 | "inv_gamma": self.inv_gamma, |
| 525 | "power": self.power, |
| 526 | "shadow_params": self.shadow_params, |
| 527 | } |
| 528 | |
| 529 | def store(self, parameters: Iterable[torch.nn.Parameter]) -> None: |
| 530 | r""" |
no outgoing calls