torch.trunc¶ torch.trunc(input, *, out=None) → Tensor¶ 返回一個新的張量,其元素為 input 的截斷整數值。 對於整數輸入,遵循 array-api 的慣例,返回輸入張量的副本。 參數 input (Tensor) – 輸入張量。 關鍵字參數 out (Tensor, optional) – 輸出張量(可選)。 範例 >>> a = torch.randn(4) >>> a tensor([ 3.4742, 0.5466, -0.8008, -0.9079]) >>> torch.trunc(a) tensor([ 3., 0., -0., -0.])