Skip to content

Instantly share code, notes, and snippets.

@roopalgarg
Last active March 15, 2017 23:52
Show Gist options
  • Save roopalgarg/d60322192c8682a91cb95640c2a04b3b to your computer and use it in GitHub Desktop.
Save roopalgarg/d60322192c8682a91cb95640c2a04b3b to your computer and use it in GitHub Desktop.
Loading glove vectors
#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