Skip to content

Instantly share code, notes, and snippets.

@ferrygun
Last active June 11, 2020 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferrygun/245946fa834f929e1f7ed5a4072c711c to your computer and use it in GitHub Desktop.
Save ferrygun/245946fa834f929e1f7ed5a4072c711c to your computer and use it in GitHub Desktop.
input = Input(shape=(max_len,))
model = Embedding(input_dim=n_words, output_dim=50, input_length=max_len)(input)
model = Dropout(0.5)(model)
model = Bidirectional(LSTM(units=100, return_sequences=True, recurrent_dropout=0.1))(model)
out = TimeDistributed(Dense(n_tags, activation="softmax"))(model) # softmax output layer
model = Model(input, out)
opt = tf.keras.optimizers.Adam(lr=0.01, decay=1e-6)
model.compile(optimizer=opt, loss="categorical_crossentropy", metrics=["accuracy"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment