mindspore/docs/api/api_python/ops/mindspore.ops.Sub.rst

21 lines
1.2 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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。
输出:
Tensorshape与两个输入广播后的shape相同数据类型为两个输入中精度较高的类型。