Session Ready
Exercise

Part 1: Text reversing model - Encoder

Creating a simple text reversing model is a great method to understand the mechanics of encoder decoder models and how they connect. You will now implement the encoder part of a text reversing model.

The implementation of the encoder has been split over two exercises. In this exercise, you will be defining the words2onehot() helper function. The words2onehot() function should take in a list of words and a dictionary word2index and convert the list of words to an array of one-hot vectors. The word2index dictionary is available in the workspace.

Instructions
100 XP
  • Convert words to IDs using the word2index dictionary in the words2onehot() function
  • Convert word IDs to onehot vectors having length 3 (using the num_classes argument) and return the resulting array.
  • Call the words2onehot() function with the words I, like and cats and assign the result to onehot.
  • Print the words and their corresponding onehot vectors using print() and zip() functions. The zip() function allows you to iterate multiple lists at the same time.