MCPcopy Create free account
hub / github.com/pytorch/pytorch / train

Method train

test/jit/test_models.py:264–274  ·  view source on GitHub ↗
(iters)

Source from the content-addressed store, hash-verified

262 check_trace=False)
263
264 def train(iters):
265 for _ in range(iters):
266 # Get some fake data
267 inp = torch.randn(5, 1, 28, 28, device='cuda')
268 out = traced_net(inp)
269
270 # Here's some fake loss
271 out.sum().backward()
272
273 # Zero out grads
274 traced_net.zero_grad()
275
276 # Set it up so the params have .grad fields so they are not reported as leaks
277 train(1)

Callers 15

test_forwardMethod · 0.45
test_factory_kwargsMethod · 0.45
test_reprMethod · 0.45
test_pickleMethod · 0.45
test_check_inplaceMethod · 0.45
test_cpu_gpu_parityMethod · 0.45
test_memory_formatMethod · 0.45

Calls 5

rangeFunction · 0.50
randnMethod · 0.45
backwardMethod · 0.45
sumMethod · 0.45
zero_gradMethod · 0.45

Tested by

no test coverage detected