Get startedGet started for free

Link between the trained and inference model

Here you will be transferring the trained weights from the trained model to the inference model. In the encoder decoder model, there are three layers with parameters. They are,

  • The encoder GRU layer
  • The decoder GRU layer
  • The decoder Dense layer

The other layers, such as TimeDistributed do not have any parameters, thus don't require the copying of weights.

For this exercise, you have been provided with the trained encoder GRU layer (tr_en_gru), trained decoder GRU (tr_de_gru) and the trained Dense layer (tr_de_dense). You also have access to all the layers of the inference model (including the encoder) such as the encoder GRU layer (en_gru), decoder GRU (de_gru) and the Dense layer (de_dense).

This exercise is part of the course

Machine Translation with Keras

View Course

Exercise instructions

  • Load the weights of the trained encoder GRU layer.
  • Set the weights of the encoder GRU layer of the inference model.
  • Load the weights for the decoder GRU layer (trained) and set the weights in the inference model.
  • Load the weights of the decoder Dense layer (trained) and set the weights in the inference model.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Load the weights to the encoder GRU from the trained model
en_gru_w = ____.get_weights()
# Set the weights of the encoder GRU of the inference model
en_gru.____(____)
# Load and set the weights to the decoder GRU
de_gru.____(tr_de_gru.____)
# Load and set the weights to the decoder Dense
____.set_weights(____.____)
Edit and Run Code