I'm training a custom YOLOv4 model using darknet, and at the end of training it produces two files: last.weights
and final.weights
. What is the difference between them, and which one should I use? From the naming I'd guess final.weights
is the best best.weights
that was generated, but I can't find it documented anywhere.
Asked
Active
Viewed 763 times
1

Nathan
- 73,987
- 14
- 40
- 69
1 Answers
1
Reference to original Yolov4, last_weight
is not the best
(file yolo-obj_last.weights will be saved to the build\darknet\x64\backup\ for each 100 iterations)
And if you dive into source code, final.weight
is saved after training (through all iterations)
The best.weights
file is exactly the best weight you need

AnhPC03
- 622
- 5
- 15
-
I appreciate you looking into the source, thank you. I'm a bit concerned that final might be just the final iteration (for later resumption of training), not the best weights (which are generated using a heuristic). – Nathan Jul 23 '22 at 08:42
-
Are you sure don't have any `best.weight` file? Cause I've found this line of code `sprintf(buff, "%s/%s_best.weights", backup_directory, base);` – AnhPC03 Jul 23 '22 at 08:53
-
It produced a few best.weights along the way, but after the training was actually finished it only produced the `final` and `last` weights. The `best.weights` file is a few hours older than the others. I wonder if it just so happened in this training that the best weight was actually found before training finished? – Nathan Jul 23 '22 at 08:59
-
Exactly, don't have any rule that the best is produced at the last. The `best.weights` file was the best. Because new `mAP` compared to old one and update if better, when updated, the `best.weights` file also was saved. So if new `mAP` was not good as old one, the `best.weights` file had older timestamp as the `last.weights` and `final.weights` – AnhPC03 Jul 23 '22 at 09:09
-
Okay, that makes sense. I ran 6k iterations, and it looks like the `best.weights` was generated around iteration !1800. It seems a bit weird that the best model would be that early in training though, doesn't it? – Nathan Jul 23 '22 at 09:14
-
It really makes sense. It means that you could stop early because the more iterations you train, the more accuracy you lost, and you wasted time too – AnhPC03 Jul 23 '22 at 09:18
-
1@Nathan I've updated my answer, you should check it, especially the image – AnhPC03 Jul 23 '22 at 09:24