Skip to content

Instantly share code, notes, and snippets.

@rasmusbergpalm
Last active November 2, 2017 19:17
Show Gist options
  • Save rasmusbergpalm/a56f14cd6a48374a69cdb90b38d25429 to your computer and use it in GitHub Desktop.
Save rasmusbergpalm/a56f14cd6a48374a69cdb90b38d25429 to your computer and use it in GitHub Desktop.
# Encoder
source = Input(shape=(None,), dtype='int32', name='source')
embedded = Embedding(output_dim=128, input_dim=train.source_vocab_size(), mask_zero=True)(source)
last_hid = LSTM(output_dim=128)(embedded)
# Decoder
repeated = RepeatVector(train.target.padded.shape[1])(last_hid)
decoder = LSTM(output_dim=128, return_sequences=True)(repeated)
output = TimeDistributed(Dense(output_dim=train.target_vocab_size(), activation='softmax'))(decoder)
model = Model([source], output=[output])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment