Copy current averaged parameters into given collection of parameters. Args: parameters: Iterable of `torch.nn.Parameter`; the parameters to be updated with the stored moving averages. If `None`, the parameters with which this `Exponential
(self, parameters: Iterable[torch.nn.Parameter])
| 467 | s_param.copy_(param) |
| 468 | |
| 469 | def copy_to(self, parameters: Iterable[torch.nn.Parameter]) -> None: |
| 470 | """ |
| 471 | Copy current averaged parameters into given collection of parameters. |
| 472 | |
| 473 | Args: |
| 474 | parameters: Iterable of `torch.nn.Parameter`; the parameters to be |
| 475 | updated with the stored moving averages. If `None`, the parameters with which this |
| 476 | `ExponentialMovingAverage` was initialized will be used. |
| 477 | """ |
| 478 | parameters = list(parameters) |
| 479 | if self.foreach: |
| 480 | torch._foreach_copy_( |
| 481 | [param.data for param in parameters], |
| 482 | [s_param.to(param.device).data for s_param, param in zip(self.shadow_params, parameters)], |
| 483 | ) |
| 484 | else: |
| 485 | for s_param, param in zip(self.shadow_params, parameters): |
| 486 | param.data.copy_(s_param.to(param.device).data) |
| 487 | |
| 488 | def pin_memory(self) -> None: |
| 489 | r""" |