21 lines
1.2 KiB
ReStructuredText
21 lines
1.2 KiB
ReStructuredText
mindspore.ops.Sub
|
||
=================
|
||
|
||
.. py:class:: mindspore.ops.Sub
|
||
|
||
逐元素用第一个输入Tensor减去第二个输入Tensor。
|
||
|
||
更多参考详见 :func:`mindspore.ops.sub`。
|
||
|
||
.. note::
|
||
- 当两个输入具有不同的shape时,它们的shape必须要能广播为一个共同的shape。
|
||
- 两个输入不能同时为bool类型。[True, Tensor(True), Tensor(np.array([True]))]等都为bool类型。
|
||
- 两个输入遵循隐式类型转换规则,使数据类型保持一致。
|
||
|
||
输入:
|
||
- **x** (Union[Tensor, number.Number, bool]) - 第一个输入,是一个number.Number、bool值或数据类型为 `number <https://www.mindspore.cn/docs/zh-CN/master/api_python/mindspore/mindspore.dtype.html#mindspore.dtype>`_ 或 `bool <https://www.mindspore.cn/docs/zh-CN/master/api_python/mindspore/mindspore.dtype.html#mindspore.dtype>`_ 的Tensor。
|
||
- **y** (Union[Tensor, number.Number, bool]) - 第二个输入,当第一个输入是Tensor时,第二个输入应该是一个number.Number或bool值,或数据类型为number或bool的Tensor。
|
||
|
||
输出:
|
||
Tensor,shape与两个输入广播后的shape相同,数据类型为两个输入中精度较高的类型。
|