title: Keras LSTM multiclass classification
body: <p>I have this code that works for binary classification. I have tested it for keras imdb dataset. </p>
  
  <pre><code>    model = Sequential()
      model.add(Embedding(5000, 32, input_length=500))
      model.add(LSTM(100, dropout=0.2, recurrent_dropout=0.2))
      model.add(Dense(1, activation='sigmoid'))
      model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])        
      print(model.summary())
      model.fit(X_train, y_train, epochs=3, batch_size=64)
      # Final evaluation of the model
      scores = model.evaluate(X_test, y_test, verbose=0)
  </code></pre>
  
  <p>I need the above code to be converted for multi-class classification where  there are 7 categories in total. What I understand after reading few articles to convert above code I have to change</p>
  
  <pre><code>model.add(Dense(7, activation='softmax'))
  model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])  
  </code></pre>
  
  <p>Obviously changing just above two lines doesn't work. What else do I have to change to make the code work for multiclass classification. Also I think I have to change the classes to one hot encoding but don't know how in keras.</p>