I have an numpy objects array with shape (60000,) and each of the 60000 elements is a (32,32,3)array. My question is how to convert the (60000,) array to a (32,32,3,60000) array.
1 Answer 1
import numpy as np
class Obj():
def __init__(self,i):
self.i = i
l = np.array([np.array([Obj(i) for i in range(64*3)]).reshape(8,8,3)
for _ in range(100)])
print(l.shape)
#Output: (100, 8, 8, 3)
print(np.transpose(l,(1,2,3,0)).shape)
#Output: (8, 8, 3, 100)
lang-py
np.stack
.