Created
March 20, 2021 21:11
-
-
Save adamoudad/721922b0841794fa64e7f67521e9e5f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
index_offset = 3 | |
word_index = imdb.get_word_index(path="imdb_word_index.json") | |
word_index = {k: (v + index_offset) for k,v in word_index.items()} | |
word_index["<PAD>"] = 0 | |
word_index["<START>"] = 1 | |
word_index["<UNK>"] = 2 | |
word_index["<UNUSED>"] = 3 | |
index_to_word = { v: k for k, v in word_index.items()} | |
def recover_text(sample, index_to_word): | |
return ' '.join([index_to_word[i] for i in sample]) | |
recover_text(x_train[50], index_to_word) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment