MCPcopy Create free account
hub / github.com/pytorch/examples / _run_batch

Method _run_batch

distributed/ddp-tutorial-series/multigpu.py:40–45  ·  view source on GitHub ↗
(self, source, targets)

Source from the content-addressed store, hash-verified

38 self.model = DDP(model, device_ids=[gpu_id])
39
40 def _run_batch(self, source, targets):
41 self.optimizer.zero_grad()
42 output = self.model(source)
43 loss = F.cross_entropy(output, targets)
44 loss.backward()
45 self.optimizer.step()
46
47 def _run_epoch(self, epoch):
48 b_sz = len(next(iter(self.train_data))[0])

Callers 1

_run_epochMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected