Permalink
Browse files

Merge pull request #61 from Paczesiowa/master

optimize normalization - slight change in output (epsilon ~e-18), about 30x speedup on relevant code.
  • Loading branch information...
2 parents 6724ad2 + c17520c commit 4153583eaeeadd88212a69ab5fa61a41283ae59b @saffsd committed Jul 15, 2017
Showing with 2 additions and 1 deletion.
  1. +2 −1 langid/langid.py
View
3 langid/langid.py 100644 → 100755
@@ -212,7 +212,8 @@ def norm_probs(pd):
# Windows this causes a RuntimeWarning, so we explicitly
# suppress it.
with np.errstate(over='ignore'):
- pd = (1/np.exp(pd[None,:] - pd[:,None]).sum(1))
+ pd_exp = np.exp(pd)
+ pd = pd_exp / pd_exp.sum()
return pd
else:
def norm_probs(pd):

0 comments on commit 4153583

Please sign in to comment.