glenn-jocher commited on
Commit
ae4261c
·
unverified ·
1 Parent(s): fdc2239

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

Browse files

Fix for https://github.com/ultralytics/yolov5/issues/3741

Files changed (1) hide show
  1. train.py +1 -1
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