approx_torch_quantile#
- ptyrad.utils.math_ops.approx_torch_quantile(t, q, sample_size=16000000)[source]#
Approximated quantile to prevent the 2^24 element (roughly 16.7M) limitation of torch.quantile as of now. See pytorch/pytorch#64947 RuntimeError: quantile() input tensor is too large Note that this approximated quantile would have some randomness.
- Parameters:
t (torch.Tensor) – Input torch tensor
q (float) – Targeted quantile number [0,1]
sample_size (int, optional) – Number of randomly selected elements used to approximate the true quantile. Defaults to 16_000_000.
- Returns:
The approximated quantile value for the input tensor
- Return type:
float