Defining the Teacher Forcing model
With all the layers created, the next step would be to define a Keras Model
object. This model is slightly different to the one that you defined earlier, as the new model has two input layers.
You have been provided with the Keras layers that you implemented in the last exercise including en_inputs
, en_gru
, de_inputs
, de_gru
and de_pred
.
This exercise is part of the course
Machine Translation with Keras
Exercise instructions
- Import Keras
Model
object from themodels
submodule. - Define a model that takes the encoder input layer and decoder input layer as inputs (in that order) and outputs the final prediction.
- Compile the model using the optimizer
adam
and the loss functioncategorical_crossentropy
. - Print the summary of the model.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import the Keras Model object
from tensorflow.keras.____ import ____
# Define a model
nmt_tf = ____(inputs=[____, ____], outputs=____)
# Compile the model with optimizer and loss
nmt_tf.compile(optimizer=____, ____=____, metrics=["acc"])
# Print the summary of the model
nmt_tf.____()