title: Keras LSTM Layer ValueError: Dimensions must be equal, but are 17 and 2
body: <p>I'm working on a basic RNN model for a multiclass task and I'm facing some issues with output dimensions.</p>
  <p>This is my input/output shapes:</p>
  <pre><code>input.shape = (50000, 2, 5) # (samples, features, feature_len)
  output.shape = (50000, 17, 185) # (samples, features, feature_len) &lt;-- one hot encoded 
  
  input[0].shape =  (2, 5)
  output[0].shape = (17, 185)
  </code></pre>
  <p>This is my model, using Keras functional API:</p>
  <pre><code>inp = tf.keras.Input(shape=(2, 5,))
  
  x = tf.keras.layers.LSTM(128, input_shape=(2, 5,), return_sequences=True, activation='relu')(inp)
  out = tf.keras.layers.Dense(185, activation='softmax')(x)
  
  model = tf.keras.models.Model(inputs=inp, outputs=out)
  </code></pre>
  <p>This is my <code>model.summary()</code>:</p>
  <pre><code>Layer (type)                 Output Shape              Param #
  =================================================================
  input_1 (InputLayer)         [(None, 2, 5)]            0
  _________________________________________________________________
  lstm (LSTM)                  (None, 2, 128)            68608
  _________________________________________________________________
  dense (Dense)                (None, 2, 185)            23865
  =================================================================
  Total params: 92,473
  Trainable params: 92,473
  Non-trainable params: 0
  _________________________________________________________________
  </code></pre>
  <p>Then I compile the model and run <code>fit()</code>:</p>
  <pre><code>model.compile(optimizer='adam',
                loss=tf.nn.softmax_cross_entropy_with_logits,
                metrics='accuracy')
  
  model.fit(x=input, y=output, epochs=5)
  </code></pre>
  <p>And I'm getting a dimension error:</p>
  <pre><code>ValueError: Dimensions must be equal, but are 17 and 2 for '{{node Equal}} = Equal[T=DT_INT64, incompatible_shape_error=true](ArgMax, ArgMax_1)' with input shapes: [?,17], [?,2].
  </code></pre>
  <p>The error is clear, the model output a dimension <code>2</code> and my output has dimension <code>17</code>, although I understand the issue, I can't find a way of fixing it, any ideas?</p>