megengine.functional.log¶
- log(x)[源代码]¶
 Element-wise \(\operatorname{log}(x)\) function.
Calculates an approximation to the natural (base \(e\)) logarithm for each element \(x_i\) of the input tensor \(x\).
This function has domain
[+0, +infinity]and codomain[-infinity, +infinity].- 参数
 x – input tensor. Should have a floating-point data type.
- 返回
 a tensor containing the evaluated natural logarithm result for each element in \(x\). The returned tensor must have a floating-point data type determined by 类型提升规则.
Special cases
For floating-point operands,
If \(x_i\) is
NaN, the result isNaN.If \(x_i\) is less than
0, the result isNaN.If \(x_i\) is either
+0or-0, the result is-infinity.If \(x_i\) is
1, the result is+0.If \(x_i\) is
+infinity, the result is+infinity.
实际案例
>>> F.log([1, F.exp(1)]) Tensor([0. 1.], device=xpux:0)