Last active
February 16, 2018 11:07
-
-
Save khuangaf/c95515be04404a5bc09f72790aa9900e to your computer and use it in GitHub Desktop.
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
maxlen = 75 | |
output_size = y_train.shape[1] | |
max_features= output_size | |
embed_size = 50 | |
input_size = (maxlen, 1,) | |
def get_model(): | |
global input_size, output_size | |
inp = Input(shape=input_size) | |
x = Embedding(max_features, embed_size)(inp) | |
x = CuDNNGRU(50, return_sequences=True)(inp) | |
x = LeakyReLU()(x) | |
x = Dropout(0.2)(x) | |
x = GlobalMaxPooling1D()(x) | |
x = Dense(40)(x) | |
x = LeakyReLU()(x) | |
x = Dropout(0.2)(x) | |
x = Dense(output_size, activation="sigmoid")(x) | |
model = Model(inputs=inp, outputs=x) | |
model.compile(loss='categorical_crossentropy', | |
optimizer='rmsprop') | |
model.layers[1].set_weights([embedding_matrix]) | |
model.layers[1].trainable = False | |
return model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment