      for batch in data_iter:
          features, labels, _ = _get_batch(batch, ctx)
          for X, y in zip(features, labels):
              y = y.astype('float32')
              acc += (net(X).argmax(axis=1) == y).sum().copyto(mx.cpu())
              n += y.size
          acc.wait_to_read()
      return acc.asscalar() / n
  
  
 
</s> remove         acc.wait_to_read()
    return acc.asscalar() / n
 </s> add         acc_sum.wait_to_read()
    return acc_sum.asscalar() / n </s> remove     acc = nd.array([0])
    n = 0
 </s> add     acc_sum, n = nd.array([0]), 0 </s> remove             train_l_sum += sum([l.sum().asscalar() for l in ls])
            trainer.step(batch_size)
            n += batch_size
 </s> add  </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
            acc_sum += (net(X).argmax(axis=1) == y).sum().copyto(mx.cpu())
      for batch in data_iter:
          features, labels, _ = _get_batch(batch, ctx)
          for X, y in zip(features, labels):
              y = y.astype('float32')
            acc_sum += (net(X).argmax(axis=1) == y).sum().copyto(mx.cpu())
              n += y.size
          acc.wait_to_read()
      return acc.asscalar() / n
  
  
keep keep keep keep replace keep keep keep keep keep
 gb 0.8.9, fix acc, loss computations 
gluonbook/utils.py