MCPcopy Index your code
hub / github.com/pytorch/tutorials / fit

Function fit

beginner_source/nn_tutorial.py:355–369  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

353# again later.
354
355def fit():
356 for epoch in range(epochs):
357 for i in range((n - 1) // bs + 1):
358 start_i = i * bs
359 end_i = start_i + bs
360 xb = x_train[start_i:end_i]
361 yb = y_train[start_i:end_i]
362 pred = model(xb)
363 loss = loss_func(pred, yb)
364
365 loss.backward()
366 with torch.no_grad():
367 for p in model.parameters():
368 p -= p.grad * lr
369 model.zero_grad()
370
371fit()
372

Callers 1

nn_tutorial.pyFile · 0.85

Calls 3

loss_batchFunction · 0.85
modelFunction · 0.70
backwardMethod · 0.45

Tested by

no test coverage detected