Created
February 19, 2021 07:14
-
-
Save AyishaR/6fc15e4de4d221f508f3c44a0c580dd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build and train neural network | |
embedding_dim = 128 | |
model = models.Sequential([ | |
layers.Embedding(vocab, embedding_dim, input_length = mlen), | |
layers.LSTM(128, activation='tanh'), | |
layers.Dense(32, activation = 'relu'), | |
layers.Dense(16, activation = 'relu'), | |
layers.Dense(1, activation = 'sigmoid') | |
]) | |
cb = [callbacks.EarlyStopping(patience = 5, restore_best_weights = True)] | |
model.compile(optimizer = optimizers.Adam(0.01), loss = losses.BinaryCrossentropy(), metrics = ['accuracy']) | |
history = model.fit(Xtrain, ytrain, batch_size=64, epochs = 256, validation_data=(Xval, yval), callbacks = cb) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment