Skip to content

Instantly share code, notes, and snippets.

@shreydesai
Created February 17, 2019 20:08
Show Gist options
  • Save shreydesai/82d52cdabb995872c9de4ac87cfd1712 to your computer and use it in GitHub Desktop.
Save shreydesai/82d52cdabb995872c9de4ac87cfd1712 to your computer and use it in GitHub Desktop.
Loading GloVe vectors
import pickle
import numpy as np
# load embeddings
glove = np.loadtxt('glove.6B.300d.txt', dtype='str', comments=None)
words = {w:i for i,w in enumerate(glove[:,0])}
vecs = glove[:,1:].astype('float')
# cache embeddings
pickle.dump((words, vecs), open('glove', 'wb'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment