rwightman/efficientdet-pytorch

[FEATURE] Freezing Layers

YHSP-AI opened this issue · 1 comments

Is your feature request related to a problem? Please describe.
My model (both tf_efficientdet_d4 and tf_efficientdet_d7 is overfitting to a small dataset. I believe that freezing some of the layers will alleviate this

Describe the solution you'd like
An option https://github.com/rwightman/efficientdet-pytorch/blob/master/effdet/config/model_config.py here to specify the number/proportion of layers to freeze.

Thanks. Any code to freeze the layers by specifying propoortion will be much appreciated.

@username2018 freezing might help the situation you describe, but an 'easy' interface (ie proportion, or generic 'number' of frozen or unfrozen layers) is well, difficult to get right :)

I'm not against adding such functionality but I'd need much more data in terms of granularity or freezing schemes that work to add a permanent feature.

For your current use I would suggest hacking it in to see what happens. There are some helpers in timm that should make life a bit easier...

mm = effdet.create_model('efficientdetv2_dt')
timm.utils.freeze(mm)  # freeze the full model, including setting frozen batch norm (there is a bool arg to enable/disable freezing running bn stats)
timm.utils.unfreeze(mm, ['box_net', 'class_net', 'fpn'])  # unfreeze heads and fpn, you could also add some modules of the backbone