updates
This commit is contained in:
parent
c6b44befde
commit
01dbdc45d7
17
train.py
17
train.py
|
@ -457,20 +457,21 @@ if __name__ == '__main__':
|
||||||
x = (x * w.reshape(n, 1)).sum(0) / w.sum() # new parent
|
x = (x * w.reshape(n, 1)).sum(0) / w.sum() # new parent
|
||||||
|
|
||||||
# Mutate
|
# Mutate
|
||||||
mutate_version = 2
|
method = 2
|
||||||
np.random.seed(int(time.time()))
|
|
||||||
s = 0.2 # 20% sigma
|
s = 0.2 # 20% sigma
|
||||||
|
np.random.seed(int(time.time()))
|
||||||
g = np.array([1, 1, 1, 1, 1, 1, 1, 0, .1, 1, 0, 1, 1, 1, 1, 1, 1, 1]) # gains
|
g = np.array([1, 1, 1, 1, 1, 1, 1, 0, .1, 1, 0, 1, 1, 1, 1, 1, 1, 1]) # gains
|
||||||
ng = len(g)
|
ng = len(g)
|
||||||
if mutate_version == 1:
|
if method == 1:
|
||||||
s *= np.random.random() # sigma
|
v = (np.random.randn(ng) * np.random.random() * g * s + 1) ** 2.0
|
||||||
v = (np.random.randn(ng) * g * s + 1) ** 2.0 # plt.hist(x.ravel(), 300)
|
elif method == 2:
|
||||||
else:
|
v = (np.random.randn(ng) * np.random.random(ng) * g * s + 1) ** 2.0
|
||||||
|
elif method == 3:
|
||||||
v = np.ones(ng)
|
v = np.ones(ng)
|
||||||
while all(v == 1): # mutate untill a change occurs (prevent duplicates)
|
while all(v == 1): # mutate untill a change occurs (prevent duplicates)
|
||||||
r = (np.random.random(ng) < 0.1) * np.random.randn(ng) # 10% mutation probability
|
r = (np.random.random(ng) < 0.1) * np.random.randn(ng) # 10% mutation probability
|
||||||
v = (g * s * r + 1) ** 2.0 # plt.hist(x.ravel(), 300)
|
v = (g * s * r + 1) ** 2.0
|
||||||
for i, k in enumerate(hyp.keys()):
|
for i, k in enumerate(hyp.keys()): # plt.hist(v.ravel(), 300)
|
||||||
hyp[k] = x[i + 7] * v[i] # mutate
|
hyp[k] = x[i + 7] * v[i] # mutate
|
||||||
|
|
||||||
# Clip to limits
|
# Clip to limits
|
||||||
|
|
Loading…
Reference in New Issue