ndarray.__repr__

ndarray.__repr__(self)

Returns a string representation of the array. The dtype of the ndarray will not be appended to the string if it is float32. The context of the ndarray will be appended for devices other than CPU.

Examples

>>> from mxnet import np, npx
>>> a = np.random.uniform(size=(2, 3))
>>> a
array([[0.5488135 , 0.5928446 , 0.71518934],
       [0.84426576, 0.60276335, 0.8579456 ]])
>>> print(a)
[[0.5488135  0.5928446  0.71518934]
 [0.84426576 0.60276335 0.8579456 ]]
>>> a.dtype
<class 'numpy.float32'>
>>> b = a.astype(np.float64)
>>> b
array([[0.54881352, 0.59284461, 0.71518934],
       [0.84426576, 0.60276335, 0.85794562]], dtype=float64)
>>> print(b)
[[0.54881352 0.59284461 0.71518934]
 [0.84426576 0.60276335 0.85794562]]
>>> b.dtype
<class 'numpy.float64'>
>>> c = a.copyto(npx.gpu(0))
>>> c
array([[0.5488135 , 0.5928446 , 0.71518934],
       [0.84426576, 0.60276335, 0.8579456 ]], ctx=gpu(0))
>>> print(c)
[[0.5488135  0.5928446  0.71518934]
 [0.84426576 0.60276335 0.8579456 ]] @gpu(0)
>>> d = b.copyto(npx.gpu(0))
>>> d
array([[0.54881352, 0.59284461, 0.71518934],
       [0.84426576, 0.60276335, 0.85794562]], dtype=float64, ctx=gpu(0))
>>> print(d)
[[0.54881352 0.59284461 0.71518934]
 [0.84426576 0.60276335 0.85794562]] @gpu(0)