YOLO_v3_tutorial_from_scratch icon indicating copy to clipboard operation
YOLO_v3_tutorial_from_scratch copied to clipboard

what does "pad = (kernel_size - 1) // 2" mean?

Open bot66 opened this issue 5 years ago • 1 comments

darknet.py line 94 still don't get it, I googled a lot, at yolov3.cfg where padding always equal to 1, some say padding is constant( links), and i tried padding = 1 in every loop, end up with error, so I use the original code from darknet.py in this repository, it works, but how "pad = (kernel_size - 1) // 2" ? why?

if padding:
    pad = (kernel_size -1) // 2
else:
    pad = 0

bot66 avatar Sep 24 '19 01:09 bot66

As a beginner, I think pad in yolov3.cfg means whether to use padding. In yolo, only stride controls the output size. If stride = 1, output the same size as input, you must use pad = (kernel_size - 1) // 2.(called Same Convolution). If stride = 2, pad = (kernel_size - 1) // 2, output half size.

paleomoon avatar Jan 09 '20 13:01 paleomoon