Skip to content

Instantly share code, notes, and snippets.

@ChunML
Created April 30, 2019 04:02
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 ChunML/9b0b7ba9751faaa8718440498c91d97e to your computer and use it in GitHub Desktop.
Save ChunML/9b0b7ba9751faaa8718440498c91d97e to your computer and use it in GitHub Desktop.
encoder = Encoder(en_vocab_size, MODEL_SIZE, NUM_LAYERS, H)
decoder = Decoder(fr_vocab_size, MODEL_SIZE, NUM_LAYERS, H)
NUM_EPOCHS = 100
start_time = time.time()
for e in range(NUM_EPOCHS):
for batch, (source_seq, target_seq_in, target_seq_out) in enumerate(dataset.take(-1)):
loss = train_step(source_seq, target_seq_in,
target_seq_out)
print('Epoch {} Loss {:.4f}'.format(
e + 1, loss.numpy()))
if e % 10 == 0:
end_time = time.time()
print('Average elapsed time: {:.2f}s'.format((end_time - start_time) / (e + 1)))
try:
predict()
except Exception as e:
print(e)
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment