Skip to content

Commit

Permalink
Merge pull request #5 from piotrgrudzien/master
Browse files Browse the repository at this point in the history
Numeric underflow causing NaNs in the output
  • Loading branch information
karpathy committed Oct 24, 2016
2 parents 2d62a1c + 6921834 commit 13ece5d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Binary file added .DS_Store
Binary file not shown.
6 changes: 5 additions & 1 deletion tsne.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ var tsnejs = tsnejs || { REVISION: 'ALPHA' };
// normalize p and compute entropy
var Hhere = 0.0;
for(var j=0;j<N;j++) {
var pj = prow[j] / psum;
if(psum == 0) {
var pj = 0;
} else {
var pj = prow[j] / psum;
}
prow[j] = pj;
if(pj > 1e-7) Hhere -= pj * Math.log(pj);
}
Expand Down

0 comments on commit 13ece5d

Please sign in to comment.