Skip to content

Instantly share code, notes, and snippets.

@ashokc
Created January 26, 2019 18:07
Show Gist options
  • Save ashokc/9c185b8db93c744271e579fbac015eb0 to your computer and use it in GitHub Desktop.
Save ashokc/9c185b8db93c744271e579fbac015eb0 to your computer and use it in GitHub Desktop.
A simple model for LSTM
# A Simple Model for LSTM
model = keras.models.Sequential()
embedding = keras.layers.embeddings.Embedding(input_dim=len(kTokenizer.word_index)+1, output_dim=300, input_length=sequenceLength, trainable=True, mask_zero=True)
model.add(embedding)
model.add(keras.layers.LSTM(units=150, dropout=0.2, recurrent_dropout=0.2, return_sequences=False))
model.add(keras.layers.Dense(numClasses, activation='softmax'))
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['acc'])
print(model.summary())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment