n = 4
m = 5
a = np.arange(1, n * m + 1).reshape(n, m)
print(a)
sz = a.itemsize
h, w = a.shape
bh, bw = 2, 2
shape = h / bh, w / bw, bh, bw
print(shape)
strides = sz * np.array([w * bh, bw, w, 1])
print(strides)
blocks = np.lib.stride_tricks.as_strided(a, shape=shape, strides=strides)
print(blocks)
Using Numpy stride_tricks to get non-overlapping array blocks