Force non-zero hyp evolution weights `w` (#3748)

Fix for https://github.com/ultralytics/yolov5/issues/3741
pull/3759/head
Glenn Jocher 2021-06-23 12:56:22 +02:00 committed by GitHub
parent fdc22398fa
commit ae4261c774
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -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