Created
December 21, 2021 23:38
-
-
Save IlievskiV/0f158a8b408f5708197ba1d06dd7eeb0 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
from keras.models import Sequential | |
from keras.layers import Activation, Bidirectional, Conv1D, Dense | |
from keras.layers import Dropout, Embedding, LSTM, MaxPooling1D | |
def make_model( | |
embedding_dim: int, | |
dropout: float, | |
filters: int, | |
kernel_size: int, | |
pool_size: int, | |
lstm_output_size: int, | |
metrics: list, | |
vocab_size: int, | |
maxlen: int, | |
): | |
model = Sequential( | |
[ | |
Embedding(vocab_size, embedding_dim, input_length=maxlen), | |
Dropout(dropout), | |
Conv1D(filters, kernel_size, padding="valid", activation="relu"), | |
MaxPooling1D(pool_size=pool_size), | |
Bidirectional(LSTM(lstm_output_size), merge_mode="ave"), | |
Dense(1), | |
Activation("sigmoid"), | |
] | |
) | |
model.compile(optimizer="adam", loss="binary_crossentropy", metrics=metrics) | |
return model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment