Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

couple of fixed to run the code #2

Open
cozec opened this issue May 21, 2017 · 0 comments
Open

couple of fixed to run the code #2

cozec opened this issue May 21, 2017 · 0 comments

Comments

@cozec
Copy link

cozec commented May 21, 2017

  1. add one more import:
    from torch.nn import Parameter

  2. 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant