when i want to use torch.median(), i found that the median of even number of data point is not as expected
why col_medians is not tensor([2.5, 4.5, 3.5, 5.5])
the version of torch is 2.8.0+cu128.
when i want to use torch.median(), i found that the median of even number of data point is not as expected
why col_medians is not tensor([2.5, 4.5, 3.5, 5.5])
the version of torch is 2.8.0+cu128.
From the docs:
The median is not unique for
inputtensors with an even number of elements in the dimensiondim. In this case the lower of the two medians is returned. To compute the mean of both medians ininput, usetorch.quantile()withq=0.5instead.