mindspore.ops.minimum
- mindspore.ops.minimum(input, other)[源代码]
逐元素计算两个输入tensor的最小值。
说明
输入 input 和 other 遵循隐式类型转换规则,使数据类型保持一致。
当输入是两个Tensor时,它们的数据类型不能同时是bool。
当输入是一个Tensor和一个Scalar时,Scalar只能是一个常数。
支持广播操作。
当一个元素与NaN比较时,将返回NaN。
- 参数:
input (Union[Tensor, Number, bool]) - 第一个输入。
other (Union[Tensor, Number, bool]) - 第二个输入。
- 返回:
Tensor
- 支持平台:
Ascend
GPU
CPU
样例:
>>> import mindspore >>> # case 1 : same data type >>> input = mindspore.tensor([1.0, 5.0, 3.0], mindspore.float32) >>> other = mindspore.tensor([4.0, 2.0, 6.0], mindspore.float32) >>> mindspore.ops.minimum(input, other) Tensor(shape=[3], dtype=Float32, value= [ 1.00000000e+00, 2.00000000e+00, 3.00000000e+00]) >>> >>> # case 2 : the data type is the one with higher precision or higher digits among the two inputs. >>> input = mindspore.tensor([1.0, 5.0, 3.0], mindspore.int64) >>> other = mindspore.tensor([4.0, 2.0, 6.0], mindspore.float64) >>> mindspore.ops.minimum(input, other) Tensor(shape=[3], dtype=Float64, value= [ 1.00000000e+00, 2.00000000e+00, 3.00000000e+00])