# Calculate the Output Size of Conv. Layer

Say, we want to convolve a 7 X 7 image with a 3 X 3 filter with a stride length of 2. What's the final size of the output?

Before going to the equation, let's lay down some definitions:

• the image is of size n X n
• the filter is of size f X f
• the padding is of size p
• the stride is of length s

The output size will be:

$$\lfloor \frac{n + 2p - f} {s} + 1 \rfloor \times \lfloor \frac{n + 2p - f} {s} + 1 \rfloor$$

Note: Should the fraction not be an integer, we'll have to round it down.

And since:

• n = 7
• f = 3
• p = 0
• s = 2

This give us 3 X 3 because:

$$\lfloor \frac{7 + 0 - 3} {2} + 1 \rfloor \times \lfloor \frac{7 + 0 - 3} {2} + 1 \rfloor = 3 \times 3$$

# 😎

If you enjoyed this post and want to buy me a cup of coffee...

The thing is, I'll always accept a cup of coffee. So feel free to buy me one.

Cheers! ☕️