python - numpy append slices to two dimensional array to make it three dimensional -


i have 5 numpy arrays shape (5,5). want achieve combine these 5 numpy arrays 1 array of shape (5,5,5). code looks following not work:

combined = np.empty((0, 5, 5), dtype=np.uint8)  idx in range(0, 5):     array = getarray(idx) # returns array of shape (5,5)     np.append(combined, img, axis=0) 

i thought if set first axis 0 append on axis in end shape (5,5,5). wrong here?

i have figured out myself:

combined = np.empty((0, 5, 5), dtype=np.uint8)  idx in range(0, 5):     array = getarray(idx) # returns array of shape (5,5)     array array[np.newaxis, :, :]     combined = np.append(combined, img, axis=0) print combined.shape + returns (5,5,5) 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -