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