Skip to content

Commit

Permalink
Merge pull request torch#434 from Moodstocks/multinomial_precision
Browse files Browse the repository at this point in the history
Use proper precision for accumulators in multinomial
  • Loading branch information
andresy committed Oct 27, 2015
2 parents fa6070c + 3e6130a commit 7157edc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/TH/generic/THTensorRandom.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void THTensor_(multinomial)(THLongTensor *self, THGenerator *_generator, THTenso
for (i=0; i<n_dist; i++)
{
/* Get normalized cumulative distribution from prob distribution */
real sum = 0;
accreal sum = 0;
for (j=0; j<n_categories; j++)
{
sum += THStorage_(get)( \
Expand Down Expand Up @@ -160,7 +160,7 @@ void THTensor_(multinomial)(THLongTensor *self, THGenerator *_generator, THTenso
/* update cumulative distribution so that sample cannot be drawn again */
real diff;
real new_val = 0;
real sum;
accreal sum;

if (sample_idx != 0)
{
Expand Down

0 comments on commit 7157edc

Please sign in to comment.