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

Method _run_batch

distributed/ddp-tutorial-series/single_gpu.py:22–27  ·  view source on GitHub ↗
(self, source, targets)

Source from the content-addressed store, hash-verified

20 self.save_every = save_every
21
22 def _run_batch(self, source, targets):
23 self.optimizer.zero_grad()
24 output = self.model(source)
25 loss = F.cross_entropy(output, targets)
26 loss.backward()
27 self.optimizer.step()
28
29 def _run_epoch(self, epoch):
30 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