From 29f2c8b8b72982eaecc9d88ce99bca8c84b4ac48 Mon Sep 17 00:00:00 2001 From: SecretStar112 Date: Wed, 23 Jun 2021 12:56:22 +0200 Subject: [PATCH] Force non-zero hyp evolution weights `w` (#3748) Fix for https://github.com/ultralytics/yolov5/issues/3741 --- train.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train.py b/train.py index e934441..ba84b43 100644 --- a/train.py +++ b/train.py @@ -608,7 +608,7 @@ def main(opt): x = np.loadtxt('evolve.txt', ndmin=2) n = min(5, len(x)) # number of previous results to consider x = x[np.argsort(-fitness(x))][:n] # top n mutations - w = fitness(x) - fitness(x).min() # weights + w = fitness(x) - fitness(x).min() + 1E-6 # weights (sum > 0) if parent == 'single' or len(x) == 1: # x = x[random.randint(0, n - 1)] # random selection x = x[random.choices(range(n), weights=w)[0]] # weighted selection