frac

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

This API is used to return the fractional portion of each element in input.

Parameters
  • x (Tensor) – The input tensor, which data type should be int32, int64, float32, float64.

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

The output Tensor of frac.

Return type

Tensor

Examples

import paddle

input = paddle.to_tensor([[12.22000003, -1.02999997],
                        [-0.54999995, 0.66000003]])
output = paddle.frac(input)
print(output)
# Tensor(shape=[2, 2], dtype=float32, place=Place(cpu), stop_gradient=True,
#        [[ 0.22000003, -0.02999997],
#         [-0.54999995,  0.66000003]])