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 is NaN.

  • If \(x_i\) is less than 0, the result is NaN.

  • If \(x_i\) is either +0 or -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)