_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: api_fluid_layers_exp

tanh

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

API Reference: api_fluid_layers_tanh

sqrt

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

API Reference: api_fluid_layers_sqrt

abs

For the input Tensor, take the elementwise absolute value.

API Reference: api_fluid_layers_abs

ceil

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

API Reference: api_fluid_layers_ceil

floor

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

API Reference: api_fluid_layers_floor

sin

For the input Tensor, take the elementwise sin value.

API Reference: api_fluid_layers_sin

cos

For input Tensor, take the elementwise cosine value.

API Reference: api_fluid_layers_cos

cosh

For input Tensor, take the elementwise hyperbolic cosine value.

API Reference: api_fluid_layers_cosh

round

Rounding the input Tensor in elementwise order.

API Reference: api_fluid_layers_round

square

Square the input Tensor in elementwise order.

API Reference: api_fluid_layers_square

reciprocal

For the input Tensor, take the reciprocal in elementwise order.

API Reference: api_fluid_layers_reciprocal

reduce

For the input Tensor, it performs reduce operations on the specified axes, including: min, max, sum, mean, product

API Reference: api_fluid_layers_reduce_min api_fluid_layers_reduce_max fluid_layers_reduce_sum api_fluid_layers_reduce_mean api_fluid_layers_reduce_prod

Binary operation

elementwise_add

Add two Tensor in elementwise order, and the corresponding math operator is + .

API Reference: api_fluid_layers_elementwise_add

elementwise_sub

Sub two Tensor in elementwise order, the corresponding math operator is - .

API Reference: api_fluid_layers_elementwise_sub

elementwise_mul

Multiply two Tensor in elementwise order, and the corresponding math operator is * .

API Reference: api_fluid_layers_elementwise_mul

elementwise_div

Divide two Tensor in elementwise order, and the corresponding math operator is / or // .

API Reference: api_fluid_layers_elementwise_div

elementwise_pow

Do power operations on two Tensor in elementwise order, and the corresponding math operator is ** .

API Reference: api_fluid_layers_elementwise_pow

equal

Judge whether the two Tensor elements are equal, and the corresponding math operator is == .

API Reference: api_fluid_layers_equal

less_than

Judge whether the two Tensor elements satisfy the ‘less than’ relationship, and the corresponding math operator is < .

API Reference: api_fluid_layers_less_than

sum

Add two Tensor in elementwise order.

API Reference: api_fluid_layers_sum

elementwise_min

Perform min(x, y) operations on two Tensor in elementwise order .

API Reference: api_fluid_layers_elementwise_min

elementwise_max

Perform max(x, y) operations on two Tensor in elementwise order .

API Reference: api_fluid_layers_elementwise_max

matmul

Perform matrix multiplication operations on two Tensor.

API Reference: api_fluid_layers_matmul