Part 2: Defining the full model
Did you know that it took around 6 days and 96 GPUs to train a variant of the Google Neural Machine Translator just on the English to French translation task.
In this exercise you will define a similar but much simpler encoder-decoder based neural machine translator model. Specifically, you will use the previously defined inputs and outputs and define a Keras Model object and compile the model with a given loss function and an optimizer.
Here you are provided with en_inputs
(encoder input layer), en_out
and en_state
(encoder GRU output), de_out
(decoder GRU output) and de_pred
(decoder prediction) that you previously defined.

This exercise is part of the course
Machine Translation with Keras
Exercise instructions
- Define a Keras
Model
which takes in theen_inputs
as inputs and the decoder predictions (de_pred
) as the output. - Compile the defined model by calling
<model>.compile
with the'adam'
optimizer, cross entropy loss and accuracy (acc
) as a metric. - Print the summary of the model.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
from tensorflow.keras.models import Model
# Define a model with encoder input and decoder output
nmt = ____(____=____, outputs=____)
# Compile the model with an optimizer and a loss
nmt.____(optimizer=____, ____='categorical_crossentropy', metrics=[____])
# View the summary of the model
nmt.____()