PyTorch torch.negative function


Pytorch torch 参考手册Pytorch torch Reference Manual

torch.negativeis a function in PyTorch used for element-wise negation, andtorch.neghas the same functionality.

Function definition

torch.negative(input, out=None)

Usage example

Example

import torch

# Element-wise negation
x = torch.tensor([1.0, 2.0, 3.0])
result = torch.negative(x)
print(result)

Pytorch torch 参考手册Pytorch torch Reference Manual

Other extensions