Created
February 17, 2019 20:08
-
-
Save shreydesai/82d52cdabb995872c9de4ac87cfd1712 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
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