Suppose I have tuple a, which elements are np.ndarrays and I want to convert a to np.ndarray too. Like this:
a = np.ndarray(a)
But getting such error: only integer scalar arrays can be converted to a scalar index. Tried also to convert inner arrays to the list, but got incorrect results. If my inner arrays have 3 dimensions, after all I want to have a ndarray with 4 dimensions. How can I do that? Thanks
I believe the numpy.ndarray
is not for creating with data.
Arrays should be constructed using array, zeros or empty (refer to the See Also section below). The parameters given here refer to a low-level method (ndarray(…)) for instantiating an array.
Try using numpy.array
.
Your error would be that the tuple is for the first argument shape
which is a tuple of integers.
You could create one from scratch with np.ndarray
and the correct tuple instead perhaps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.