oneflow.frac

oneflow.frac()

frac(input) → Tensor

Computes the fractional portion of each element in input.

\[\text{out}_{i} = \text{input}_{i} - \left\lfloor |\text{input}_{i}| \right\rfloor * \operatorname{sgn}(\text{input}_{i})\]
Parameters

input – The input Tensor.

Returns

The fractional part of the argument.

Return type

Tensor

For example:

>>> import oneflow as flow
>>> flow.frac(flow.Tensor([1, 2.50, -3.21]))
tensor([ 0.0000,  0.5000, -0.2100], dtype=oneflow.float32)