updates
This commit is contained in:
parent
f18913736b
commit
3de61b1fa5
4
train.py
4
train.py
|
@ -452,9 +452,9 @@ if __name__ == '__main__':
|
||||||
x = x[np.argsort(-fitness(x))][:n] # top n mutations
|
x = x[np.argsort(-fitness(x))][:n] # top n mutations
|
||||||
if parent == 'single' or len(x) == 1:
|
if parent == 'single' or len(x) == 1:
|
||||||
x = x[random.randint(0, n - 1)] # select one of the top n
|
x = x[random.randint(0, n - 1)] # select one of the top n
|
||||||
elif parent == 'weighted': # weighted combination
|
elif parent == 'weighted':
|
||||||
w = fitness(x) - fitness(x).min() # weights
|
w = fitness(x) - fitness(x).min() # weights
|
||||||
x = (x * w.reshape(n, 1)).sum(0) / w.sum() # new parent
|
x = (x * w.reshape(n, 1)).sum(0) / w.sum() # select weighted combination
|
||||||
|
|
||||||
# Mutate
|
# Mutate
|
||||||
method = 3
|
method = 3
|
||||||
|
|
Loading…
Reference in New Issue