mindspore.mint.log2
- mindspore.mint.log2(input)[source]
Returns the logarithm to the base 2 of a tensor element-wise.
Warning
If the input value of operator Log2 is within the range (0, 0.01] or [0.95, 1.05], the output accuracy may be affacted.
- Parameters
input (Tensor) – Input Tensor of any dimension. The value must be greater than 0.
- Returns
Tensor, has the same shape as the input. If input.dtype is of integer or boolean type, the output dtype will be float32. Otherwise, the output dtype will be the same as input.dtype.
- Raises
TypeError – If input is not a Tensor.
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> import numpy as np >>> from mindspore import Tensor, mint >>> x = Tensor(np.array([3.0, 5.0, 7.0]), mindspore.float32) >>> output = mint.log2(x) >>> print(output) [1.5849625 2.321928 2.807355 ]