Exercise

Part 1: Treasure hunt

You recently won a all-paid trip to a lush tropical island. While you were wandering around, you found an ancient treasure map pointing to a great treasure, which had a few secret messages written using 1s and 0s. Having just taken this course, you instantly recognize that it is a sequence of onehot encoded vectors. You have also been lucky to find the word to index mapping to know which word refers to which ID.

Now you need to decrypt the secret message and find out what this map is saying. You have been provided with a treasure_map which is a number of sentences by number of words by onehot vector length matrix. You have also been provided with the index2word Python dictionary that maps an ID to a word.

Instructions

100 XP
  • Get the word IDs for the onehot encoded vectors in the treasure_map (onehot vector dimension is the last dimension).
  • Get the sequence length (i.e. number of time steps) from treasure_map and assign to seq_len.
  • Get the word ID in the i-th sentence at t-th position.
  • Append the String word (i.e. not the word ID) corresponding to wid to the list words.