3
$\begingroup$

Below you can see a convolutional network with 24 convolutional layers. I am trying to understand the shape of the network. Given the input image with shape 448x448x3, we apply first conv filter of shape 7x7x64 with stride = 2 followed by a maxpool layer with 2x2 with stride 2. The output as I calculated it is as follows:

$$ o_{conv}=\frac{448-7}{2}+1=221 \\ o_{pool}=\frac{221-2}{2}+1=110.5 $$

I am not sure why we got the shape to be 112, please.

enter image description here

$\endgroup$
2
  • $\begingroup$ Which Yolo is this? i.e. YoloVx. $\endgroup$
    – gunes
    Commented Dec 24, 2022 at 11:22
  • $\begingroup$ @gunes. YOLOv1 model $\endgroup$
    – Avv
    Commented Dec 24, 2022 at 13:15

1 Answer 1

3
$\begingroup$

I couldn't find YoloV1 TFlite model file and verify, but the option that can cause this is padding. There are two modes of padding: SAME and VALID. In the SAME option, the input image is padded from left/right and top/bottom such that the output will be of the same size (when strides are 1). For that, you need 6 pixels of padding. And, with stride equal to 2, you'll have $$o_{\text{conv}}=\bigg\lfloor{\frac{448-7+6}{2}}\bigg\rfloor+1=224$$

When we pool this with $2\times 2$ filters, we get $112$ pixels.

$\endgroup$
2
  • $\begingroup$ Thank you very much. So the image is padded with 3 pixels from the left and 3 pixels from the right, which gives 6 pixels in total. $\endgroup$
    – Avv
    Commented Dec 24, 2022 at 15:47
  • 1
    $\begingroup$ Yes, the padding is split equally when it can be done so. If not, the larger part goes to right (and bottom). $\endgroup$
    – gunes
    Commented Dec 24, 2022 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.