Exercise

Defining the embedding model

You will be defining a Keras model that:

  • Uses Embedding layers
  • Will be trained with Teacher Forcing

This model will have two embedding layers; an encoder embedding layer and a decoder embedding layer. Furthermore, as the model is trained using Teacher Forcing, it will use a sequence length of fr_len-1 in the decoder Input layer.

For this exercise, you have all the required keras.layers and Model imported. Furthermore the variables, en_len (English sequence length), fr_len (French sequence length), en_vocab (English vocabulary size), fr_vocab (French vocabulary size) and hsize (hidden size) have been defined.

Instructions

100 XP
  • Define an Input layer which accepts a sequence of word IDs.
  • Define an Embedding layer that embeds en_vocab words, has length 96 and can accept a sequence of IDs (sequence length is specified using the input_length argument).
  • Define an Embedding layer that embeds fr_vocab words, has length 96 and can accept a sequence of fr_len-1 IDs.
  • Define a model that takes an input from the encoder and an input from the decoder (in that order) and outputs the word predictions.