title: How to output a multi dimensional array in Keras?
body: <p>I have this CNN in Keras where output is a 2d array of bounding boxes,
  The shape of output is</p>
  
  <pre><code>(18, 4)
  
  x_train shape = (None, 600, 750, 1) # grayscale
  y_train shape = (None, 18, 4)
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <blockquote>
    <p>ValueError: Error when checking target: expected dense_2 to have 2
    dimensions, but got array with shape (1, 18, 4)</p>
  </blockquote>
  
  <pre><code>model = tf.keras.models.Sequential([
      tf.keras.layers.Conv2D(32, kernel_size=(3, 3), input_shape=(h, w, 1),
                             strides=(2, 2), padding="same", activation="relu"),
      tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=(2, 2), padding="same"),
      tf.keras.layers.Dropout(0.25),
  
      tf.keras.layers.Conv2D(64, (3, 3), strides=(2, 2), padding="same", activation="relu"),
      tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=(2, 2), padding="same"),
      tf.keras.layers.Dropout(0.25),
  
      tf.keras.layers.Conv2D(128, (3, 3), strides=(2, 2), padding="same", activation="relu"),
      tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=(2, 2), padding="same"),
      tf.keras.layers.Dropout(0.25),
  
      tf.keras.layers.Conv2D(512, (3, 3), strides=(2, 2), padding="same", activation="relu"),
      tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=(2, 2), padding="same"),
      tf.keras.layers.Dropout(0.25),
  
      tf.keras.layers.Flatten(),
      tf.keras.layers.Dense(1024, activation="relu"),
      tf.keras.layers.Dropout(0.5),
      tf.keras.layers.Dense(18)
  ])
  
  model.compile(loss="mse", optimizer=tf.keras.optimizers.RMSprop(), metrics=["accuracy"])
  model.fit(x_train, y_train, epochs=1)
  model.save("trained_model.h5")
  </code></pre>