Skip to content

Instantly share code, notes, and snippets.

@wezleysherman
Created July 31, 2020 05:08
Show Gist options
  • Save wezleysherman/34f7f99d58523ee7c3b069ae21aa59e8 to your computer and use it in GitHub Desktop.
Save wezleysherman/34f7f99d58523ee7c3b069ae21aa59e8 to your computer and use it in GitHub Desktop.
# LSTM
D = 768
T = train_X.shape[1]
i = Input(shape=(T,))
x = Embedding(V + 1, D)(i)
x = Dropout(0.1)(x)
x = LSTM(100, return_sequences=True)(x)
x = LSTM(100)(x)
x = Dropout(0.1)(x)
x = Dense(V, activation="softmax")(x)
lstm_model = Model(i, x)
lstm_model.summary()
adam = tf.keras.optimizers.Adam(0.001)
lstm_model.compile(optimizer=adam, metrics=["accuracy"], loss="categorical_crossentropy")
lstm_r = lstm_model.fit(train_X, train_y, epochs=120)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment