title: Multiple images as CNN input - cannot reshape array
body: <p>I am trying to train CNN to drive a car using 4 images as one input. </p>
  
  <p>This is how my code looks like</p>
  
  <pre><code>import numpy as np
  from datetime import datetime
  import tensorflow as tf
  from tensorflow.keras.models import Sequential
  from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dropout, Dense
  from tensorflow_core.python.keras.layers import concatenate
  from tensorflow_core.python.keras.models import Model
  
  
  # Loading data
  train_data = np.load("/mydrive/Mister_car/training_data-6.npy", allow_pickle=True)
  WIDTH = 200
  HEIGHT = 160
  MODEL_DIR = "/mydrive/Mister_car/model/"
  
  # Load new model
  #model = alexnet((WIDTH, HEIGHT, 3), 9)
  
  model1 = alexnet((WIDTH, HEIGHT, 3), 9)
  model2 = alexnet((WIDTH, HEIGHT, 3), 9)
  model3 = alexnet((WIDTH, HEIGHT, 3), 9)
  model4 = alexnet((WIDTH, HEIGHT, 3), 9)
  
  combined = concatenate([model1.output, model2.output, model3.output, model4.output])
  out = Dense(9, activation="softmax")(combined)
  
  model = Model(inputs=[model1.input, model2.input, model3.input, model4.input], outputs = out)
  
  model.compile(optimizer=tf.keras.optimizers.Adam(0.01),
                   loss='categorical_crossentropy',
                   metrics=['accuracy'])
  
  # Load existing model
  # model = tf.keras.models.load_model(MODEL_DIR)
  
  if len(train_data) &gt; 10:
      print("git")
      # Splitting data into a training set and test set
      train = train_data[:]
      test = train_data[:]
  
      print(train[6][0][0].shape)
  
      X = np.array([i[0] for i in train]).reshape(-1, 4, WIDTH, HEIGHT, 3)
      Y = np.array([i[1] for i in train])
  
      x_test = np.array([i[0] for i in test])#.reshape(-1, 4, WIDTH, HEIGHT, 3)
      y_test = np.array([i[1] for i in test])
  
      # start training
      model.fit(x=X,
                y=Y,
                epochs=10,
                validation_data=(x_test, y_test))
  
      # save the whole model
      model.save(MODEL_DIR)
  </code></pre>
  
  <p>This lines causes problem</p>
  
  <pre><code>X = np.array([i[0] for i in train]).reshape(-1, 4, WIDTH, HEIGHT, 3)
  Y = np.array([i[1] for i in train])
  
  x_test = np.array([i[0] for i in test])#.reshape(-1, 4, WIDTH, HEIGHT, 3)
  y_test = np.array([i[1] for i in test])
  </code></pre>
  
  <p>cannot reshape array of size 200 into shape (4,200,160,3)</p>
  
  <p>Earlier with one image as input I used this:</p>
  
  <pre><code>X = np.array([i[0] for i in train]).reshape(-1, WIDTH, HEIGHT, 3)
  Y = np.array([i[1] for i in train])
  
  x_test = np.array([i[0] for i in test])#.reshape(-1, WIDTH, HEIGHT, 3)
  y_test = np.array([i[1] for i in test])
  </code></pre>
  
  <p>where i[0] is the image and i[1] is a list with keyboard input.</p>
  
  <p>Now i[0] is a list of 4 images and i[1] is a list of 4 lists.
  So I added this new dimension, which is for but I get this error. It's very strange for me.
  I would be really appreciated for your help.</p>