title: Is there any better way of creating numpy array when number of elements are very high?
body: <p>I'm reading the images (512 x 512) and corresponding labels, which were in .mat format, then  storing it into numpy array amd finally into .npy file....</p>
  
  <pre><code>i=0
  arr1=[]
  while(i&lt;500):
      f=h5py.File(imagenames[i])
      dset=f['cjdata']
      print(i)
     a1=dset['image']
     a2=dset['label']
     arr1.append(np.array(a1))
     arr2.append(np.array(a2))
     np.save('xxtrain.npy',arr1)
  np.save('yytrain.npy',arr2)
  i=i+1
  </code></pre>
  
  <p>then I loaded  data1 and data2 with the values which were stored in the previous np file :</p>
  
  <pre><code>data1=np.load('xxtrain.npy')
  data2=np.load('yytrain.npy')
  </code></pre>
  
  <p>Then, I printed the shape of each data1 and data2:</p>
  
  <pre><code>print(data1.shape)
  print(data2.shape)
  </code></pre>
  
  <p>It printed as follows:</p>
  
  <pre><code>(500,)
  (500, 1, 1)
  </code></pre>
  
  <p>The data2 shape is perfect , but the data1 shape should have been (500,512,512) it is considering data1 as one array of 500 elements ....</p>
  
  <p>Any help will be appreciated, Thank you:)</p>
  
  <p>Sorry for my English. </p>