Created
May 6, 2019 04:07
-
-
Save ChunML/6cc2e187a4b3b0a985ef2fe260a0dac3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 + 1) % 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