Detectron: How to freeze batchnorm parameter when using AffineChannel layer?

Created on 24 Jul 2018  ·  4Comments  ·  Source: facebookresearch/Detectron

I am trying to build detectron with my custom network backbone.

1.
I am using affine channel in detectron instead of batch norm layer and i want to freeze this layer.
In ResNet.py file they use stopgradient but i think it freeze all previous layers.
Is that correct to use stopgradient to freeze a certain one layer?


  1. I think there is no freeze function for affine layer in resnet
    (freeze_at config freezes only chosen blocks not all affine layers)
    Is that okay to reproduce the results? Because affine layer is not batch norm layer.
    Is there anything freezes affine layer that i missed?

Most helpful comment

There is a method TrainableParams() in DetectionModelHelper class in detectron/modeling/detector.py which returns all trainable params. It depends on self.do_not_update_params list, so you can actually somehow append your param names to it manually and that would effectively freeze the weight. That might help.

All 4 comments

That's my problem, too.

I have tried to replace ResNet backbone with my custom backbone networks that was pretrained in caffe and had batchnorm+scale layer.

So ,firstly, I converted .caffemodel to .pkl file.

Second, define my backbone networks as like ResNet.py.

When I define my backbone network that have bachnorm layer, as like ResNet.py, I used AffineChannel layer instead of batchnorm.

My questions are here,

  1. How to freeze batchnrom parameter? Faster R-CNN paper mentioned that batchnorm parameters are freezed due to small mini-batch size.

In the ResNet.py, model.StopGradient(s, s) ,I guess, freezes all parameters not only batchnorm parameters(the scale and bias in AffineChannel).

  1. if not freezed batchnorm parameters, Don't I need to freeze batchnorm parameters?

There is a method TrainableParams() in DetectionModelHelper class in detectron/modeling/detector.py which returns all trainable params. It depends on self.do_not_update_params list, so you can actually somehow append your param names to it manually and that would effectively freeze the weight. That might help.

@zeenolife thanks!

Hi,I wonder to know the effect of the 'inplace‘ in AffineChannel,What's the impact of setting it to True or false? @lsrock1 @youngwanLEE

Was this page helpful?
0 / 5 - 0 ratings