MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / training_step

Method training_step

sat/sgm/models/autoencoder.py:280–293  ·  view source on GitHub ↗
(self, batch: dict, batch_idx: int)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 3

inner_training_stepMethod · 0.95
zero_gradMethod · 0.80
stepMethod · 0.45

Tested by

no test coverage detected