scatter_elements¶
dragon.
scatter_elements
(
inputs,
axis=0,
copy=True,
**kwargs
)[source]¶Update elements along the given axis of index.
Number of dimensions of input and index should be same. For 3-d input, output is updated as:
out[index[i, j, k], j, k] = updates[i, j, k] # ``axis`` is 0 out[i, index[i, j, k], k] = updates[i, j, k] # ``axis`` is 1 out[i, j, index[i, j, k]] = updates[i, j, k] # ``axis`` is 2
Examples:
y = dragon.constant([[1, 2], [3, 4]]) x = dragon.constant([[5, 6], [7, 8]]) index = dragon.constant([[0, 0], [0, 1]]) print(dragon.scatter_elements([y, index, x], axis=0)) # [[7, 6], [3, 8]] print(dragon.scatter_elements([y, index, x], axis=1)) # [[6, 2], [7, 8]]
- Parameters:
- inputs (Sequence[dragon.Tensor]) – The input, index and updates tensor.
- axis (int, optional, default=0) – The axis of index values.
- copy (bool, optional, default=True) – Return a new tensor or call in-place.
- Returns:
dragon.Tensor – The output tensor.