26 Chapter 16, Deep Learning
b. The arrays y_train and X_test are one-dimensional arrays containing 1s and
0s, indicating whether each review is positive or negative.
c. Based on the outputs from the snippets in Part (a), X_train and X_test appear
to be one-dimensional. However, their elements actually are lists of integers, each
representing one review’s contents, as shown in the code below:
[8]: %pprint
[8]: Pretty printing has been turned OFF
[9]: X_train[123]
[9]: [1, 307, 5, 1301, 20, 1026, 2511, 87, 2775, 52, 116,
5, 31, 7, 4, 91, 1220, 102, 13, 28, 110, 11, 6, 137, 13,
115, 219, 141, 35, 221, 956, 54, 13, 16, 11, 2714, 61, 322,
423, 12, 38, 76, 59, 1803, 72, 8, 2, 23, 5, 967, 12, 38,
85, 62, 358, 99]
d. All of the above statements are true:
16.9 Q6: Which of the following statements a), b) or c) is false?
a. Because IMDb movie reviews are numerically encoded in the dataset bundled
with Keras, to view their original text, you need to know the word to which each
number corresponds.
b. Keras’s IMDb dataset provides a dictionary that maps the words to their in-
dexes. Each word’s corresponding value is its frequency ranking among all the
words in the entire set of reviews.
c. In the dictionary mentioned in Part (b), the word with the ranking 1 is the most
frequently occurring word (calculated by the Keras team from the dataset), the
word with ranking 2 is the second most frequently occurring word, and so on.
Though the dictionary values begin with 1 as the most frequently occurring word,
in each encoded review, the ranking values are offset by 3. So any review contain–
ing the most frequently occurring word will have the value 4 wherever that word
appears in the review.
d. All of the above statements are true.
16.9 Q7: Which of the following statements a), b) or c) is false regarding decoding
IMDb movie reviews?