mindspore/docs/api/api_python/ops/mindspore.ops.TensorScatter...

28 lines
2.1 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.TensorScatterUpdate
==================================
.. py:class:: mindspore.ops.TensorScatterUpdate
根据指定的更新值 `update` 和输入索引 `indices` 通过更新操作更新输出Tensor的值。此操作几乎等同于使用 :class:`mindspore.ops.ScatterNdUpdate` 但更新后的结果是返回一个新的输出Tensor而不是直接更新 `input_x`
`indices` 的rank大于等于2最后一个轴表示每个索引向量的深度。对于每个索引向量 `update` 中必须有相应的值。如果每个索引Tensor的深度与 `input_x` 的rank匹配则每个索引向量对应于 `input_x` 中的Scalar并且每次更新都会更新一个Scalar。如果每个索引Tensor的深度小于 `input_x` 的rank则每个索引向量对应于 `input_x` 中的切片,并且每次更新都会更新一个切片。
更新的顺序是不确定的,这意味着如果 `indices` 中有多个索引向量对应于同一位置,则输出中该位置值是不确定的。
.. math::
output\left [indices \right ] = update
输入:
- **input_x** (Tensor) - 任意维度的Tensor。其数据类型为数值型。 `input_x` 的维度必须不小于indices.shape[-1]。其shape为 :math:`(N, *)` ,其中 :math:`*` 为任意数量的额外维度。
- **indices** (Tensor) - `input_x` 执行scatter操作的目标索引数据类型为int32或int64rank必须大于等于2。
- **update** (Tensor) - 指定与 `input_x` 做更新操作的Tensor其数据类型与 `input_x` 相同。并且 :math:`update.shape = indices.shape[:-1]+input\_x.shape[indices.shape[-1]:]`
输出:
Tensorshape和数据类型与输入 `input_x` 相同。
异常:
- **TypeError** - `indices` 的数据类型不满足int32或int64。
- **ValueError** - `input_x` 的rank小于 indices.shape的最后一维。
- **ValueError** - `input_x` 的值与输入 `indices` 不匹配。
- **RuntimeError** - `indices` 中的值超出了 `input_x` 的索引范围。