Last active
June 20, 2022 17:11
-
-
Save prafulgondane/a25c1d8c70ade1d5ace38d543d1d9bec 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
DROPOUT_RATE = 0.3 | |
LEARNING_RATE = 0.00005 | |
NUM_EPOCHS = 10 | |
BATCH_SIZE = 128 | |
#Create CNN Layers | |
sequence_input = Input(shape=(MAX_SEQUENCE_LENGTH,), dtype='int32') | |
embedding_layer = Embedding(len(tokenizer.word_index) + 1, | |
EMBEDDINGS_DIMENSION, | |
weights=[embedding_matrix], | |
input_length=MAX_SEQUENCE_LENGTH, | |
trainable=False) | |
x = embedding_layer(sequence_input) | |
x = Conv1D(128, 2, activation='relu', padding='same')(x) | |
x = MaxPooling1D(5, padding='same')(x) | |
x = Conv1D(128, 3, activation='relu', padding='same')(x) | |
x = MaxPooling1D(5, padding='same')(x) | |
x = Conv1D(128, 4, activation='relu', padding='same')(x) | |
x = MaxPooling1D(40, padding='same')(x) | |
x = Flatten()(x) | |
x = Dropout(DROPOUT_RATE)(x) | |
x = Dense(128, activation='relu')(x) | |
preds = Dense(2, activation='softmax')(x) | |
# Compile model. | |
print('compiling model') | |
# model = Model(input_layer, output_layer) | |
model = Model(sequence_input, preds) | |
model.compile(loss='categorical_crossentropy', optimizer=RMSprop(lr=LEARNING_RATE), metrics=['acc']) | |
keras.utils.plot_model(model, "multi_input_and_output_model.png", show_shapes=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment