How to find optimal image size for training?

Generally, we see a trade off between image size and batch size when training. Having larger batch size makes the loss to decrease smoothly and having less image size can speed up training. But when we dealing with images where the small details are important for model to learn to classify. Here, we need to have high resolution of the images but batch size should decrease because of memory issues and training time will increase. So, how to find optimal image size? because after finding that value increasing size more will not affect much our accuracy and training time. So, is there any analysis of the images to be done or include image size as another hyperparameter and tune it?

1 Like

Same as any other hyperparameter, you need to tune it by experimentation, this could be classified more like a “prepocessing hyperpameter” let’s say, so you would need to evaluate different values for your specific case. Both image size and batch size impact on the training as you mentioned. If you need to analyze high resolution images then you will probably need a very powerful computer since it needs to fit all the image in memory times the batch size.

1 Like

I wonder if precedence should be given to image size. Batch size affects convergence, which could be smoother for larger batch sizes. However, losing information due to resizing for problems where small details are needed, could have a worse impact over the ability to capture key features

I think when you are talking about image size and batch size, it’s hard to say there is a direct tradeoff between the two. The image size you need depends on the problem you want to solve. You need high-res data if the problem you have at hand requires that level of detail. Some problems may work just fine using lower-res images. If the latter is the case you want to lower-res as it will reduce the computation cost. But not too low, so you still retain all the info you need out of the image!
Batch size on the other hand has to do with generalization and conversion speed. The smaller the batch size is the more stochastic the update becomes. The larger the batch size is the more synchronous the update becomes.
It’s true larger batch-size require more computation, but, the image size shouldn’t be the deciding factor of the batch size. It depends on the nature of the objective function and how you want that to be optimized.