Skip to content

Instantly share code, notes, and snippets.

@khuangaf
Last active February 16, 2018 11:07
Show Gist options
  • Save khuangaf/c95515be04404a5bc09f72790aa9900e to your computer and use it in GitHub Desktop.
Save khuangaf/c95515be04404a5bc09f72790aa9900e to your computer and use it in GitHub Desktop.
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