          train_acc_sum = 0
          for X, y in train_iter:
              with autograd.record():
                  y_hat = net(X)
                  l = loss(y_hat, y)
              l.backward()
              if trainer is None:
                  sgd(params, lr, batch_size)
              else:
                  trainer.step(batch_size)
 
</s> remove                 sgd(params, lr, batch_size)
 </s> add                 gb.sgd(params, lr, batch_size) </s> remove                 l = loss(y_hat, y)
 </s> add                 l = loss(y_hat, y).sum() </s> remove     """Train and evaluate a model on CPU."""
    for epoch in range(1, num_epochs + 1):
        train_l_sum = 0
        train_acc_sum = 0
 </s> add     """Train and evaluate a model with CPU."""
    for epoch in range(num_epochs):
        train_l_sum, train_acc_sum, n = 0.0, 0.0, 0 </s> remove     for epoch in range(1, num_epochs + 1):
        train_l_sum = 0
        train_acc_sum = 0
        start = time.time()
 </s> add     for epoch in range(num_epochs):
        train_l_sum, train_acc_sum, n, start = 0.0, 0.0, 0, time.time() </s> remove             train_l_sum += l.mean().asscalar()
            train_acc_sum += accuracy(y_hat, y)
 </s> add             y = y.astype('float32')
            train_l_sum += l.asscalar()
            train_acc_sum += (y_hat.argmax(axis=1) == y).sum().asscalar()
            n += y.size
                l = loss(y_hat, y).sum()
          train_acc_sum = 0
          for X, y in train_iter:
              with autograd.record():
                  y_hat = net(X)
                l = loss(y_hat, y).sum()
              l.backward()
              if trainer is None:
                  sgd(params, lr, batch_size)
              else:
                  trainer.step(batch_size)
keep keep keep keep replace keep keep keep keep keep
 gb 0.8.9, fix acc, loss computations 
gluonbook/utils.py