Last active
June 2, 2018 23:10
-
-
Save adamkusey/87326161817d85bf0476f1edf9a98c04 to your computer and use it in GitHub Desktop.
SecuritAI LSTM RNN Model
This file contains hidden or 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
model = Sequential() | |
model.add(Embedding(num_words, 32, input_length=max_log_length)) | |
# Prevent overfitting using dropout method of regularization | |
model.add(Dropout(0.5)) | |
model.add(LSTM(64, recurrent_dropout=0.5)) | |
model.add(Dropout(0.5)) | |
# Condense to single binary output value | |
model.add(Dense(1, activation='sigmoid')) | |
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) | |
# Training set automatically split 75/25 to check validation loss/accuracy at each epoch | |
model.fit(X_train, Y_train, validation_split=0.25, epochs=3, batch_size=128, callbacks=[tb_callback]) | |
# Evaluation of separate test dataset performed after training | |
score, acc = model.evaluate(X_test, Y_test, verbose=1, batch_size=128) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment