sqrt_

Documentation

treetensor.torch.sqrt_(input)[source]

In-place version of sqrt().

Examples:

>>> import torch
>>> import treetensor.torch as ttorch
>>> t = ttorch.tensor([-4.0, -1.0, 0, 2.0, 4.8, 8.0])
>>> ttorch.sqrt_(t)
>>> t
tensor([   nan,    nan, 0.0000, 1.4142, 2.1909, 2.8284])

>>> t = ttorch.tensor({
...     'a': [-4.0, -1.0, 0, 2.0, 4.8, 8.0],
...     'b': {'x': [[-2.0, 1.2, 0.25],
...                 [16.0, 3.75, -2.34]]},
... })
>>> ttorch.sqrt_(t)
>>> t
<Tensor 0x7ff90a4b0af0>
├── a --> tensor([   nan,    nan, 0.0000, 1.4142, 2.1909, 2.8284])
└── b --> <Tensor 0x7ff90a4b04f0>
    └── x --> tensor([[   nan, 1.0954, 0.5000],
                      [4.0000, 1.9365,    nan]])

Torch Version Related

This documentation is based on torch.sqrt_ in torch v2.0.1+cu117. 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__)'