maxframe.tensor.modf#

maxframe.tensor.modf(x, out1=None, out2=None, out=None, where=None, **kwargs)[源代码]#

返回张量的分数部分和整数部分,按元素计算。

如果给定数字为负数,则分数部分和整数部分也为负数。

参数:
  • x (array_like) -- 输入张量。

  • out (Tensor, None, or tuple of Tensor and None, optional) -- 用于存储结果的位置。如果提供,其形状必须与输入广播一致。如果未提供或为 None,则返回一个新分配的张量。元组(仅可作为关键字参数)的长度必须等于输出的数量。

  • where (array_like, optional) -- 值为 True 表示在该位置计算 ufunc,值为 False 表示保留输出中的值不变。

  • **kwargs

返回:

  • y1 (Tensor) -- x 的分数部分。

  • y2 (Tensor) -- x 的整数部分。

备注

对于整数输入,返回值为浮点数。

参见

divmod

divmod(x, 1) 等价于 modf,但返回值顺序相反,且余数始终为正。

示例

>>> import maxframe.tensor as mt
>>> mt.modf([0, 3.5]).execute()
(array([ 0. ,  0.5]), array([ 0.,  3.]))
>>> mt.modf(-0.5).execute()
(-0.5, -0)