**Scatter_nd Layer** Output is obtained by scattering the :attr:`updates` in a new tensor according to :attr:`index` . This op is similar to :code:`scatter_nd_add`, except the tensor of :attr:`shape` is zero-initialized. Correspondingly, :code:`scatter_nd(index, updates, shape)`
(
index: Tensor, updates: Tensor, shape: ShapeLike, name: str | None = None
)
| 4871 | |
| 4872 | |
| 4873 | def scatter_nd( |
| 4874 | index: Tensor, updates: Tensor, shape: ShapeLike, name: str | None = None |
| 4875 | ) -> Tensor: |
| 4876 | """ |
| 4877 | **Scatter_nd Layer** |
| 4878 | |
| 4879 | Output is obtained by scattering the :attr:`updates` in a new tensor according |
| 4880 | to :attr:`index` . This op is similar to :code:`scatter_nd_add`, except the |
| 4881 | tensor of :attr:`shape` is zero-initialized. Correspondingly, :code:`scatter_nd(index, updates, shape)` |
| 4882 | is equal to :code:`scatter_nd_add(paddle.zeros(shape, updates.dtype), index, updates)` . |
| 4883 | If :attr:`index` has repeated elements, then the corresponding updates are accumulated. |
| 4884 | Because of the numerical approximation issues, the different order of repeated elements |
| 4885 | in :attr:`index` may cause different results. The specific calculation method can be |
| 4886 | seen :code:`scatter_nd_add` . This op is the inverse of the :code:`gather_nd` op. |
| 4887 | |
| 4888 | Args: |
| 4889 | index (Tensor): The index input with ndim >= 1 and index.shape[-1] <= len(shape). |
| 4890 | Its dtype should be int32 or int64 as it is used as indexes. |
| 4891 | updates (Tensor): The updated value of scatter_nd op. Its dtype should be float32, float64. |
| 4892 | It must have the shape index.shape[:-1] + shape[index.shape[-1]:] |
| 4893 | shape(tuple|list|Tensor): Shape of output tensor. |
| 4894 | name (str|None, optional): The output Tensor name. If set None, the layer will be named automatically. |
| 4895 | |
| 4896 | Returns: |
| 4897 | output (Tensor), The output is a tensor with the same type as :attr:`updates` . |
| 4898 | |
| 4899 | Examples: |
| 4900 | |
| 4901 | .. code-block:: pycon |
| 4902 | |
| 4903 | >>> import paddle |
| 4904 | |
| 4905 | >>> index = paddle.to_tensor([[1, 1], [0, 1], [1, 3]], dtype="int64") |
| 4906 | >>> updates = paddle.rand(shape=[3, 9, 10], dtype='float32') |
| 4907 | >>> shape = [3, 5, 9, 10] |
| 4908 | |
| 4909 | >>> output = paddle.scatter_nd(index, updates, shape) |
| 4910 | """ |
| 4911 | return scatter_nd_add(zeros(shape, updates.dtype), index, updates, name) |
| 4912 | |
| 4913 | |
| 4914 | @param_two_alias(["x", "input"], ["axis", "dim"]) |
nothing calls this directly
no test coverage detected