How to split multidimensional numpy array?
for example) suppose splitinig 4-dimensional x array by 4th dimension (whose shape is a×b×c×d)
into d number arrays (whoes shape are a×b×c)
and merge this d number arrays into original shape (a×b×c×d)?
for simplified version
Let A be a 3 × 3 × 3 size numpy array
A =[[[111,112,113],[121,122,123],[131,132,133]],
[[211,212,213],[221,222,223],[231,232,233]],
[[311,312,313],[321,322,323],[331,332,333]]]
then spliting A by last 3rd columb
A1=[[111,121,131],[211,221,231],[311,321,331]]
A2=[[112,122,132],[212,222,232],[312,322,332]]
A3=[[113,123,133],[213,223,233],[313,323,333]]
next merge A1 A2 A3 and return it to A which has 3×3×3 size matrix.
newA = [A1, A2, A3]
#newA=newA.reshape(???)
assert newA == A
assert failed because the matrix structure has changed for better understaing suppose 3×3×4 size matrix
newA = [A1, A2, A3, A4]
newA=newA.reshape(???)
because the dimensional shape is changed I have tried
newA=newA.reshape((A1.shape),4)
assert newA == A
but not working good. assert failed