Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from keras.layers.convolutional import Conv1D
from keras.layers.convolutional import MaxPooling1D
preprocessed_question_title_input = Input(shape=(max_length,), name = "preprocessed_question_title")
emb = Embedding(vocab_size, 300, weights=[embedding_matrix], input_length=max_length,trainable=False)(preprocessed_question_title_input)
conv1 = Conv1D(filters=32, kernel_size=4, activation='relu')(emb)
pool1 = MaxPooling1D(pool_size=2)(conv1)
lstm_CNN= LSTM(128,return_sequences=True)(pool1)
dropout_CNN_LSTM = Dropout(0.2)(lstm_CNN)
flat_title = Flatten()(dropout_CNN_LSTM)
concat_layers = []
concat_layers.append(flat_title)
concat_layers.append(flat_question)
concat_layers.append(flat_answer)
concat_layers.append(category_flat)
concat_layers.append(host_flat)
concat_layers.append(num_field_dense)
concat_layers = Concatenate()(concat_layers)
concat_layers= Dense(512,activation='relu',kernel_initializer='he_normal',kernel_regularizer=l2(0.001))(concat_layers)
concat_layers = BatchNormalization()(concat_layers)
concat_layers= Dropout(0.4)(concat_layers)
concat_layers= Dense(64,activation='relu',kernel_initializer='he_normal',kernel_regularizer=l2(0.001))(concat_layers)
concat_layers = BatchNormalization()(concat_layers)
concat_layers= Dropout(0.4)(concat_layers)
concat_layers = BatchNormalization()(concat_layers)
output=Dense(len(target_columns), activation='sigmoid')(concat_layers)
model_4 = Model(inputs=[preprocessed_question_title_input,preprocessed_question_body_input,preprocessed_question_answer_input,category_input,host_input,num_field_input], outputs=output)
model_4.summary()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.