Correct way to freeze detector model
Im working on fine tuning detector model. I am freezing the detector in the following way before initiating the training:
for Layer in detector.model.layers: Layer.trainable = False
detector.model.compile()
If I do not freeze the model , the model performance after training is very bad in terms of detecting the text. That means when I am not freezing , the training is overwriting the pretrained model weights.
My question in this regard is that if the way Im doing the freeze of pretrained model is correct? Or I should do freeze on VGG 16 backbone model only? Should I freeze only specific layers? Which specific layers should I freeze ? Please advise.
In my experimentation Im able to train some of the layers while freezing others in the following way :
detector = keras_ocr.detection.Detector(weights= 'clovaai_general') convLayer = "conv_cls" for Layer in detector.model.layers: if Layer.name.find(convLayer) != -1: Layer.trainable = True else: Layer.trainable = False detector.model.compile('adam','mse')