title: Input 0 of layer sequential is incompatible with the layer expected ndim=3, found ndim=2. Full shape received: [None, 1]
body: <p>I am working with keras for text classification. After pre-processing and vectorization my train and validation data details is like bellow:</p>
  <pre><code>print(X_train.shape, ',', X_train.ndim, ',', type(X_train))
  print(y_train.shape, ',', y_train.ndim, ',', type(y_train))
  print(X_valid.shape, ',', X_valid.ndim, ',', type(X_valid))
  print(y_valid.shape, ',', y_valid.ndim, ',', type(y_valid))
  print(data_dim)
  </code></pre>
  <p>output is:</p>
  <pre><code>(14904,) , 1 , &lt;class 'numpy.ndarray'&gt;
  (14904,) , 1 , &lt;class 'numpy.ndarray'&gt;
  (3725,) , 1 , &lt;class 'numpy.ndarray'&gt;
  (3725,) , 1 , &lt;class 'numpy.ndarray'&gt;
  15435
  </code></pre>
  <p>then model definition is:</p>
  <pre><code>model = Sequential()
  model.add(LSTM(100, input_shape=(data_dim,1 ), return_sequences=True))
  model.add(Dropout(0.2))
  model.add(LSTM(200))
  model.add(Dropout(0.2))
  model.add(Dense(1, activation='sigmoid'))
  
  model.compile(loss='binary_crossentropy', optimizer='adam', metrics = ['accuracy'])
  model.summary()
  </code></pre>
  <p>model summury:</p>
  <p><a href="https://i.stack.imgur.com/iwZyg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iwZyg.png" alt="enter image description here" /></a></p>
  <p>model fitting:</p>
  <pre><code>model.fit(X_train,y_train, validation_data = (X_valid, y_valid),
            batch_size=batch_size, epochs=epochs)
  </code></pre>
  <p>Why does this error occur?</p>
  <pre><code>----&gt; 1 model.fit(X_train,y_train, validation_data = (X_valid, y_valid),
        2           batch_size=batch_size, epochs=epochs)
  ...
  ...
  
      ValueError: Input 0 of layer sequential is incompatible with the layer:
                expected ndim=3, found ndim=2. Full shape received: [None, 1]
  </code></pre>