Thank you very much for this code. I tried this and it works as you mentioned. When I change the stride to dh, dw to 1, 1 (stride) we get 100 3 by 3 patches. But I need 144 patches according to input  size. Could you please suggest the modififcation to be done ?