AlexeyAB / darknet

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

could you explain what is different between ema.weights, last.weights, final.weights? #8240

Open Wooks-git opened 2 years ago

Wooks-git commented 2 years ago

when i trained model, i get model-[iter].weights, model-ema.weights, model-last.weights, model-final.weights.

what is different between ema, last, final??

stephanecharette commented 2 years ago

ema? I've never seen that.

You should have ...best.weights, ...last.weights, and ...final.weights. "best" is the best one. You'll get that if you train with a valid.txt file and -map. See: https://www.ccoderun.ca/programming/darknet_faq/#training_command Last is the most recent (last) one to be written to disk. Final is the one that comes at the very end training. If you md5 last and final, you'll see they are the same once you finish training.

> md5sum driving_best.weights driving_final.weights driving_last.weights 
6a3045750a5f8013b735aaf9a9fcd82c  driving_best.weights
dbe82c8971f9a67f235c52c5af4d21b0  driving_final.weights
dbe82c8971f9a67f235c52c5af4d21b0  driving_last.weights
Wooks-git commented 2 years ago

hmm.. i trained yolov4-csp-custom. Then i got like this.

image

stephanecharette commented 2 years ago

Never seen that before. But I stick mostly to YOLOvX.cfg and YOLOvX-tiny.cfg. Looking at the code, I do see functions like save_convolutional_weights_ema() and is_ema_initialized().

Must be specific to some of the newer configs, because looking through the 40 or so neural network directories on this computer, I don't have a single instance of a "ema" file.

stephane@2004-dev ~/nn> find . | grep ema
stephane@2004-dev ~/nn [0|1]> find . | grep weights | wc -l
95
Wooks-git commented 2 years ago

i found this line in darknet.c file image

and explain about ema is this link https://pytorch.org/blog/pytorch-1.6-now-includes-stochastic-weight-averaging/

akashAD98 commented 2 years ago

@stephanecharette @Wooks-git when you train yolov4-csp-swish model you will get that ema weight, The best model having highest MAP compared last,ema weight , inside cfg of csp-swish you will get this ema parameter, but im not sure whats the purpose of ema