I created a 2D nd.array by stacking a list of regular arrays:
from mxnet import nd
x = [0,1,2]
y = [3,4,5]
z = nd.array([x, y])
The above code works fine. I could replace x
and y
with numpy arrays, which works fine as well:
import numpy as np
x = np.array([0,1,2])
y = np.array([3,4,5])
z = nd.array([x, y])
Finally, I tried to replace x
and y
with nd.array:
x = nd.array([0,1,2])
y = nd.array([3,4,5])
z = nd.array([x, y])
This fails and gives the following errors:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mxnet/ndarray.py", line 1291, in array
source_array = np.array(source_array, dtype=dtype)
ValueError: setting an array element with a sequence.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mxnet/ndarray.py", line 1293, in array
raise TypeError('source_array must be array like object')
TypeError: source_array must be array like object
It does not seem to take the nd.array as an “array like” object, which is not so intuitive. Would it be possible to have nd.array recognized as an array-like object?
Also, could anyone explain if there is any overhead for converting either regular or numpy array to nd.array? If there is, is it significant enough for developers to worry about or negligible? Thanks!