title: I am getting error layer max_pooling2d_111 is incompatible with the layer: expected ndim=4, found ndim=5
body: <p>I am currently writing the code, the model to take 4 images as an input. All 4 images are passed through the convolution network and then all image's output is concatenated. But while compiling I am getting an error of &quot;Input 0 of layer max_pooling2d_111 is incompatible with the layer: expected ndim=4 found ndim=5. Full shape received: [None, 4, 128, 128, 16]&quot;</p>
  <p><img src="https://i.stack.imgur.com/UQ1aX.png" alt="Error" /></p>
  <p>I know there is 1 more dimension in the input (size of 4) but how should I do this or solve this issue?</p>
  <p>My model code is :</p>
  <p>#Build the model</p>
  <pre><code>inputs1 = tf.keras.layers.Input((IMG_HEIGHT, IMG_WIDTH, IMG_CHANNELS))
  o1 = tf.keras.layers.Lambda(lambda x: x / 255)(inputs1)
  c1 = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(o1)
  c1 = tf.keras.layers.Dropout(0.1)(c1)
  c1 = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c1)
  p1 = tf.keras.layers.MaxPooling2D((2, 2))(c1)
  #p1 = c1
  
  c1 = tf.keras.layers.Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p1)
  c1 = tf.keras.layers.Dropout(0.1)(c1)
  c1 = tf.keras.layers.Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c1)
  p1 = tf.keras.layers.MaxPooling2D((2, 2))(c1)
  #p1 = c1
  
  c1 = tf.keras.layers.Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p1)
  c1 = tf.keras.layers.Dropout(0.2)(c1)
  c1 = tf.keras.layers.Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c1)
  p1 = tf.keras.layers.MaxPooling2D((2, 2))(c1)
  #p1 = c1
  
  c1 = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p1)
  c1 = tf.keras.layers.Dropout(0.2)(c1)
  c1 = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c1)
  p1 = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(c1)
  #p1 = c1
  
  inputs2 = tf.keras.layers.Input((IMG_HEIGHT, IMG_WIDTH, IMG_CHANNELS))
  o2 = tf.keras.layers.Lambda(lambda x: x / 255)(inputs2)
  c2 = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(o2)
  c2 = tf.keras.layers.Dropout(0.1)(c2)
  c2 = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c2)
  p2 = tf.keras.layers.MaxPooling2D((2, 2))(c2)
  #p2 = c2
  
  c2 = tf.keras.layers.Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p2)
  c2 = tf.keras.layers.Dropout(0.1)(c2)
  c2 = tf.keras.layers.Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c2)
  p2 = tf.keras.layers.MaxPooling2D((2, 2))(c2)
  #p2 = c2
  
  c2 = tf.keras.layers.Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p2)
  c2 = tf.keras.layers.Dropout(0.2)(c2)
  c2 = tf.keras.layers.Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c2)
  p2 = tf.keras.layers.MaxPooling2D((2, 2))(c2)
  #p2 = c2
  
  c2 = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p2)
  c2 = tf.keras.layers.Dropout(0.2)(c2)
  c2 = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c2)
  p2 = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(c2)
  #p2 = c2
  
  inputs3 = tf.keras.layers.Input((IMG_HEIGHT, IMG_WIDTH, IMG_CHANNELS))
  o3 = tf.keras.layers.Lambda(lambda x: x / 255)(inputs3)
  c3 = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(o3)
  c3 = tf.keras.layers.Dropout(0.1)(c3)
  c3 = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c3)
  p3 = tf.keras.layers.MaxPooling2D((2, 2))(c3)
  #p3 = c3
  
  c3 = tf.keras.layers.Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p3)
  c3 = tf.keras.layers.Dropout(0.1)(c3)
  c3 = tf.keras.layers.Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c3)
  p3 = tf.keras.layers.MaxPooling2D((2, 2))(c3)
  #p3 = c3
  
  c3 = tf.keras.layers.Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p3)
  c3 = tf.keras.layers.Dropout(0.2)(c3)
  c3 = tf.keras.layers.Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c3)
  p3 = tf.keras.layers.MaxPooling2D((2, 2))(c3)
  #p3 = c3
  
  c3 = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p3)
  c3 = tf.keras.layers.Dropout(0.2)(c3)
  c3 = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c3)
  p3 = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(c3)
  #p3 = c3
  
  P = tf.keras.layers.concatenate([p1, p2, p3])
  
  cp = tf.keras.layers.Conv2D(256, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(P)
  cp = tf.keras.layers.Dropout(0.3)(cp)
  cp = tf.keras.layers.Conv2D(256, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(cp)
  
  #Build the model
  inputs = tf.keras.layers.Input((IMG_HEIGHT, IMG_WIDTH, IMG_CHANNELS))
  s = tf.keras.layers.Lambda(lambda x: x / 255)(inputs)
  c = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(s)
  c = tf.keras.layers.Dropout(0.1)(c)
  c = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c)
  p = tf.keras.layers.MaxPooling2D((2, 2))(c)
  #p = c
  
  c = tf.keras.layers.Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p)
  c = tf.keras.layers.Dropout(0.1)(c)
  c = tf.keras.layers.Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c)
  p = tf.keras.layers.MaxPooling2D((2, 2))(c)
  #p = c
  
  c = tf.keras.layers.Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p)
  c = tf.keras.layers.Dropout(0.2)(c)
  c = tf.keras.layers.Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c)
  p = tf.keras.layers.MaxPooling2D((2, 2))(c)
  #p = c
  
  c = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p)
  c = tf.keras.layers.Dropout(0.2)(c)
  c = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c)
  p = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(c)
  #p = c
  
  c = tf.keras.layers.Conv2D(256, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(p)
  c = tf.keras.layers.Dropout(0.3)(c)
  c = tf.keras.layers.Conv2D(256, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(c)
  
  one =  tf.keras.layers.concatenate([cp,c])
  #one =  tf.keras.layers.add([cp,c])
  
  #Compression
  onec = tf.keras.layers.Conv2D(512, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(one)
  onec = tf.keras.layers.Dropout(0.3)(onec)
  onec = tf.keras.layers.Conv2D(512, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(onec)
  onep = tf.keras.layers.MaxPooling2D(pool_size=(2, 2))(onec)
  
  #Decompression
  d = tf.keras.layers.Conv2DTranspose(256, (2, 2), strides=(2, 2), padding='same')(onep)
  d = tf.keras.layers.Conv2D(256, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(d)
  d = tf.keras.layers.Dropout(0.3)(d)
  d = tf.keras.layers.Conv2D(256, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(d)
   
  d = tf.keras.layers.Conv2DTranspose(128, (2, 2), strides=(2, 2), padding='same')(d)
  d = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(d)
  d = tf.keras.layers.Dropout(0.3)(d)
  d = tf.keras.layers.Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(d)
  
  d = tf.keras.layers.Conv2DTranspose(64, (2, 2), strides=(2, 2), padding='same')(d)
  d = tf.keras.layers.Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(d)
  d = tf.keras.layers.Dropout(0.2)(d)
  d = tf.keras.layers.Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(d)
  
  d = tf.keras.layers.Conv2DTranspose(332, (2, 2), strides=(2, 2), padding='same')(d)
  d = tf.keras.layers.Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(d)
  d = tf.keras.layers.Dropout(0.1)(d)
  d = tf.keras.layers.Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(d)
  
  d = tf.keras.layers.Conv2DTranspose(16, (2, 2), strides=(2, 2), padding='same')(d)
  d = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(d)
  d = tf.keras.layers.Dropout(0.1)(d)
  d = tf.keras.layers.Conv2D(16, (3, 3), activation='relu', kernel_initializer='he_normal', padding='same')(d)
  
  outputs = tf.keras.layers.Conv2D(1, (1, 1), activation='relu',name = &quot;ouput&quot;)(d)
  
  model = tf.keras.Model(inputs=[inputs,inputs1,inputs2,inputs3], outputs=[outputs])
  model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
  </code></pre>
  <p>Anyone can please help me or suggest to me how to do it.</p>