Session Ready
Exercise

Defining the decoder

In this exercise, you will implement the decoder and define an end-to-end model going from encoder inputs to the decoder GRU outputs. The decoder uses the same model as the encoder. However there are differences in the inputs and states fed to the decoder, compared to the encoder. For example, the decoder consumes the context vector produced by the encoder as inputs as well as the initial state to the decoder.

To implement the decoder you will use RepeatVector and GRU layers.

For this exercise you have been provided with the encoder model and the various layers of the encoder that you have already implemented. For example, the encoder inputs are provided as en_inputs and the context vector as en_state. Also note that the GRU and Model objects have been already imported.

Instructions
100 XP
  • Define an RepeatVector layer that takes en_state as an input and repeats it fr_len times.
  • Define a GRU layer, decoder_gru, which has hidden units equal to hsize and returns all the outputs produced.
  • Get the output of the decoder_gru layer by feeding in de_inputs as the input and en_state as the initial state of the decoder.
  • Define a model that takes en_inputs as the input and gru_outputs as the output.