title: ValueError: Input 0 of layer lstm_1 is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (None, 64)
body: <p>I've been having a hard time comprehending what this error message is about. I've looked into many posts like</p>
  <p><a href="https://stackoverflow.com/questions/52936132/4d-input-in-lstm-layer-in-keras">4D input in LSTM layer in Keras</a></p>
  <p><a href="https://stackoverflow.com/questions/65065630/valueerror-input-0-of-layer-sequential-is-incompatible-with-the-layer-expect">ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=4, found ndim=3</a></p>
  <p><a href="https://stackoverflow.com/questions/44583254/valueerror-input-0-is-incompatible-with-layer-lstm-13-expected-ndim-3-found-n">ValueError: Input 0 is incompatible with layer lstm_13: expected ndim=3, found ndim=4</a></p>
  <p><a href="https://stackoverflow.com/questions/63835532/input-0-of-layer-sequential-is-incompatible-with-the-layer-expected-ndim-3-foun">Input 0 of layer sequential is incompatible with the layer expected ndim=3, found ndim=2. Full shape received: [None, 1]</a></p>
  <p><a href="https://stackoverflow.com/questions/54416322/expected-ndim-3-found-ndim-2">expected ndim=3, found ndim=2</a></p>
  <p>but none of them seem to resolve my problem.</p>
  <p>I have</p>
  <pre><code>batch_train_dataset = tf.data.Dataset.from_tensor_slices((train_features, train_labels)).shuffle(512).batch(batch_size)
  
  for i,x in enumerate(batch_train_dataset):
    print(&quot;x[0].ndim: &quot;, x[0].ndim)
    print(&quot;x[0].shape: &quot;, x[0].shape)
    print(&quot;x[1].shape: &quot;, x[1].shape)
    if i==0:
      break
  ##########OUTPUT###########
  x[0].ndim:  3
  x[0].shape:  (64, 32, 1000)
  x[1].shape:  (64,)
  </code></pre>
  <p>and my individual data has a shape<code>(64,32,1000)</code> where <code>64</code> is batch_size, <code>32</code> is timesteps and <code>1000</code> is a number of features.</p>
  <p>This is my model.</p>
  <pre><code>num_classes = len(index_to_label)
  
  lstm_model = tf.keras.Sequential([
      tf.keras.layers.Masking(mask_value=0.0), # DO NOT REMOVE THIS LAYER
  
      # TODO: Define a recurrent neural network to recognize one of `num_classes` actions from the given video
      ### START CODE HERE ###
      tf.keras.layers.LSTM(64, input_shape=(batch_size,32,1000)),
      tf.keras.layers.LSTM(32),
      tf.keras.layers.Dense(32, activation='relu'),
      tf.keras.layers.Dense(32, activation='relu'),
      tf.keras.layers.Dense(num_classes, activation='softmax')
      ### END CODE HERE ###
  ])
  </code></pre>
  <p>I think I had my <code>input_shape</code> set right and I have no idea what to fix here based on those questions that I listed above. Whenever I try to fit the model, it still prints an error</p>
  <pre><code>ValueError: Input 0 of layer lstm_1 is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (None, 64)
  </code></pre>
  <p>Can anyone help me with this please.</p>
  <p>====================EDIT==================</p>
  <p>Thanks to some comments, I've changed my input_shaped to (32,1000) but it still prints out the exact same error. I'm still wondering what the cause might be so any other ideas would be appreciated.</p>