title: How to create a dataset array of images?
body: <p>I'm was messing around with tensorflow, and I has made an image classifier on the mnist dataset. Now I'm trying to recreate that, but with my own dataset, but i'm having trouble just creating the array I want. For example-</p>
  <pre><code>(X_train, y_train),(X_test, y_test)= mnist.load_data()
  print(X_train.shape)
  </code></pre>
  <p>Output-</p>
  <pre><code>(60000, 28, 28)
  
  </code></pre>
  <p>Where 60000 is the number of images, and the 28, 28 is the image array.</p>
  <p>Trying to create this 3d array with my 2 images, I wrote this program-</p>
  <pre><code>import numpy as np, random
  import matplotlib.image as plt
  X_train=[]
  print(&quot;Preparing the dataset...&quot;)
  for i in range(100):
      img= plt.imread(f&quot;img/{random.randint(1,2)}.png&quot;)
      X_train= np.append(X_train, img)
  print(&quot;Done...&quot;)
  print(X_train.shape)
  
  </code></pre>
  <p>Here, I'm just trying to append my <code>img</code> array to another array <code>X_train</code>. But the output is-</p>
  <pre><code>Preparing the dataset...
  Done...
  (1510452,)
  </code></pre>
  <p>Why is it flattening the whole thing? I'm expecting the shape to be (100, x, y), where x and y is the image array. How do I fix this? Please help me. Thanks!</p>