Table of Contents
Shortcuts

# torch.nanquantile

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

  This is a variant of `torch.quantile()` that “ignores” `NaN` values, computing the quantiles `q` as if `NaN` values in `input` did not exist. If all values in a reduced row are `NaN` then the quantiles for that reduction will be `NaN`. See the documentation for `torch.quantile()`.

  Parameters:

    - input (Tensor) – the input tensor.

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

    - dim (int) – the dimension to reduce.

    - keepdim (bool) – whether the output tensor has `dim` retained or not.

  Keyword Arguments:

    - interpolation (str) – interpolation method to use when the desired quantile lies between two data points. Can be `linear`, `lower`, `higher`, `midpoint` and `nearest`. Default is `linear`.

    - 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]])
      >>> t
      tensor([[nan, nan],
              [1., 2.]])
      >>> t.nanquantile(0.5, dim=0)
      tensor([1., 2.])
      >>> t.nanquantile(0.5, dim=1)
      tensor([   nan, 1.5000])

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.