  def evaluate_accuracy(data_iterator, net, ctx=[mx.cpu()]):
      if isinstance(ctx, mx.Context):
          ctx = [ctx]
      acc = nd.array([0])
      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):
              y = y.astype('float32')
              acc += nd.sum(net(X).argmax(axis=1)==y).copyto(mx.cpu())
              n += y.size
          acc.wait_to_read() # don't push too many operators into backend
      return acc.asscalar() / n
 
</s> remove             acc += nd.sum(net(X).argmax(axis=1)==y).copyto(mx.cpu())
 </s> add             acc += (net(X).argmax(axis=1)==y).sum().copyto(mx.cpu()) </s> remove         acc.wait_to_read() # don't push too many operators into backend
 </s> add         acc.wait_to_read()  </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.""" </s> remove     return nd.mean(output.argmax(axis=1)==label).asscalar()

 </s> add     """Get accuracy."""
    return (output.argmax(axis=1) == label).mean().asscalar()
    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):
  def evaluate_accuracy(data_iterator, net, ctx=[mx.cpu()]):
      if isinstance(ctx, mx.Context):
          ctx = [ctx]
      acc = nd.array([0])
    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):
    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):
    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):
    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):
    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):
    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):
              y = y.astype('float32')
              acc += nd.sum(net(X).argmax(axis=1)==y).copyto(mx.cpu())
              n += y.size
          acc.wait_to_read() # don't push too many operators into backend
      return acc.asscalar() / n
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep
 apply gluonbook in dl basics, cnn, remove gluonbook deps 
gluonbook/utils.py