Skip to content

Instantly share code, notes, and snippets.

@CMCDragonkai
Created July 3, 2020 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CMCDragonkai/1224ce71cdc30d633491e0abe87f0a81 to your computer and use it in GitHub Desktop.
Save CMCDragonkai/1224ce71cdc30d633491e0abe87f0a81 to your computer and use it in GitHub Desktop.
Batch size and Image size optimisation for CNNs

Batch size and Image size optimisation for CNNs

Given an initial size of an image. If we drop the square image size by side_p percentage points.

How much does the area percentage drop by?

The formula is as below:

area_p = [side_p * x^2 * (2 - side_p)] / 100

If x was 10, and we dropped by 0.2 (20%):

0.36 = [0.2 * 10^2 * (2 - 0.2)] / 100

Then the total area size dropped by 0.36 (36%)

Remember that reducing image size doesn't reduce channel size. Therefore the percentage drop in area is the same percentage drop in volume.

Thus going from a 300 size square image to 200 size square image is roughly a 450% drop in area and thus memory usage.

Which means you can multiple your batch size by more than 5x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment