log2¶
Log2激活函数(计算底为2的对数)
\[\begin{split}\\Out=log_2x\\\end{split}\]
参数¶
x (Tensor) – 该OP的输入为Tensor。数据类型为float32,float64。
name (str,可选) – 该参数供开发人员打印调试信息时使用,具体用法请参见 Name ,默认值为None。
返回¶
Tensor,Log2算子底为2对数输出,数据类型与输入一致。
代码示例¶
import paddle
# example 1: x is a float
x_i = paddle.to_tensor([[1.0], [2.0]])
res = paddle.log2(x_i)
print(res) # [[0.], [1.0]]
# example 2: x is float32
x_i = paddle.full(shape=[1], fill_value=2, dtype='float32')
res = paddle.log2(x_i)
print(res) # [1.]
# example 3: x is float64
x_i = paddle.full(shape=[1], fill_value=2, dtype='float64')
res = paddle.log2(x_i)
print(res) # [1.]