title: Keras 2D input to 2D output
body: <p>First, I have read <a href="https://stackoverflow.com/questions/42154792/keras-custom-layer-2d-input-2d-output">this</a> and <a href="https://stackoverflow.com/questions/36293208/keras-2d-input-2d-output">this</a> questions with similar names to mine and still do not have an answer.</p>
  
  <p>I want to build a feedforward network for sequence prediction. (I realize that RNNs are more suitable for this task, but I have my reasons). The sequences are of length 128 and each element is a vector with 2 entries, so each batch should be of shape <code>(batch_size, 128, 2)</code> and the target is the next step in the sequence, so the target tensor should be of shape <code>(batch_size, 1, 2)</code>.</p>
  
  <p>The network architecture is something like this:</p>
  
  <pre><code>    model = Sequential()
      model.add(Dense(50, batch_input_shape=(None, 128, 2), kernel_initializer="he_normal" ,activation="relu"))
      model.add(Dense(20, kernel_initializer="he_normal", activation="relu"))
      model.add(Dense(5, kernel_initializer="he_normal", activation="relu"))
      model.add(Dense(2))
  </code></pre>
  
  <p>But trying to train I get the following error:</p>
  
  <pre><code>ValueError: Error when checking target: expected dense_4 to have shape (128, 2) but got array with shape (1, 2)
  </code></pre>
  
  <p>I've tried variations like:</p>
  
  <pre><code>model.add(Dense(50, input_shape=(128, 2), kernel_initializer="he_normal" ,activation="relu"))
  </code></pre>
  
  <p>but get the same error.</p>