Rate this Page

torch.nanquantile#

torch.nanquantile(input,q,dim=None,keepdim=False,*,interpolation='linear',out=None)Tensor#

This is a variant oftorch.quantile() that “ignores”NaN values,computing the quantilesq as ifNaN values ininput didnot exist. If all values in a reduced row areNaN then the quantiles forthat reduction will beNaN. See the documentation fortorch.quantile().

Parameters
  • input (Tensor) – the input tensor.

  • q (float orTensor) – a scalar or 1D tensor of quantile values in the range [0, 1]

  • dim (int,optional) – the dimension to reduce.IfNone, all dimensions are reduced.

  • keepdim (bool,optional) – whether the output tensor hasdim retained or not. Default:False.

Keyword Arguments
  • interpolation (str) – interpolation method to use when the desired quantile lies between two data points.Can belinear,lower,higher,midpoint andnearest.Default islinear.

  • out (Tensor,optional) – the output tensor.

Example:

>>>t=torch.tensor([float('nan'),1,2])>>>t.quantile(0.5)tensor(nan)>>>t.nanquantile(0.5)tensor(1.5000)>>>t=torch.tensor([[float('nan'),float('nan')],[1,2]])>>>ttensor([[nan, nan],        [1., 2.]])>>>t.nanquantile(0.5,dim=0)tensor([1., 2.])>>>t.nanquantile(0.5,dim=1)tensor([   nan, 1.5000])