I have downloaded pretrained glove vector file from the internet. It is a .txt file. I am unable to load and access it. It is easy to load and access a word vector binary file u
Here's a one liner if all you want is the embedding matrix
np.loadtxt(path, usecols=range(1, dim+1), comments=None)
where path
is path to your downloaded GloVe file and dim
is the dimension of the word embedding.
If you want both the words and corresponding vectors you can do
glove = np.loadtxt(path, dtype='str', comments=None)
and seperate the words and vectors as follows
words = glove[:, 0]
vectors = glove[:, 1:].astype('float')