select_scatter¶
- paddle. select_scatter ( x, values, axis, index, name=None ) [source]
-
Embeds the values of the values tensor into x at the given index of axis.
- Parameters
-
x (Tensor) – The Destination Tensor. Supported data types are bool, float16, float32, float64, uint8, int8, int16, int32, int64, bfloat16, complex64, complex128.
values (Tensor) – The tensor to embed into x. Supported data types are bool, float16, float32, float64, uint8, int8, int16, int32, int64, bfloat16, complex64, complex128.
axis (int) – the dimension to insert the slice into.
index (int) – the index to select with.
name (str, optional) – Name for the operation (optional, default is None).
- Returns
-
Tensor, same dtype and shape with x
Examples
>>> import paddle >>> x = paddle.zeros((2,3,4)).astype("float32") >>> values = paddle.ones((2,4)).astype("float32") >>> res = paddle.select_scatter(x,values,1,1) >>> print(res) Tensor(shape=[2, 3, 4], dtype=float32, place=Place(cpu), stop_gradient=True, [[[0., 0., 0., 0.], [1., 1., 1., 1.], [0., 0., 0., 0.]], [[0., 0., 0., 0.], [1., 1., 1., 1.], [0., 0., 0., 0.]]])