Here are the situations:
x.shape = (20,)
x1 = x [0,]
x2 = x [1,]
x3 = x [2,]
...
The shapes of x1, x2, x3 ... are all different.
For example,
x1.shape = (300, 400, 3)
x2.shape = (280, 520, 3)
x3.shape = (330, 400, 3)
I have a 3d numpy array of different sizes
I want to assign it to each element of vector called x.
What should I do?
Make your elements first, then create your x
array from them
x = numpy.array([x1, x2, x3])
A modern numpy
will automatically use dtype=object
whereas in previous versions you had to add dtype=object
explicitly.
This isn't really much different from using a plain Python list
though:
x = [x1, x2, x3]
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.