Added support for gradual unfreezing while training (transfer-learning) #9684
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Unfreezing layers during training is one the strategy used in ULMFIT to fine-tune model. Based on that, I have updated code to unfreeze layers during training.
Compatibility Changes
--grad_unfreeze
, to able the gradual unfreezing.--unfreezing_layers
, layer ids, (it is basically decided on number of layers has already frozen)--unfreeze_epochs
, Epoch number, where you want to unfreeze the layer.Usage
To use gradual unfreeze, if only backbone is frozen & trained for 50 epochs.
python train.py --data coco.yaml --cfg yolov5n.yaml --weights '' --batch-size 128 --grad_unfreeze --unfreezing_layers 9 --unfreezing_layers 8 --unfreezing_layers 7 --unfreezing_layers 6 --unfreeze_epochs 15 20 25 30 35
You can find issue here #9677
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Implemented Gradual Unfreezing in YOLOv5 training 🚀.
📊 Key Changes
gradual_unfreeze
function to allow selective unfreezing of model layers during training.train.py
to support new command-line arguments for gradual unfreezing.🎯 Purpose & Impact