(self, context=None)
| 96 | |
| 97 | @contextmanager |
| 98 | def ema_scope(self, context=None): |
| 99 | if self.use_ema: |
| 100 | self.model_ema.store(self.parameters()) |
| 101 | self.model_ema.copy_to(self) |
| 102 | if context is not None: |
| 103 | logpy.info(f"{context}: Switched to EMA weights") |
| 104 | try: |
| 105 | yield None |
| 106 | finally: |
| 107 | if self.use_ema: |
| 108 | self.model_ema.restore(self.parameters()) |
| 109 | if context is not None: |
| 110 | logpy.info(f"{context}: Restored training weights") |
| 111 | |
| 112 | @abstractmethod |
| 113 | def encode(self, *args, **kwargs) -> torch.Tensor: |
no test coverage detected