cavalleria / cavaface

face recognition training project(pytorch)
MIT License
459 stars 87 forks source link

Maxpool in shortcut is redundant #73

Open liorkad3 opened 3 years ago

liorkad3 commented 3 years ago

In the Bottleneck_IR_SE , the shortcut layer of Maxpool is always with kernel=1 and stride=1. So the layer is useless. Am I missing something?

xsacha commented 2 years ago

This happens in the last bottleneck only, where depth and channels are both the same and stride is not set (so defaults to 1), right? As far as I know it's only a single occurrence in the model and maybe libtorch automatically optimises for it. Otherwise, try:

        if in_channel == depth:
            if stride == 1:
                self.shortcut_layer = Identity()
            else:
                self.shortcut_layer = MaxPool2d(1, stride)