def numpy_size(msg, m):
  """Size in bytes of a numpy object.

  Only works for a couple of numpy types.

  Args:
    msg: A string used in error messages.
    m: numpy array or scipy COO or CSR matrix.

  Returns:
    size in bytes
  """
  if isinstance(m, scipy.sparse.coo.coo_matrix):
    # assumes data, i, j all have 32 bits/4 bytes
    size = m.data.shape[0] * 3 * 4
  elif isinstance(m, np.ndarray):
    size = m.shape[0] * m.shape[1] * 4
  elif isinstance(m, scipy.sparse.csr_matrix):
    size += numpy_size(msg, m.indices) + numpy_size(msg, m.values)
  else:
    tf.logging.warn('uncounted object %s of type %r' % (msg, type(m)))
    size = 0
  return size
Size in bytes of a numpy object.

  Only works for a couple of numpy types.

  Args:
    msg: A string used in error messages.
    m: numpy array or scipy COO or CSR matrix.

  Returns:
    size in bytes
  
language/nql/demos/gridworld_scaling/scaling_eval.py