mindspore.ops.frac

View Source On Gitee
mindspore.ops.frac(x)[source]

Calculates the fractional part of each element in the input

Parameters

x (Tensor) – x is a tensor.

Returns

Tensor, has the same shape and type as input.

Raises

TypeError – If x is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> from mindspore import Tensor
>>> from mindspore import dtype as mstype
>>> from mindspore import ops
>>> x = Tensor([2, 4.2, -2.5], mstype.float16)
>>> output = ops.frac(x)
>>> print(output)
[ 0.      0.1992 -0.5   ]