_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

exp

Perform an exp operation on each input Tensor element.

API Reference: exp

tanh

For the input Tensor, take the tanh value of each element.

API Reference: tanh

sqrt

For the input Tensor, take the square root of each element.

API Reference: sqrt

abs

For the input Tensor, take the elementwise absolute value.

API Reference: abs

ceil

Round up each input Tensor element to the nearest greater integer.

API Reference: ceil

floor

Round down each input Tensor element to the nearest less integer.

API Reference: floor

sin

For the input Tensor, take the elementwise sin value.

API Reference: sin

cos

For input Tensor, take the elementwise cosine value.

API Reference: cos

round

Rounding the input Tensor in elementwise order.

API Reference: round

square

Square the input Tensor in elementwise order.

API Reference: square

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

sum

Add two Tensor in elementwise order.

API Reference: sum

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

matmul

Perform matrix multiplication operations on two Tensor.

API Reference: matmul