mxnet.ndarray.NDArray.copyto¶
-
NDArray.
copyto
(other)[source]¶ Copies the value of this array to another array.
If
other
is aNDArray
object, thenother.shape
andself.shape
should be the same. This function copies the value fromself
toother
.If
other
is a context, a newNDArray
will be first created on the target context, and the value ofself
is copied.- Parameters
other (NDArray or Context) – The destination array or context.
- Returns
The copied array. If
other
is anNDArray
, then the return value andother
will point to the sameNDArray
.- Return type
Examples
>>> x = mx.nd.ones((2,3)) >>> y = mx.nd.zeros((2,3), mx.gpu(0)) >>> z = x.copyto(y) >>> z is y True >>> y.asnumpy() array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) >>> y.copyto(mx.gpu(0)) <NDArray 2x3 @gpu(0)>