title: Keras word embedding in four gram model
body: <p>I am following coursera neural network class and I am trying to pass the assignments using python+keras instead of octave.</p>
  
  <p>I want to predict the fourth word given the previous three ones. My input documents total 250 unique words. </p>
  
  <p>The model should have an embedding layer that maps each word to a 50-d vector space, a hidden layer with 200 neurons with sigmoid activation function and an output layer of 250 units scoring the probability of the forth word to be equal to those in my vocabulary through a softmax activation.</p>
  
  <p>I am having troubles with dimensions. Here is my code:</p>
  
  <pre><code>    from keras.models import Sequential
  
      from keras.layers import Dense, Activation, Embedding
  
  
      model = Sequential([Embedding(250,50),
                  Dense(200, activation='sigmoid'),
                  Dense(250, activation='softmax')
  
      ])
  
  
  
      model.compile(optimizer='rmsprop',
            loss='categorical_crossentropy',
            metrics=['accuracy'])
  </code></pre>
  
  <p>Yet I never get to compile the model since I am encountering the following error:</p>
  
  <pre><code>    Exception: Input 0 is incompatible with layer dense_1: expected ndim=2, found ndim=3
  </code></pre>
  
  <p>Any hint will be much appreciated. Thanks in advance</p>