torch.trunc¶ torch.trunc(input, *, out=None) → 张量¶ 返回一个新的张量,其中包含 input 元素的截断整数值。 对于整数输入,遵循返回输入张量副本的数组API约定。 Parameters 输入 (张量) – 输入张量。 Keyword Arguments 输出 (张量, 可选) – 输出张量。 示例: >>> a = torch.randn(4) >>> a tensor([ 3.4742, 0.5466, -0.8008, -0.9079]) >>> torch.trunc(a) tensor([ 3., 0., -0., -0.])