mindspore2022/docs/api/api_python/ops/mindspore.ops.ScatterSub.rst

34 lines
1.7 KiB
ReStructuredText
Raw 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.ScatterSub
=========================
.. py:class:: mindspore.ops.ScatterSub(use_locking=False)
使用给定更新值通过减法操作和输入索引来更新Tensor值。此操作在更新完成后输出数据 ,这有利于更加方便地使用更新后的值。
对于每个在 `indices.shape` 中的 `i, ..., j`
.. math::
\text{input_x}[\text{indices}[i, ..., j], :]\mathrel{-}= \text{updates}[i, ..., j, :]
输入的 `input_x``updates` 遵循隐式类型转换规则以确保数据类型一致。如果它们具有不同的数据类型则优先级低的数据类型将转换为优先级相对最高的数据类型。当需要转换Parameter的数据类型时会抛出RuntimeError异常。
**参数:**
- **use_locking** (bool) - 表示是否使用锁来保护。默认值False。
**输入:**
- **input_x** (Parameter) - ScatterSub的输入任意维度的Parameter。
- **indices** (Tensor) - 指定相减操作的索引其数据类型必须为mindspore.int32。
- **updates** (Tensor) - 指定与 `input_x` 相减的Tensor其数据类型与 `input_x` 的相同shape为 `indices_shape + x_shape[1:]`
**输出:**
Tensor表示更新后的 `input_x` 其shape和数据类型与 `input_x` 的相同。
**异常:**
- **TypeError** - `use_locking` 不是bool。
- **TypeError** - `indices` 不是int32。
- **ValueError** - `updates` 的shape不是 `indices_shape + x_shape[1:]`
- **RuntimeError** - 当 `input_x``updates` 类型不一致,需要进行类型转换时,如果 `updates` 不支持转成参数 `input_x` 需要的数据类型,就会报错。