Shortcuts

torch.abs

torch.abs(input, out=None) → Tensor

Computes the element-wise absolute value of the given input tensor.

outi=inputi\text{out}_{i} = |\text{input}_{i}|
Parameters
  • input (Tensor) – the input tensor.

  • out (Tensor, optional) – the output tensor.

Example:

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

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources