AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.68k stars 7.96k forks source link

When to use stopbackward and clear flag #7259

Closed renziver closed 3 years ago

renziver commented 3 years ago

I'm studying about model retraining and a little bit confused with the purpose of these commands/flags.

When and Why should I use the stopbackward and -clear whenever I try to retrain or fine-tune a model?

As per my understanding, I should use -clear flag if I have finished training the model (model-final.weights) and would want to continue training it on the old+new dataset, but what is the concept behind it? what am I "clearing"?

For the stopbackward, the README file only says that it can be used to speed up training in exchange for lower accuracy. what is the concept behind it? when should I use stopbackward? Based on my understanding, it is used to freeze certain layers, but aren't the usage of pre-trained models when training already uses frozen layers? why do i need to use stopbackward when I'm using pre-trained models?

Thank you!

lsd1994 commented 3 years ago

-clear only set seen imgs and current iteration to 0, it doesn't change weights itself. https://github.com/AlexeyAB/darknet/blob/103d301ccbc19e47e002005bdfdbaf07a92cd880/src/detector.c#L83-L86 stopbackward can frozen weights before current layer, if you add this in some layer, then backward stops. https://github.com/AlexeyAB/darknet/blob/103d301ccbc19e47e002005bdfdbaf07a92cd880/src/network.c#L353-L355

akashAD98 commented 3 years ago

@lsd1994 stopbackward=1 where should we need to add this parameter in scaled yolov4. i.e mish/csp.cfg ? at which yolo layer?
adding stopbackward=1 in cfg is noting but fine tunning? Im correct?