1. Learn
  2. /
  3. Courses
  4. /
  5. Machine Translation with Keras

Exercise

Preprocessing data

You now need to process the data for our new model which has two inputs and a single output. The two inputs are, the one-hot encoded English words and one-hot encoded French words excluding the last word.

The output would be the one-hot encoded French words excluding the first word. In other words, in the decoder, each input French word has an output, which is the next word. Here you will learn how to implement that.

You have been provided with the sents2seqs() function, en_text and fr_text.

Instructions

100 XP
  • Obtain a batch of encoder inputs (from i to i+bsize) using the sents2seqs() function (onehot encoded and reversed).
  • Obtain a batch of decoder inputs and outputs (from i to i+bsize) using the sents2seqs() function (onehot encoded).
  • Separate the decoder inputs (all French words except the last) from de_xy by slicing on the time dimension.
  • Separate the decoder outputs (all French words except the first) from de_xy.