scatter_add¶
- dragon.- scatter_add(
 inputs,
 axis=0,
 copy=True,
 **kwargs
 )[source]¶
- Add 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, 0]]) print(dragon.scatter_add([y, index, x], axis=0)) # [[13, 16], [3, 4]] print(dragon.scatter_add([y, index, x], axis=1)) # [[12, 2], [18, 4]] - 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. 
 
