(self, context=None)
| 175 | |
| 176 | @contextmanager |
| 177 | def ema_scope(self, context=None): |
| 178 | if self.use_ema: |
| 179 | self.model_ema.store(self.model.parameters()) |
| 180 | self.model_ema.copy_to(self.model) |
| 181 | if context is not None: |
| 182 | print(f"{context}: Switched to EMA weights") |
| 183 | try: |
| 184 | yield None |
| 185 | finally: |
| 186 | if self.use_ema: |
| 187 | self.model_ema.restore(self.model.parameters()) |
| 188 | if context is not None: |
| 189 | print(f"{context}: Restored training weights") |
| 190 | |
| 191 | def instantiate_optimizer_from_config(self, params, lr, cfg): |
| 192 | return get_obj_from_str(cfg["target"])( |
no test coverage detected