Skip to content

Commit 0bcfd44

Browse files
Merge pull request #30 from shawn-jung/patch-1
Adding small numbers to feature counter to avoid ZeroDivisionError
2 parents 54fcf42 + f8d9dce commit 0bcfd44

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Ch4/03_Word2Vec_Example.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
" feats = []\n",
211211
" for tokens in list_of_lists:\n",
212212
" feat_for_this = np.zeros(DIMENSION)\n",
213-
" count_for_this = 0\n",
213+
" count_for_this = 0 + 1e-5 # to avoid divide-by-zero \n",
214214
" for token in tokens:\n",
215215
" if token in w2v_model:\n",
216216
" feat_for_this += w2v_model[token]\n",

0 commit comments

Comments
 (0)