frexp

paddle. frexp ( x, name=None ) [source]

The function used to decompose a floating point number into mantissa and exponent.

Parameters
  • x (Tensor) – The input tensor, it’s data type should be float32, float64.

  • name (str, optional) – For details, please refer to Name. Generally, no setting is required. Default: None.

Returns

  • mantissa (Tensor), A mantissa Tensor. The shape and data type of mantissa tensor and exponential tensor are

    the same as those of input.

  • exponent (Tensor), A exponent Tensor. The shape and data type of mantissa tensor and exponential tensor are

    the same as those of input.

Examples

>>> import paddle

>>> x = paddle.to_tensor([[1, 2, 3, 4]], dtype="float32")
>>> mantissa, exponent = paddle.tensor.math.frexp(x)
>>> mantissa
Tensor(shape=[1, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
[[0.50000000, 0.50000000, 0.75000000, 0.50000000]])
>>> exponent
Tensor(shape=[1, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
[[1., 2., 2., 3.]])