使用Python的Keras库来学习深度学习中的二分类问题 ------ IMDB。
IMDB它包含来自互联网电影数据库的50000条严重两级分化的评论,数据集被分为用于训练的25000条评论和用于测试的25000条评论,训练集和测试集都包含50%的正面评论和50%的负面评论。
将评论解码为英文单词
用下面的代码解析第一条train_data[0]中的评论
# word_index is a dictionary mapping words to an integer index
word_index = imdb.get_word_index()
# We reverse it, mapping integer indices to words
reverse_word_index = dict([(value, key) for (key, value) in word_index.items()])
# We decode the review; note that our indices were offset by 3
# because 0, 1 and 2 are reserved indices for "padding", "start of sequence", and "unknown".
decoded_review = ' '.join([reverse_word_index.get(i - 3, '?') for i in train_data[0]])
print(decoded_review)