mindspore.Tensor.inplace_update
- Tensor.inplace_update(v, indices)[source]
Update some rows of a tensor with values of v according to the specified indices.
Note
indices refers to the left-most dimension.
- Parameters
- Returns
Tensor, with updated values.
- Raises
TypeError – if indices is not int or tuple.
TypeError – if indices is tuple but any of its element is not int.
ValueError – the Tensor shape is different from that of v.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import numpy as np >>> from mindspore import Tensor >>> import mindspore >>> x = Tensor(np.array([[1, 2], [3, 4], [5, 6]]), mindspore.float32) >>> v = Tensor(np.array([[0.1, 0.2], [0.3, 0.4]]), mindspore.float32) >>> indices = (0, 1) >>> output = x.inplace_update(v, indices) >>> print(output) [[0.1 0.2] [0.3 0.4] [5. 6. ]]