title: mean() got an unexpected keyword argument 'dtype'!
body: <p>I am trying to implement image classification using Intel Bigdl. It is using mnist dataset for classification. Since, I don't want to use the mnist dataset I wrote the alternative approach to it as below:</p>
  
  <p><strong>Image Utils.py</strong></p>
  
  <pre><code>from StringIO import StringIO
  from PIL import Image
  import numpy as np
  from bigdl.util import common
  from bigdl.dataset import mnist
  from pyspark.mllib.stat import Statistics
  
  def label_img(img):
      word_label = img.split('.')[-2].split('/')[-1]
      print word_label
      # conversion to one-hot array [cat,dog]
      #                            [much cat, no dog]
      if "jobs" in word_label: return [1,0]
      #                             [no cat, very doggo]
      elif "zuckerberg" in word_label: return [0,1]
  
      # target is start from 0,
  
  def get_data(sc,path):
      img_dir = path
      train = sc.binaryFiles(img_dir + "/train")
      test = sc.binaryFiles(img_dir+"/test")
      image_to_array = lambda rawdata: np.asarray(Image.open(StringIO(rawdata)))
  
      train_data = train.map(lambda x : (image_to_array(x[1]),np.array(label_img(x[0]))))
      test_data = test.map(lambda x : (image_to_array(x[1]),np.array(label_img(x[0]))))
  
      train_images = train_data.map(lambda x : x[0])
      test_images = test_data.map((lambda x : x[0]))
      train_labels = train_data.map(lambda x : x[1])
      test_labels = test_data.map(lambda x : x[1])
  
      training_mean = np.mean(train_images)
      training_std = np.std(train_images)
      rdd_train_images = sc.parallelize(train_images)
      rdd_train_labels = sc.parallelize(train_labels)
      rdd_test_images = sc.parallelize(test_images)
      rdd_test_labels = sc.parallelize(test_labels)
  
      rdd_train_sample = rdd_train_images.zip(rdd_train_labels).map(lambda (features, label):
                                          common.Sample.from_ndarray(
                                          (features - training_mean) / training_std,
                                          label + 1))
      rdd_test_sample = rdd_test_images.zip(rdd_test_labels).map(lambda (features, label):
                                          common.Sample.from_ndarray(
                                          (features - training_mean) / training_std,
                                          label + 1))
  
      return (rdd_train_sample, rdd_test_sample)
  </code></pre>
  
  <p>Now when I try to get the data using the real image as below:</p>
  
  <p><strong>Classification.py</strong></p>
  
  <pre><code>import pandas
  import datetime as dt
  
  from bigdl.nn.layer import *
  from bigdl.nn.criterion import *
  from bigdl.optim.optimizer import *
  from bigdl.util.common import *
  from bigdl.dataset.transformer import *
  from bigdl.dataset import mnist
  from imageUtils import get_data
  
  from StringIO import StringIO
  from PIL import Image
  import numpy as np
  
  init_engine()
  
  path = "/home/fusemachine/Hyper/person"
  (train_data, test_data) = get_data(sc,path)
  print train_data.count()
  print test_data.count()
  </code></pre>
  
  <p>I get the following error</p>
  
  <blockquote>
    <p>TypeError                                 Traceback (most recent call >last)
     in ()</p>
    
    <blockquote>
      <p>2 # Get and store MNIST into RDD of Sample, please edit the "mnist_path" accordingly.</p>
      
      <p>3 path = "/home/fusemachine/Hyper/person"</p>
      
      <p>----> 4 (train_data, test_data) = get_data(sc,path)</p>
      
      <p>5 print train_data.count()</p>
      
      <p>6 print test_data.count()</p>
    </blockquote>
    
    <p>/home/fusemachine/Downloads/dist-spark-2.1.0-scala-2.11.8-linux64-0.1.1-dist/imageUtils.py in get_data(sc, path)</p>
    
    <blockquote>
      <p>31     test_labels = test_data.map(lambda x : x[1])</p>
      
      <p>---> 33     training_mean = np.mean(train_images)</p>
      
      <p>34     training_std = np.std(train_images)</p>
      
      <p>35     rdd_train_images = sc.parallelize(train_images)</p>
    </blockquote>
    
    <p>/opt/anaconda3/lib/python2.7/site-packages/numpy/core/fromnumeric.pyc in mean(a, axis, dtype, out, keepdims)</p>
    
    <blockquote>
      <p>2884             pass</p>
      
      <p>2885         else:</p>
      
      <p>-> 2886             return mean(axis=axis, dtype=dtype, out=out, **kwargs)</p>
      
      <p>2887 </p>
      
      <p>2888     return _methods._mean(a, axis=axis, dtype=dtype,</p>
    </blockquote>
    
    <p>TypeError: mean() got an unexpected keyword argument 'dtype'</p>
  </blockquote>
  
  <p>I could not figure out the solution for this. Also is there any other alternative of mnist dataset. So that we can directly process the real Image ? 
  Thank you</p>