Does Darknet class implement shortcuts of darknet?


(Josh) #1

Darknet53 uses shortcut layers. I am going through the lectures again and the darknet class here.

I understand how the blocks are used to build the resnet layers, and how the layers are concatenated together to make the model. The number and architecture of the convolution make sense. But I can’t seem to under stand how the shortcut connections are implemented like I the the darknet53 config here https://github.com/pjreddie/darknet/blob/master/cfg/darknet53.cfg

I don’t understand how the the fastai implementation concates the output of the previous layer with the layer 3 above for the shortcut layer. Anyone able to provide insight?


(Ben) #2

Look carefully at this method in ResLayer:

def forward(self, x): return x + self.conv2(self.conv1(x))

We’re taking the inputs (x), and concatenating them with the outputs 2 layers above. In the darknet53.cfg file it says ‘-3’ rather than ‘-2’ because they’re counting backwards from ‘shortcut’ as its own layer. At least, that’s my interpretation :sweat_smile:


(Josh) #3

Thank you, that makes sense. I completely missed that! The -2 vs -3 i was Ok with but i missed where the addition was being done. Another thing i think is interesting if I understand correctly is that in a block the shortcut layers actually point to the shortcut layers above it on the same block (not the first short be the others) . After writing our the layers on paper this is also being handled. Some very compact code compared to other implementations. Thank you so much for the reply.