Rate this Page
โ˜… โ˜… โ˜… โ˜… โ˜…

torch.abs#

torch.abs(input: Tensor, *, out: Optional[Tensor]) โ†’ Tensor#

Computes the absolute value of each element in input.

outi=โˆฃinputiโˆฃ\text{out}_{i} = |\text{input}_{i}|
Parameters

input (Tensor) โ€“ the input tensor.

Keyword Arguments

out (Tensor, optional) โ€“ the output tensor.

Example:

>>> torch.abs(torch.tensor([-1, -2, 3]))
tensor([ 1,  2,  3])