-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
Line 489 in d6ed035
| return correct/(y.shape[0]*niter), total_loss/(y.shape[0]*niter) |
for batch in dataloader:
opt.reset_grad()
X, y = batch
X,y = ndl.Tensor(X, device=device), ndl.Tensor(y, device=device)
out = model(X)
correct += np.sum(np.argmax(out.numpy(), axis=1) == y.numpy())
loss = loss_fn(out, y)
total_loss += loss.data.numpy() * y.shape[0]
loss.backward()
opt.step()
if i >= niter:
break
i += 1
return correct/(y.shape[0]*niter), total_loss/(y.shape[0]*niter)correct/(y.shape[0]*niter), total_loss/(y.shape[0]*niter) only correct if the size of the last batch is equal to the others. It's maybe not true for all dataset.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels