torch.quantile
-
torch.quantile(input, q) → Tensor -
Returns the q-th quantiles of all elements in the
inputtensor, doing a linear interpolation when the q-th quantile lies between two data points.- Parameters
Example:
>>> a = torch.randn(1, 3) >>> a tensor([[ 0.0700, -0.5446, 0.9214]]) >>> q = torch.tensor([0, 0.5, 1]) >>> torch.quantile(a, q) tensor([-0.5446, 0.0700, 0.9214])
-
torch.quantile(input, q, dim=None, keepdim=False, *, out=None) → Tensor
Returns the q-th quantiles of each row of the
inputtensor along the dimensiondim, doing a linear interpolation when the q-th quantile lies between two data points. By default,dimisNoneresulting in theinputtensor being flattened before computation.If
keepdimisTrue, the output dimensions are of the same size asinputexcept in the dimensions being reduced (dimor all ifdimisNone) where they have size 1. Otherwise, the dimensions being reduced are squeezed (seetorch.squeeze()). Ifqis a 1D tensor, an extra dimension is prepended to the output tensor with the same size asqwhich represents the quantiles.- Parameters
- Keyword Arguments
-
out (Tensor, optional) – the output tensor.
Example:
>>> a = torch.randn(2, 3) >>> a tensor([[ 0.0795, -1.2117, 0.9765], [ 1.1707, 0.6706, 0.4884]]) >>> q = torch.tensor([0.25, 0.5, 0.75]) >>> torch.quantile(a, q, dim=1, keepdim=True) tensor([[[-0.5661], [ 0.5795]], [[ 0.0795], [ 0.6706]], [[ 0.5280], [ 0.9206]]]) >>> torch.quantile(a, q, dim=1, keepdim=True).shape torch.Size([3, 2, 1])
© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.quantile.html