log¶
Documentation¶
-
treetensor.torch.
log
(input, *args, **kwargs)[source]¶ Returns a new tensor with the natural logarithm of the elements of
input
.Examples:
>>> import torch >>> import treetensor.torch as ttorch >>> ttorch.log(ttorch.tensor([-4.0, -1.0, 0, 2.0, 4.8, 8.0])) tensor([ nan, nan, -inf, 0.6931, 1.5686, 2.0794]) >>> ttorch.log(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]]}, ... })) <Tensor 0x7ff90a4c9ca0> ├── a --> tensor([ nan, nan, -inf, 0.6931, 1.5686, 2.0794]) └── b --> <Tensor 0x7ff90a4c9e50> └── x --> tensor([[ nan, 0.1823, -1.3863], [ 2.7726, 1.3218, nan]])
Torch Version Related
This documentation is based on torch.log 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.
Description From Torch v1.9.0+cu102¶
-
torch.
log
(input, *, out=None) → Tensor¶ Returns a new tensor with the natural logarithm of the elements of
input
.\[y_{i} = \log_{e} (x_{i})\]- Args:
input (Tensor): the input tensor.
- Keyword args:
out (Tensor, optional): the output tensor.
Example:
>>> a = torch.randn(5) >>> a tensor([-0.7168, -0.5471, -0.8933, -1.4428, -0.1190]) >>> torch.log(a) tensor([ nan, nan, nan, nan, nan])