PyTorch torch.absolute Function
PyTorch torch reference manual
torch.absolute is a function in PyTorch used to compute the element-wise absolute value, the same as torch.abs in functionality.
Function definition
torch.absolute(input, out=None)
Usage examples
Example
import
torch
Create a tensor containing negative numbers
x
=
torch.
tensor
(
[
1.0
,
2.0
,
3.0
,
4.0
]
)
Compute the absolute value
result
=
torch.
absolute
(
x
)
(
result
)
The output is:
tensor([1., 2., 3., 4.])