快捷方式

torch.nanquantile

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

這是 torch.quantile() 的一個變體,它“忽略” NaN 值,計算分位數 q 時就像 input 中不存在 NaN 值一樣。如果某個被縮減的行中的所有值都是 NaN,則該縮減的分位數將為 NaN。請參閱 torch.quantile() 的文件。

引數
  • input (Tensor) – 輸入張量。

  • q (floatTensor) – 範圍在 [0, 1] 內的標量或一維張量,表示分位數

  • dim (int) – 要縮減的維度。

  • keepdim (bool) – 輸出張量是否保留 dim

關鍵字引數
  • interpolation (str) – 當所需分位數位於兩個資料點之間時使用的插值方法。可以是 linear(線性)、lower(較低)、higher(較高)、midpoint(中點)和 nearest(最近)。預設值為 linear

  • out (Tensor, 可選) – 輸出張量。

示例

>>> 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])

文件

訪問 PyTorch 的全面開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲取解答

檢視資源