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

Method __init__

distributed/ddp-tutorial-series/multigpu.py:25–38  ·  view source on GitHub ↗
(
        self,
        model: torch.nn.Module,
        train_data: DataLoader,
        optimizer: torch.optim.Optimizer,
        gpu_id: int,
        save_every: int,
    )

Source from the content-addressed store, hash-verified

23
24class Trainer:
25 def __init__(
26 self,
27 model: torch.nn.Module,
28 train_data: DataLoader,
29 optimizer: torch.optim.Optimizer,
30 gpu_id: int,
31 save_every: int,
32 ) -> None:
33 self.gpu_id = gpu_id
34 self.model = model.to(gpu_id)
35 self.train_data = train_data
36 self.optimizer = optimizer
37 self.save_every = save_every
38 self.model = DDP(model, device_ids=[gpu_id])
39
40 def _run_batch(self, source, targets):
41 self.optimizer.zero_grad()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected