Restore the parameters stored with the `store` method. Useful to validate the model with EMA parameters without affecting the original optimization process. Store the parameters before the `copy_to` method. After validation (or model saving), use this to rest
(self, parameters)
| 66 | self.collected_params = [param.clone() for param in parameters] |
| 67 | |
| 68 | def restore(self, parameters): |
| 69 | """ |
| 70 | Restore the parameters stored with the `store` method. |
| 71 | Useful to validate the model with EMA parameters without affecting the |
| 72 | original optimization process. Store the parameters before the |
| 73 | `copy_to` method. After validation (or model saving), use this to |
| 74 | restore the former parameters. |
| 75 | Args: |
| 76 | parameters: Iterable of `torch.nn.Parameter`; the parameters to be |
| 77 | updated with the stored parameters. |
| 78 | """ |
| 79 | for c_param, param in zip(self.collected_params, parameters): |
| 80 | param.data.copy_(c_param.data) |