Pytorch Torch Abs
# PyTorch torch.abs Function
* * Pytorch torch reference manual](#)
`torch.abs` is a function in PyTorch used to compute the absolute value of a tensor.
### Function Definition
torch.abs(input, out=None)
* * *
## Usage Example
## Example
import torch
# Create a tensor containing negative numbers
x = torch.tensor([-1, -2, 3, -4])
# Compute the absolute value
y = torch.abs(x)
print(y)
Output:
tensor([1, 2, 3, 4])
* * Pytorch torch reference manual](#)
YouTip