Created
February 16, 2018 11:01
-
-
Save khuangaf/e72acfc1ba28808c37b819cd7abcc363 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
item_index = { str(i):i for i in range(931)} | |
embeddings_index={} | |
f = open( 'data/item_vectors.txt') | |
for line in f: | |
values = line.split() | |
word = values[0] | |
coefs = np.asarray(values[1:], dtype='float32') | |
embeddings_index[word] = coefs | |
f.close() | |
embedding_matrix = np.zeros((max_features, embed_size)) | |
for word, i in item_index.items(): | |
if i < max_features: | |
embedding_vector = embeddings_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