mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
histogram correctly calculated for tensors where all elements are same.
This commit is contained in:
@ -1145,6 +1145,11 @@ void THTensor_(histc)(THTensor *hist, THTensor *tensor, long nbins, real minvalu
|
||||
minval = THTensor_(minall)(tensor);
|
||||
maxval = THTensor_(maxall)(tensor);
|
||||
}
|
||||
if (minval == maxval)
|
||||
{
|
||||
minval = minval - 1;
|
||||
maxval = maxval + 1;
|
||||
}
|
||||
real bins = (real)(nbins)-1e-6;
|
||||
|
||||
THTensor *clone = THTensor_(newWithSize1d)(THTensor_(nElement)(tensor));
|
||||
|
Reference in New Issue
Block a user