mindspore.ops.log2
- mindspore.ops.log2(x)[source]
Returns a new tensor with the logarithm to the base 2 of the elements of input.
\[y_i = log_2(x_i)\]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. If the input value of operator Log2 is less than or equal to 0, it will not raise Error.
Note
The dimension of the input Tensor on Ascend should be less than or equal to 8, and the dimension of the input Tensor on the CPU or GPU should be less than 8.
- Parameters
x (Tensor) – Input Tensor of any dimension. The value must be greater than 0.
- Returns
Tensor, has the same shape and dtype as the x.
- Raises
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> x = Tensor(np.array([2, 4, 8]).astype(np.float16)) >>> output = ops.log2(x) >>> print(output) [1. 2. 3.]