Force non-zero hyp evolution weights `w` (#3748)
Browse filesFix for https://github.com/ultralytics/yolov5/issues/3741
train.py
CHANGED
@@ -608,7 +608,7 @@ def main(opt):
|
|
608 |
x = np.loadtxt('evolve.txt', ndmin=2)
|
609 |
n = min(5, len(x)) # number of previous results to consider
|
610 |
x = x[np.argsort(-fitness(x))][:n] # top n mutations
|
611 |
-
w = fitness(x) - fitness(x).min() # weights
|
612 |
if parent == 'single' or len(x) == 1:
|
613 |
# x = x[random.randint(0, n - 1)] # random selection
|
614 |
x = x[random.choices(range(n), weights=w)[0]] # weighted selection
|
|
|
608 |
x = np.loadtxt('evolve.txt', ndmin=2)
|
609 |
n = min(5, len(x)) # number of previous results to consider
|
610 |
x = x[np.argsort(-fitness(x))][:n] # top n mutations
|
611 |
+
w = fitness(x) - fitness(x).min() + 1E-6 # weights (sum > 0)
|
612 |
if parent == 'single' or len(x) == 1:
|
613 |
# x = x[random.randint(0, n - 1)] # random selection
|
614 |
x = x[random.choices(range(n), weights=w)[0]] # weighted selection
|