-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HYPERPARAMETER EVOLUTION #392
Comments
I had this problem. 'shape '[16, 3, 85, 13, 13]' is invalid for input of size 56784'.The problem is located in the code here,' p = p.view(bs, self.na, self.nc + 5, self.ny, self.nx).permute(0, 1, 3, 4, 2).contiguous() # prediction',I'm a green hand and I'd appreciate any advice. |
@YRunner this issue is dedicated only to hyperparameter evolution. Is your post in reference to this topic? |
@Chida15 haha, yes, well good job, you've run two different models here, the orange points, and it's showing you the best result highlighted in blue. For this to be effective you want to evolve hundreds of mutations. So I would change the for loop here to at least 200 generations. Line 371 in e77ca7e
|
ok, thanks a lot! |
Hi. I am trying to plot the evolution results but get an error that hyp is not defined. I am applying your latest version of repo. Any hint on that?thanks |
I solved it. |
@sanazss ah yes, you need to define |
I see these params in the cfg file. I would like to use the same parameters . In such case, how would the updated hyp be? hyp = {'giou': 1.582, # giou loss gain
'xy': 4.688, # xy loss gain
'wh': 0.1857, # wh loss gain
'cls': 27.76, # cls loss gain (CE should be around ~1.0)
'cls_pw': 1.446, # cls BCELoss positive_weight
'obj': 21.35, # obj loss gain
'obj_pw': 3.941, # obj BCELoss positive_weight
'iou_t': 0.2635, # iou training threshold
'lr0': 0.002324, # initial learning rate
'lrf': -4., # final LambdaLR learning rate = lr0 * (10 ** lrf)
'momentum': 0.97, # SGD momentum
'weight_decay': 0.0004569, # optimizer weight decay
'hsv_s': 0.5703, # image HSV-Saturation augmentation (fraction)
'hsv_v': 0.3174, # image HSV-Value augmentation (fraction)
'degrees': 1.113, # image rotation (+/- deg)
'translate': 0.06797, # image translation (+/- fraction)
'scale': 0.1059, # image scale (+/- gain)
'shear': 0.5768} # image shear (+/- deg) |
@varghesealex90 the hyp dictionary is pretty self explanatory. The key names are the same in many cases to what you have above, i.e. hyp['momentum'] etc. The parameters we do not use are angle, hue, burn_in. The LR scheduler hyps are set to reduce at 80% and 90% of total epochs with scales of 0.1 and 0.1 already. In any case, the hyps have been evolved to their present state because they improve performance over what you have, so I would not change them unless you are experimenting. |
I have a problem here , |
@DanielChungYi is your error reproducible in a new git clone? |
@glenn-jocher I did clone the latest version of the code, but the problem still there. Please help me. |
@DanielChungYi ok I see. It's likely an issue with your custom dataset, as we can not reproduce this on the coco data. Unless you can supply a minimum reproducible example on the coco dataset there is not much we can do. |
@DanielChungYi also check your cfg and your number of classes, as you might have a mismatch. |
even i am getting the same error |
RuntimeError: shape '[64, 3, 8, 10, 10]' is invalid for input of size 19200 |
did you solved this problem???? |
@glenn-jocher How to use the parameters of evolve.txt in training? |
@hande6688 see the yolov5 tutorials. A new hyp evolution yaml is created that you can point to when training yolov5: python train.py --hyp hyp.evolve.yaml |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@glenn-jocher why the result of me about evolve is like the nayyersaahil28 users, and i had been modified code like fig1-2 , |
@nanhui69 your plots look like this because you have only evolved 1 generation. For the best performing and most recent evolution I would recommend the YOLOv5 hyperparameter evolution tutorial, where the default code evolves 300 generations: YOLOv5 Tutorials
|
@glenn-jocher but i have chaged the code "for _ in range(265): # generations to evolve---------------------------" ? |
@glenn-jocher python3 train.py --epochs 30 --cache-images --evolve & ? should i need specify the my custom weight ,not the pretrainweight? |
@nanhui69 you can evolve any base scenario, including starting from any pretrained weights. There are no constraints. |
|
@nanhui69 your plots look like this because you have only evolved 1 generation. For the best performing and most recent evolution I would recommend the YOLOv5 hyperparameter evolution tutorial, where the default code evolves 300 generations: YOLOv5 Tutorials
|
oh, i will check it again。。。。。 |
when i follow yolov5 steps ,the evolve.txt have only one line? what's that? |
@nanhui69 YOLOv5 evolution will create an evolve.txt file with 300 lines, one for each generation. |
so ,what's wrong with me ? and when evolve.txt exists ,to run evolve style, error appears? |
Hi @glenn-jocher. Can you please indicate how I might modify the fitness function? |
@ananda1996ai you can update your fitness function to any weighting you'd like here before evolving: Lines 12 to 16 in ab7ff9d
Though I would recommend the YOLOv5 🚀 Hyperparameter Evolution tutorial for best results: YOLOv5 Tutorials
|
Thanks @glenn-jocher but I need to work with YoloV3 for my project and the hyperparameter evolution tutorial above indicates the fitness function used for evolve is as described in yolov3/utils.py. Lines 605 to 608 in bd92457
This is different from the utils/metrics.py you mention above. So in the current yolov3 master branch, just updating the fitness function in metrics.py is enough to change the evolution fitness measure, right? |
@sjhsbhqf good question. This is a gain that is applied to the base mutation gain, so values > 1 do not cause any errors despite the comment showing the 0-1 range. This helps test different anchor counts, since an anchor count is an integer small changes will not modify it's value. |
|
Training hyperparameters in this repo are defined in train.py, including augmentation settings:
yolov3/train.py
Lines 35 to 54 in df4f25e
We began with darknet defaults before evolving the values using the result of our hyp evolution code:
python3 train.py --data data/coco.data --weights '' --img-size 320 --epochs 1 --batch-size 64 -- accumulate 1 --evolve
The process is simple: for each new generation, the prior generation with the highest fitness (out of all previous generations) is selected for mutation. All parameters are mutated simultaneously based on a normal distribution with about 20% 1-sigma:
yolov3/train.py
Lines 390 to 396 in df4f25e
Fitness is defined as a weighted mAP and F1 combination at the end of epoch 0, under the assumption that better epoch 0 results correlate to better final results, which may or may not be true.
yolov3/utils/utils.py
Lines 605 to 608 in bd92457
An example snapshot of the results are here. Fitness is on the y axis (higher is better).
from utils.utils import *; plot_evolution_results(hyp)
The text was updated successfully, but these errors were encountered: