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

Method __init__

distributed/ddp-tutorial-series/single_gpu.py:8–20  ·  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

6
7class Trainer:
8 def __init__(
9 self,
10 model: torch.nn.Module,
11 train_data: DataLoader,
12 optimizer: torch.optim.Optimizer,
13 gpu_id: int,
14 save_every: int,
15 ) -> None:
16 self.gpu_id = gpu_id
17 self.model = model.to(gpu_id)
18 self.train_data = train_data
19 self.optimizer = optimizer
20 self.save_every = save_every
21
22 def _run_batch(self, source, targets):
23 self.optimizer.zero_grad()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected