mindspore.Tensor.assign_value

View Source On Gitee
Tensor.assign_value(value)[source]

Assign another tensor value to this tensor.

Parameters

value (Tensor) – Tensor for assignment.

Returns

Tensor, Tensor that’s been assigned.

Examples

>>> from mindspore import Tensor
>>> import numpy as np
>>> x = Tensor([1, 2, 3, 4])
>>> y = Tensor(np.array([[1, 2], [3, 4]]))
>>> output = x.assign_value(y)
>>> print(x)
[[1 2]
[3 4]]