abs¶
Documentation¶
-
treetensor.torch.
abs
(input, *args, **kwargs)[source]¶ Computes the absolute value of each element in
input
.Examples:
>>> import torch >>> import treetensor.torch as ttorch >>> ttorch.abs(ttorch.tensor([12, 0, -3])) tensor([12, 0, 3]) >>> ttorch.abs(ttorch.tensor({ ... 'a': [12, 0, -3], ... 'b': {'x': [[-3, 1], [0, -2]]}, ... })) <Tensor 0x7f1c81d78ee0> ├── a --> tensor([12, 0, 3]) └── b --> <Tensor 0x7f1c81d78d90> └── x --> tensor([[3, 1], [0, 2]])
Torch Version Related
This documentation is based on torch.abs in torch v1.9.0+cu102. Its arguments’ arrangements depend on the version of pytorch you installed.
If some arguments listed here are not working properly, please check your pytorch’s version with the following command and find its documentation.
1 | python -c 'import torch;print(torch.__version__)' |
The arguments and keyword arguments supported in torch v1.9.0+cu102 is listed below.