              train_l_sum += l.mean().asscalar()
              train_acc_sum += accuracy(y_hat, y)
          test_acc = evaluate_accuracy(test_iter, net)
          print('epoch %d, loss %.4f, train acc %.3f, test acc %.3f'
                % (epoch, train_l_sum / len(train_iter),
                   train_acc_sum / len(train_iter), test_acc))
  
  
  def train_ch5(net, train_iter, test_iter, batch_size, trainer, ctx,
                num_epochs):
      """Train and evaluate a model on CPU or GPU."""
 
</s> remove     """Train and evaluate a model on CPU or GPU."""
 </s> add     """Train and evaluate a model with CPU or GPU.""" </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 </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 </s> remove               % (epoch, train_l_sum / len(train_iter),
                 train_acc_sum / len(train_iter), test_acc, time.time() - start))
 </s> add               % (epoch + 1, train_l_sum / n, train_acc_sum / n, test_acc,
                 time.time() - start)) </s> remove               % (epoch, train_l_sum / n, train_acc_sum / m, test_acc,
 </s> add               % (epoch + 1, train_l_sum / n, train_acc_sum / m, test_acc,
              % (epoch + 1, train_l_sum / n, train_acc_sum / n, test_acc))
              train_l_sum += l.mean().asscalar()
              train_acc_sum += accuracy(y_hat, y)
          test_acc = evaluate_accuracy(test_iter, net)
          print('epoch %d, loss %.4f, train acc %.3f, test acc %.3f'
              % (epoch + 1, train_l_sum / n, train_acc_sum / n, test_acc))
              % (epoch + 1, train_l_sum / n, train_acc_sum / n, test_acc))
  
  
  def train_ch5(net, train_iter, test_iter, batch_size, trainer, ctx,
                num_epochs):
      """Train and evaluate a model on CPU or GPU."""
keep keep keep keep replace replace keep keep keep keep keep
 gb 0.8.9, fix acc, loss computations 
gluonbook/utils.py