title: ValueError: could not broadcast input array from shape (22500,3) into shape (1)
body: <p>I relied on the code mentioned, <a href="https://stackoverflow.com/questions/29781976/cpickle-very-large-amount-of-data">here</a>, but with minor edits. The version that I have is as follows:</p>
  
  <pre><code>import numpy as np
  import _pickle as cPickle
  from PIL import Image
  import sys,os
  
  pixels = []
  labels = []
  traindata = []
  data=[]
  
  directory = 'C:\\Users\\abc\\Desktop\\Testing\\images'
  for root, dirs, files in os.walk(directory):
      for file in files:
          floc = file
          im = Image.open(str(directory) + '\\' + floc)
          pix = np.array(im.getdata())
          pixels.append(pix)
          labels.append(1)
  
  pixels = np.array(pixels)
  labels = np.array(labels)
  traindata.append(pixels)
  traindata.append(labels)
  traindata = np.array(traindata)
  # do the same for validation and test data
  # put all data and labels into 'data' array
  cPickle.dump(data,open('data.pkl','wb'))
  </code></pre>
  
  <p>When I run the code, I get the following:</p>
  
  <pre><code>Traceback (most recent call last):
    File "pickle_data.py", line 24, in &lt;module&gt;
      traindata=np.array(traindata)
  ValueError: could not broadcast input array from shape (22500,3) into shape (1)
  </code></pre>
  
  <p>How can I solve this issue?</p>
  
  <p>Thanks.</p>