title: ValueError: Shapes (None, 1) and (None, 3) are incompatible
body: <p>I have a 3 dimensional dataset of audio files where <code>X.shape</code> is <code>(329,20,85)</code>. I want to have a simpl bare-bones model running, so please don't nitpick and address only the issue at hand. Here is the code:</p>
  <pre><code>model = tf.keras.models.Sequential()
  model.add(tf.keras.layers.LSTM(32, return_sequences=True, stateful=False, input_shape = (20,85,1)))
  model.add(tf.keras.layers.LSTM(20))
  model.add(tf.keras.layers.Dense(nb_classes, activation='softmax'))
  model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=[&quot;accuracy&quot;])
  model.summary()
  print(&quot;Train...&quot;)
  model.fit(X_train, y_train, batch_size=batch_size, nb_epoch=50, validation_data=(X_test, y_test))
  </code></pre>
  <p>But then I had the error mentioned in the title:
  <code>ValueError: Shapes (None, 1) and (None, 3) are incompatible</code></p>
  <p>Here is the <code>model.summary()</code></p>
  <pre><code>Model: &quot;sequential_13&quot;
  _________________________________________________________________
  Layer (type)                 Output Shape              Param #   
  =================================================================
  lstm_21 (LSTM)               (None, 20, 32)            15104     
  _________________________________________________________________
  lstm_22 (LSTM)               (None, 20)                4240      
  _________________________________________________________________
  dense_8 (Dense)              (None, 3)                 63        
  =================================================================
  Total params: 19,407
  Trainable params: 19,407
  Non-trainable params: 0
  _________________________________________________________________
  Train...
  </code></pre>
  <p>For this, I followed <a href="https://stackoverflow.com/questions/61267737/valueerror-shapes-none-50-and-none-1-are-incompatible-in-tensorflow-and-c">this</a> post and updated Tensorflow to the latest version, but the issue persists. <a href="https://stackoverflow.com/questions/43901767/valueerror-shapes-2-1-and-are-incompatible">This</a> post is completely unrelated and highly unreliable.<a href="https://stackoverflow.com/questions/60789274/tf-estimator-add-metrics-ends-in-shapes-none-12-and-none-are-incompatible">This</a> post although a bit relatable is unanswered for a while now.</p>
  <p><strong>Update 1.0:</strong></p>
  <p>I strongly think the problem has something to do with the final <code>Dense</code> layer where I pass nb_classes as 3, since I am classifying for 3 categories in <code>y</code>.</p>
  <p>So I changed the <code>Dense</code> layer's <code>nb_classes</code> to 1, which ran the model and gives me this output, which I am positive is wrong.</p>
  <pre><code>Train...
  9/9 [==============================] - 2s 177ms/step - loss: 0.0000e+00 - accuracy: 0.1520 - val_loss: 0.0000e+00 - val_accuracy: 0.3418
  
  &lt;tensorflow.python.keras.callbacks.History at 0x7f50f1dcebe0&gt;
  </code></pre>
  <p><strong>Update 2.0:</strong></p>
  <p>I one hot encoded the <code>y</code>s and resolved the shape issue. But now the above output with <code>&lt;tensorflow.python.keras.callbacks.History at 0x7f50f1dcebe0&gt;</code> persists. Any help with this? Or should I post a new question for this? Thanks for all the help.</p>
  <p>How should I proceed, or what should I be changing?</p>