title: Convolutional Neural Network Layers
body: <p>I want to detect certain patterns using a CNN, however, the last two layers of my CNN get an error when I try to run them. I have commented those layers in the code below.
  *Every Conv2D layer is repeated before the MaxPooling layer.</p>
  <pre><code>  inputs = tf.keras.layers.Input(shape=(256, 256, 27), name='input_layer')
          lambda_layer = tf.keras.layers.Lambda(lambda value: value / 255)(inputs)
          xp = tf.keras.layers.Conv2D(64, 3, padding='same', activation=tf.nn.relu)(lambda_layer)
          xp = tf.keras.layers.MaxPooling2D()(xp)  # by default uses 2,2
          xp = tf.keras.layers.BatchNormalization()(xp)
          xp = tf.keras.layers.Conv2D(94, 3, padding='same', activation=tf.nn.relu)(xp)
          xp = tf.keras.layers.MaxPooling2D()(xp)
          xp = tf.keras.layers.BatchNormalization()(xp)
          xp = tf.keras.layers.Conv2D(128, 3, padding='same', activation=tf.nn.relu)(xp)
          xp = tf.keras.layers.MaxPooling2D()(xp)
          xp = tf.keras.layers.BatchNormalization()(xp)
          xp = tf.keras.layers.Conv2D(156, 3, padding='valid', activation=tf.nn.relu)(xp)
          xp = tf.keras.layers.MaxPooling2D()(xp)
          xp = tf.keras.layers.BatchNormalization()(xp)
          xp = tf.keras.layers.Conv2D(256, 3, padding='same', activation=tf.nn.relu)(xp)
          xp = tf.keras.layers.MaxPooling2D()(xp)
          xp = tf.keras.layers.BatchNormalization()(xp)
          xp = tf.keras.layers.Conv2D(394, 3, padding='same', activation=tf.nn.relu)(xp)
          xp = tf.keras.layers.MaxPooling2D()(xp)
          xp = tf.keras.layers.BatchNormalization()(xp)
          xp = tf.keras.layers.Conv2D(458, 3, padding='same', activation=tf.nn.relu)(xp)
          xp = tf.keras.layers.MaxPooling2D()(xp)
          xp = tf.keras.layers.BatchNormalization()(xp)
      #    xp = tf.keras.layers.Conv2D(516, 3, padding='same', activation=tf.nn.relu)(xp)
       #   xp = tf.keras.layers.Conv2D(516, 3, padding='same', activation=tf.nn.relu)(xp)
       #   xp = tf.keras.layers.MaxPooling2D()(xp)
      #    xp = tf.keras.layers.BatchNormalization()(xp)
          xp = tf.keras.layers.Dropout(0.25)(xp)
          xp = tf.keras.layers.Flatten()(xp)
          xp = tf.keras.layers.Dense(1024, activation=tf.nn.relu)(xp)
          xp = tf.keras.layers.BatchNormalization()(xp)
          xp = tf.keras.layers.Dropout(0.25)(xp)
          xp = tf.keras.layers.Dense(512, activation=tf.nn.relu)(xp)
          xp = tf.keras.layers.Dropout(0.25)(xp)
  </code></pre>
  <p>I get an error</p>
  <pre><code>
  Call arguments received:
    • inputs=tf.Tensor(shape=(None, 2, 2, 394), dtype=float32)
  </code></pre>
  <p>Meaning I might have convolved the image too much so it's getting an error. What can I do to solve this?</p>