Skip to content

Commit

Permalink
Fixed potential 0/0 errors causing NaN in the output
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrgrudzien committed Oct 22, 2016
1 parent 2d62a1c commit 4be77e8
Showing 1 changed file with 5 additions and 1 deletion.
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 4be77e8

Please sign in to comment.