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.
Bu egzersiz
Machine Translation with Keras
kursunun bir parçasıdırEgzersiz talimatları
- Import Keras
Modelobject from themodelssubmodule. - 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
adamand the loss functioncategorical_crossentropy. - Print the summary of the model.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
# 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.____()