Last active
March 15, 2017 23:52
-
-
Save roopalgarg/d60322192c8682a91cb95640c2a04b3b to your computer and use it in GitHub Desktop.
Loading glove vectors
This file contains 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
#load glove vectors | |
#download them from http://nlp.stanford.edu/data/glove.6B.zip | |
embeddings_index = {} | |
GLOVE_DIR = 'glove.6B' | |
import os | |
f = open(os.path.join(GLOVE_DIR, 'glove.6B.%id.txt' %EMBEDDING_DIM)) | |
for line in f: | |
values = line.split() | |
word = values[0] | |
coefs = np.asarray(values[1:], dtype='float32') | |
embeddings_index[word] = coefs | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment