mindspore.ops.fmod

查看源文件
mindspore.ops.fmod(input, other)[源代码]

逐元素计算第一个输入除以第二个输入的余数。

支持广播、类型提升。

out=inputnother

其中 ninput/other 结果中的整数部分。 返回值的符号和 input 相同,在数值上小于 other

参数:
  • input (Union[Tensor, Number]) - 被除数。

  • other (Union[Tensor, Number]) - 除数。

返回:

Tensor

支持平台:

Ascend GPU CPU

样例:

>>> import mindspore
>>> # case 1: When other is scalar:
>>> input = mindspore.tensor([-3., -2, -1, 3, 4, 5])
>>> output = mindspore.ops.fmod(input, 2)
>>> print(output)
[-1.  0. -1.  1.  0.  1.]
>>>
>>> # case 2: When other is a tensor:
>>> other = mindspore.tensor([-1., 1, 2, 2.5, 1.5, 1.7])
>>> output = mindspore.ops.fmod(input, other)
>>> print(output)
[ 0.   0.  -1.   1.   0.5  1.3]