Skip to content

Commit

Permalink
Force non-zero hyp evolution weights w
Browse files Browse the repository at this point in the history
Fix for #3741
  • Loading branch information
glenn-jocher committed Jun 23, 2021
1 parent fdc2239 commit e095b74
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e095b74

Please sign in to comment.