Fixed 'meta' and 'hyp' may out of order when using evolve#4657
Fixed 'meta' and 'hyp' may out of order when using evolve#4657glenn-jocher merged 2 commits intoultralytics:masterfrom imyhxy:master
Conversation
|
@imyhxy I reviewed the code here, but I don't see any problem in master. Even if meta and hyp are out of order, the Lines 581 to 586 in fad57c2 |
|
@imyhxy took a second look, yes you are right there is a latent bug! For some reason I was focusing on the other section of code above, not sure why. But yes in the initial gain assignment there is a danger of misalignment, if not now then possibly in the future. Your fix looks good I think, it enforces alignment again based off the key directly. |
|
@imyhxy PR is merged. Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐ |
…s#4657) * Fixed 'meta' and 'hyp' may out of order when using evolve * Update gitignore
…s#4657) * Fixed 'meta' and 'hyp' may out of order when using evolve * Update gitignore
Hi, there.
Recently I have try to use the
evolvefeature of yolov5, and found out that the keys ofmetaandhypmaybe miss align intrain.py. The reason is that, firstly, dictionary in python won't gurantee order. Secondly, theanchorshyper-parameter is possible add to thehypdictionary in runtime (when it not be defined in hyp.yaml). And after that, all hyper-parameters afteranchorswill miss align betweenmetaandhyp.So, I just use the
hypkeys to get bothgain, which will maintain the order.We can validate this by set all
gainofmetato 0 except one that afteranchorskey. Usetranslatekey as an example (becausetranslateandscaleare initialized with non-zero value, if a hyper-parameter initialize with 0 and it won't get mutation), it will evolve on thescalekey:🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Improving the
.gitignoreand genetic algorithm in YOLOv5.📊 Key Changes
.gitignoreto explicitly ignore thewandb/directory.train.pyto ensure hyp keys align with meta values during mutation.🎯 Purpose & Impact
wandbdirectories.The changes will make collaborating on YOLOv5 codebase cleaner and may lead to improved performance of models trained with YOLOv5 thanks to the more robust hyperparameter tuning process. 🧬✨