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.
Bu egzersiz
Machine Translation with Keras
kursunun bir parçasıdırEgzersiz talimatları
- Define a Keras
Modelwhich takes in theen_inputsas inputs and the decoder predictions (de_pred) as the output. - Compile the defined model by calling
<model>.compilewith the'adam'optimizer, cross entropy loss and accuracy (acc) as a metric. - Print the summary of the model.
Uygulamalı interaktif egzersiz
Bu örnek kodu tamamlayarak bu egzersizi bitirin.
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.____()