-
add one more import:
from torch.nn import Parameter
-
At In[16] and In[17], in case you don't have the preprocessed pkl files. (guess you won't)
def loadGloveModel(gloveFile):
print "Loading Glove Model"
f = open(gloveFile,'r')
model = {}
for line in f:
splitLine = line.split()
word = splitLine[0]
embedding = np.array([float(val) for val in splitLine[1:]], dtype='f')
model[word] = embedding
print "Done.",len(model)," words loaded!"
return model
gloveFile='./datasets/nlp/glove.6B.100d.txt'
en_w2v = loadGloveModel(gloveFile)
dim_en_vec = 100
n_en_vec = len(en_w2v)
add one more import:
from torch.nn import Parameter
At In[16] and In[17], in case you don't have the preprocessed pkl files. (guess you won't)
def loadGloveModel(gloveFile):
print "Loading Glove Model"
f = open(gloveFile,'r')
model = {}
for line in f:
splitLine = line.split()
word = splitLine[0]
embedding = np.array([float(val) for val in splitLine[1:]], dtype='f')
model[word] = embedding
print "Done.",len(model)," words loaded!"
return model
gloveFile='./datasets/nlp/glove.6B.100d.txt'
en_w2v = loadGloveModel(gloveFile)
dim_en_vec = 100
n_en_vec = len(en_w2v)