(self, batch: dict, batch_idx: int)
| 278 | raise NotImplementedError(f"Unknown optimizer {optimizer_idx}") |
| 279 | |
| 280 | def training_step(self, batch: dict, batch_idx: int): |
| 281 | opts = self.optimizers() |
| 282 | if not isinstance(opts, list): |
| 283 | # Non-adversarial case |
| 284 | opts = [opts] |
| 285 | optimizer_idx = batch_idx % len(opts) |
| 286 | if self.global_step < self.disc_start_iter: |
| 287 | optimizer_idx = 0 |
| 288 | opt = opts[optimizer_idx] |
| 289 | opt.zero_grad() |
| 290 | with opt.toggle_model(): |
| 291 | loss = self.inner_training_step(batch, batch_idx, optimizer_idx=optimizer_idx) |
| 292 | self.manual_backward(loss) |
| 293 | opt.step() |
| 294 | |
| 295 | def validation_step(self, batch: dict, batch_idx: int) -> Dict: |
| 296 | log_dict = self._validation_step(batch, batch_idx) |
nothing calls this directly
no test coverage detected