mindspore.ops.subtract
=======================

.. image:: https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/r2.3.1/resource/_static/logo_source.svg
    :target: https://gitee.com/mindspore/mindspore/blob/r2.3.1/docs/api/api_python/ops/mindspore.ops.func_subtract.rst
    :alt: 查看源文件


.. py:function:: mindspore.ops.subtract(input, other, *, alpha=1)

    对Tensor进行逐元素的减法。

    .. math::
        output[i] = input[i] - alpha * other[i]

    参数:
        - **input** (Union[Tensor, number.Number]) - 参与减法的Tensor或者Number。
        - **other** (Union[Tensor, number.Number]) - 参与减法的Tensor或者Number。

    关键字参数:
        - **alpha** (Number) - :math:`other` 的乘数。默认值: ``1`` 。

    返回:
        Tensor,shape与广播后的shape相同,数据类型为输入中精度较高的类型。

    异常:
        - **TypeError** - `input` 或 `other` 不是Tensor、number.Number。
        - **TypeError** - `input` 和 `other` 都不是Tensor。