Skip to content

Instantly share code, notes, and snippets.

@nlothian
Created February 1, 2018 10:49
Show Gist options
  • Save nlothian/1b5728f7d965f58065381ed219a3cbfd to your computer and use it in GitHub Desktop.
Save nlothian/1b5728f7d965f58065381ed219a3cbfd to your computer and use it in GitHub Desktop.
inp = Input(shape=(maxlen,), name="text_input") # featureized text comes in here
x = Embedding(embedding_matrix.shape[0], embed_size, weights=[embedding_matrix], trainable=True)(inp)
x = Dense(some_num_here, activation="relu")(x)
extra_data = Input(shape=(1,), name="extra_data") # your continous features comes in here
combined = concatenate([x, extra_data])
# maybe some ReLu + Dropout here
out = Dense(num_classes, activation="sigmoid")(combined)
model = Model(inputs=[inp, extra_data], outputs=out)
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment