Skip to content

Instantly share code, notes, and snippets.

@arshjat
Created January 1, 2019 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arshjat/14344f0753a410262e4fedccfbab8ce4 to your computer and use it in GitHub Desktop.
Save arshjat/14344f0753a410262e4fedccfbab8ce4 to your computer and use it in GitHub Desktop.
word_index = tk.word_index
nb_words = min(max_features, len(word_index))
embedding_matrix = np.zeros((nb_words + 1, embed_size))
for word, i in word_index.items():
if i >= max_features: continue
embedding_vector = embedding_index.get(word)
if embedding_vector is not None: embedding_matrix[i] = embedding_vector
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment