You can use some permutation and replacement of axes -
A.reshape(h
Run Example -
In [46]:
Each element (as a block) along the first two axes represents patches. Thus. for the sample provided, we would have 5 x 6 = 30
corrections.
If you need these patches along one combined first axis, use another reshape
-
In [85]: out = A.reshape(h
Let it be checked manually by checking the values ββthemselves -
In [81]: A[:ph,:pw] # First patch Out[81]: array([[[6, 5, 2], [4, 0, 1]], [[0, 0, 4], [2, 3, 0]]]) In [82]: A[:ph,pw:2*pw] # Second patch Out[82]: array([[[8, 3, 3], [0, 0, 2]], [[8, 5, 4], [3, 4, 6]]]) In [83]: out[0] Out[83]: array([[[6, 5, 2], [4, 0, 1]], [[0, 0, 4], [2, 3, 0]]]) In [84]: out[1] Out[84]: array([[[8, 3, 3], [0, 0, 2]], [[8, 5, 4], [3, 4, 6]]])