torch.neg¶ torch.neg(input, *, out=None) → Tensor¶ 返回一個新張量,其元素是 input 張量元素的負值。 out=−1×input\text{out} = -1 \times \text{input} out=−1×input 引數 input (Tensor) – 輸入張量。 關鍵字引數 out (Tensor, 可選) – 輸出張量。 示例 >>> a = torch.randn(5) >>> a tensor([ 0.0090, -0.2262, -0.0682, -0.2866, 0.3940]) >>> torch.neg(a) tensor([-0.0090, 0.2262, 0.0682, 0.2866, -0.3940])