The relation between original image size and patch size

Hi everyone,
I am using your CSBdeep for my project to restore images, it works now. I have a question about the data generation for training. What’s the relation among original image size, patch size and number of patches per image? How you decide the patch size and number of patches per image? How they influence traing? Like for Tribolium castaneou (fig.1e in the paper), the original image size is 48773665. Why you pick patch size 166464, and number of patches per image is 1024? What’s relation between them? I am new to deep learning, any information would be very helpful.

Thank you so much for help!

Best regards,


Hi Xiaolei,

  • patch_size: is typically chosen large enough such that it provides enough context for the neural network and small enough such that a few batches would fit into GPU memory. We used 16x64x64 in the Tribolium example as the axial pixelsize was roughly 4 times larger than lateral and that way the patchsize would cover the same physical size along every dimension. If you have isotropic data, you could use e.g. 64x64x64 or larger depending on your GPUs memory (in general this is not a critical parameter).

  • n_patches_per_image: Since patches are randomly sampled from the signal containing regions of the image, the number of patches should be chosen such that these samples roughly cover the whole image but without completely oversampling it. So for a larger image you should sample more patches than from a smaller one. Setting n_patches_per_image to something like 2 #pixels(image)/#pixel(patch_size) is a good default .

Hope that helps,


1 Like

Hi Martin,

This is very helpful. Thanks a lot!