_api_guide_math_en:
Mathematical operation¶
Paddle provides a wealth of mathematical operations. The mathematical operations listed below are all elementwise operations on the target tensor. If the two inputs of the binary operations have different shapes, they will be processed first by broadcast
. Some mathematical operations also support mathematical operators, such as: +
, -
, *
, /
, etc. Math operators not only support tensors but also scalars.
Unary operation¶
reciprocal¶
For the input Tensor
, take the reciprocal in elementwise order.
API Reference: reciprocal
reduce¶
For the input Tensor
, it performs reduce operations on the specified axes, including: min, max, sum, mean, product
API Reference: reduce_min reduce_max fluid_layers_reduce_sum reduce_mean reduce_prod
Binary operation¶
elementwise_add¶
Add two Tensor
in elementwise order, and the corresponding math operator is +
.
API Reference: elementwise_add
elementwise_sub¶
Sub two Tensor
in elementwise order, the corresponding math operator is -
.
API Reference: elementwise_sub
elementwise_mul¶
Multiply two Tensor
in elementwise order, and the corresponding math operator is *
.
API Reference: elementwise_mul
elementwise_div¶
Divide two Tensor
in elementwise order, and the corresponding math operator is /
or //
.
API Reference: elementwise_div
elementwise_pow¶
Do power operations on two Tensor
in elementwise order, and the corresponding math operator is **
.
API Reference: elementwise_pow
equal¶
Judge whether the two Tensor
elements are equal, and the corresponding math operator is ==
.
API Reference: equal
less_than¶
Judge whether the two Tensor
elements satisfy the ‘less than’ relationship, and the corresponding math operator is <
.
API Reference: less_than
elementwise_min¶
Perform min(x, y)
operations on two Tensor
in elementwise order .
API Reference: elementwise_min
elementwise_max¶
Perform max(x, y)
operations on two Tensor
in elementwise order .
API Reference: elementwise_max