MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Machine Translation with Keras

Lihat Kursus

Petunjuk latihan

  • 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.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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.____()
Edit dan Jalankan Kode