Session Ready
Exercise

Part 2: Text reversing model - Encoder

You will now implement the rest of the encoder of the text reversing model. The encoder feeds on the one-hot vectors produced by the words2onehot() function you implemented previously.

Here you will be implementing the encoder() function. The encoder() function takes in a set of one-hot vectors and converts them to a list of word ids.

For this exercise, the words2onehot() function and the word2index dictionary (having the words We, like and dogs) have been provided.

Instructions
100 XP
  • Convert onehot to an array of word IDs using np.argmax() function and return the word IDs.
  • Define a list of words with words We, like, dogs.
  • Convert the list of words to onehot vectors using the words2onehot() function. Remember that words2onehot() takes a list of words and a Python dictionary as its arguments.
  • Get the context vector of the onehot vectors using the encoder() function.