                  loss = square_loss(output, label)
              loss.backward()
              trainer.step(batch_size)
              if batch_i * batch_size % log_interval == 0:
                  y_vals.append(square_loss(net(X), y).mean().asnumpy())
      print('w:', net[0].weight.data(), '\nb:', net[0].bias.data(), '\n')
      x_vals = np.linspace(0, num_epochs, len(y_vals), endpoint=True)
      semilogy(x_vals, y_vals, 'epoch', 'loss')
  
  
 
</s> remove                 output = net(features)
                loss = square_loss(output, label)
            loss.backward()
 </s> add                 l = loss(net(X), y)
            l.backward() </s> remove     return nd.mean(output.argmax(axis=1)==label).asscalar()

 </s> add     """Get accuracy."""
    return (output.argmax(axis=1) == label).mean().asscalar() </s> remove     n = 0.
    if isinstance(data_iterator, mx.io.MXDataIter):
        data_iterator.reset()
    for batch in data_iterator:
        data, label, batch_size = _get_batch(batch, ctx)
        for X, y in zip(data, label):
 </s> add     n = 0
    if isinstance(data_iter, mx.io.MXDataIter):
        data_iter.reset()
    for batch in data_iter:
        features, labels, batch_size = _get_batch(batch, ctx)
        for X, y in zip(features, labels): </s> remove def evaluate_accuracy(data_iterator, net, ctx=[mx.cpu()]):
 </s> add def evaluate_accuracy_cpu(data_iter, net):
    """Evaluate accuracy of a model on the given data set on CPU."""
    acc = 0
    for X, y in data_iter:
        acc += accuracy(net(X), y)
    return acc / len(data_iter)


def evaluate_accuracy(data_iter, net, ctx=[mx.cpu()]):
    """Evaluate accuracy of a model on the given data set."""
                ls.append(loss(net(features), labels).mean().asnumpy())
    # To print more conveniently, use numpy.
                  loss = square_loss(output, label)
              loss.backward()
              trainer.step(batch_size)
              if batch_i * batch_size % log_interval == 0:
                ls.append(loss(net(features), labels).mean().asnumpy())
    # To print more conveniently, use numpy.
      print('w:', net[0].weight.data(), '\nb:', net[0].bias.data(), '\n')
      x_vals = np.linspace(0, num_epochs, len(y_vals), endpoint=True)
      semilogy(x_vals, y_vals, 'epoch', 'loss')
  
  
keep keep keep keep replace keep keep keep keep keep
 apply gluonbook in dl basics, cnn, remove gluonbook deps 
gluonbook/utils.py