Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Machine Translation with Keras

Cursus bekijken

Oefeninstructies

  • Import Keras Model object from the models 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 function categorical_crossentropy.
  • Print the summary of the model.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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.____()
Code bewerken en uitvoeren