File tree Expand file tree Collapse file tree 3 files changed +104
-4
lines changed
Expand file tree Collapse file tree 3 files changed +104
-4
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ def train_glove(args):
8686 j = Variable (torch .LongTensor ([i ]))
8787 vec = (model .l_vecs (j ) + model .r_vecs (j )).data .squeeze ()
8888 for k in range (vec .size (0 )):
89- s + ' ' + str (vec [k ])
89+ s += ' ' + str (round ( vec [k ], 6 ) )
9090
9191 f .write (s )
9292
Original file line number Diff line number Diff line change 77
88
99def print_nearest_words (args ):
10- word = args .word .lower ()
10+ word = args .word .lower (). strip ()
1111
1212 # Load the word vectors
1313 embeddings_index = {}
@@ -19,8 +19,8 @@ def print_nearest_words(args):
1919 embeddings_index [w ] = coefs
2020 f .close ()
2121
22- w_v = np .zeros ( 50 )
23- for w in word .strip (). split ():
22+ w_v = np .zeros_like ( embeddings_index [ w ] )
23+ for w in word .split ():
2424 if w not in embeddings_index .keys ():
2525 continue
2626
You can’t perform that action at this time.
0 commit comments