ultralytics / yolov3

YOLOv3 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
10.16k stars 3.44k forks source link

Freeze backbone at epoch 0, unfreeze at epoch 1 #218

Closed hktxt closed 5 years ago

hktxt commented 5 years ago

Hey, thanks for your implementation. I just don't understand this: # Freeze backbone at epoch 0, unfreeze at epoch 1 in train loop.

By the way, no close() were called, while using open(). I think switch it to with open() is more elegant. And, add a param for training from scratch, even though we can do this just comment some lines.

glenn-jocher commented 5 years ago

@hktxt this optionally freezes the darknet53 backbone for the first epoch so only non-backbone layers are trained.

with open() commands don't require close() commands.

Pari-singh commented 4 years ago

Hi @glenn-jocher ,

  1. I want to understand, is that freezing of the final layer and then unfreezing are in case of (no) transfer learning, ie., if I do a custom data train and do not use the tag --transfer, given my data is new, it will freeze the last layers
  2. I want to freeze the lowest layers i.e., the first 2, how would you suggest me to modify the train.py?

It would be really great to hear your comments! Thanks

glenn-jocher commented 4 years ago

@Pari-singh --transfer freezes layers, which I do not recommend. Simply train normally for best results from whatever starting point you wish using python3 train.py --weights start_from_here.pt

Pari-singh commented 4 years ago

@glenn-jocher which eventually means training it more on entire model, correct? I was wondering if there was a feature for gradual unfreezing till the layer we want

glenn-jocher commented 4 years ago

@Pari-singh no there's no feature like this. If you want the fastest results, simply start from pretrained yolov3-spp. python3 train.py --weights yolov3-spp.weights

If you want the best results, train on randomly initialized weights: python3 train.py --weights ''

Pari-singh commented 4 years ago

Yes, thanks for the insight @glenn-jocher

glenn-jocher commented 10 months ago

You're welcome, @Pari-singh! If you need further assistance, feel free to ask. Good luck with your training!