Skip to content

Instantly share code, notes, and snippets.

@wezleysherman
Created July 31, 2020 05:09
Show Gist options
  • Save wezleysherman/5cf93c56530d945a288aad8bc62011f8 to your computer and use it in GitHub Desktop.
Save wezleysherman/5cf93c56530d945a288aad8bc62011f8 to your computer and use it in GitHub Desktop.
# CNN+LSTM
D = 512
T = train_X.shape[1]
i = Input(shape=(T,))
x = Embedding(V + 1, D)(i)
x = Dropout(0.2)(x)
x = Conv1D(filters=512, kernel_size=15)(x)
x = Dropout(0.2)(x)
x = Conv1D(filters=256, kernel_size=8)(x)
x = Dropout(0.2)(x)
x = Bidirectional(LSTM(250))(x)
x = Dropout(0.2)(x)
x = Dense(V, activation="softmax")(x)
cnn_model = Model(i, x)
cnn_model.summary()
adam = tf.keras.optimizers.Adam(0.0001)
cnn_model.compile(optimizer=adam, metrics=["accuracy"], loss="categorical_crossentropy")
cnn_r = cnn_model.fit(train_X, train_y, epochs=220)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment