Skip to content

Commit

Permalink
Force non-zero hyp evolution weights w (#3748)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelAnderson-AI committed Jun 23, 2021
1 parent f7c9f53 commit 3ebe588
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 3ebe588

Please sign in to comment.