title: I have this error "input 0 is incompatible with layer lstm expected ndim=3 found ndim=5"
body: <p>I am very new in this field. I searched on the internet but I could not find a solution. I am waiting for the help of people who are interested in this field. </p>
  
  <p>My model</p>
  
  <pre><code>def load_VGG16_model():
      base_model = VGG16(weights='imagenet', include_top=False, input_shape=(256,256,3))
      print("Model loaded..!")
      return base_model
  </code></pre>
  
  <p>Summary of the model</p>
  
  <pre><code>load_VGG16_model().summary()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/KS4s9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KS4s9.png" alt="result"></a>  </p>
  
  <p>Adding Layers</p>
  
  <pre><code>def action_model(shape=(30, 256, 256, 3), nbout=len(classes)):
      convnet = load_VGG16_model()
  
      model = Sequential()
      model.add(TimeDistributed(convnet, input_shape=shape))
      model.add(LSTM(30,return_sequences=True,input_shape=(30,512))) # the error shows this line.
      top_model.add(Dense(4096, activation='relu', W_regularizer=l2(0.1)))
      top_model.add(Dropout(0.5))
      top_model.add(Dense(4096, activation='relu', W_regularizer=l2(0.1)))
      top_model.add(Dropout(0.5))
      model.add(Dense(nbout, activation='softmax'))
      return model
  </code></pre>
  
  <p><strong>model.add(LSTM(30,return_sequences=True,input_shape=(30,512)))</strong> ==> the error shows this line.</p>