title: MXNET - Invalid type '<type 'numpy.ndarray'>' for data, should be NDArray, numpy.ndarray,
body: <p>I am having trouble with basic IO with <code>mxnet</code>.  I am attempting to use  <code>mxnet.io.NDArrayIter</code> to read in-memory datasets for training in mxnet.  I have the below code (condensed for brevity) which preprocesses the code and attempt to iterate through it (heavily based on the <a href="https://mxnet.incubator.apache.org/tutorials/basic/data.html#reading-data-in-memory" rel="nofollow noreferrer">tutorial</a>):</p>
  
  <pre class="lang-python prettyprint-override"><code>import csv
  import mxnet as mx
  import numpy as np
  
  from sklearn.feature_extraction.text import CountVectorizer, TfidfTransformer
  from sklearn.pipeline import Pipeline
  
  
  with open('data.csv', 'r') as data_file:
      data = list(csv.reader(data_file))
  
  labels = np.array(map(lambda x: x[1], data)) # one-hot encoded classes
  data = map(lambda x: x[0], data) # raw text in need of pre-processing
  
  transformer = Pipeline(steps=(('count_vectorizer', CountVectorizer()),
                                ('tfidf_transformer', TfidfTransformer())))
  
  preprocessed_data = np.array([np.array(row) for row in transformer.fit_transform(data)])
  
  training_data = mx.io.NDArrayIter(data=preprocessed_data, label=labels, batch_size=50)
  
  for i, batch in enumerate(training_data):
      print(batch)
  </code></pre>
  
  <p>When executing this code, I receive the following error:</p>
  
  <pre><code>    Traceback (most recent call last):
    File "/usr/local/lib/python3.5/dist-packages/mxnet/io.py", line 510, in _init_data
      data[k] = array(v)
    File "/usr/local/lib/python3.5/dist-packages/mxnet/ndarray/utils.py", line 146, in array
      return _array(source_array, ctx=ctx, dtype=dtype)
    File "/usr/local/lib/python3.5/dist-packages/mxnet/ndarray/ndarray.py", line 2245, in array
      arr[:] = source_array
    File "/usr/local/lib/python3.5/dist-packages/mxnet/ndarray/ndarray.py", line 437, in __setitem__
      self._set_nd_basic_indexing(key, value)
    File "/usr/local/lib/python3.5/dist-packages/mxnet/ndarray/ndarray.py", line 698, in _set_nd_basic_indexing
      self._sync_copyfrom(value)
    File "/usr/local/lib/python3.5/dist-packages/mxnet/ndarray/ndarray.py", line 856, in _sync_copyfrom
      source_array = np.ascontiguousarray(source_array, dtype=self.dtype)
    File "/usr/local/lib/python3.5/dist-packages/numpy/core/numeric.py", line 581, in ascontiguousarray
      return array(a, dtype, copy=False, order='C', ndmin=1)
  TypeError: float() argument must be a string or a number, not 'csr_matrix'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "mxnet_test.py", line 20, in &lt;module&gt;
      training_data = mx.io.NDArrayIter(data=preprocessed_data, label=labels, batch_size=50)
    File "/usr/local/lib/python3.5/dist-packages/mxnet/io.py", line 643, in __init__
      self.data = _init_data(data, allow_empty=False, default_name=data_name)
    File "/usr/local/lib/python3.5/dist-packages/mxnet/io.py", line 513, in _init_data
      "should be NDArray, numpy.ndarray or h5py.Dataset")
  TypeError: Invalid type '&lt;class 'numpy.ndarray'&gt;' for data, should be NDArray, numpy.ndarray or h5py.Dataset
  </code></pre>
  
  <p>which I do not understand, as my data is being converted to a <code>numpy.ndarray</code> before creating the <code>NDArrayIter</code> instance.  Would someone be willing to provide some insight on how to read data in <code>mxnet</code>?  </p>
  
  <p>The code above is currently using the following versions:</p>
  
  <ul>
  <li>mxnet-1.1.0</li>
  <li>numpy-1.14.2</li>
  </ul>