This commit is contained in:
Glenn Jocher 2020-01-27 16:52:40 -05:00
parent cb0f4bbfe7
commit 72680a5992
2 changed files with 4 additions and 3 deletions

View File

@ -459,7 +459,7 @@ if __name__ == '__main__':
# Mutate
method = 3
s = 0.3 # 20% sigma
s = 0.3 # 30% 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
ng = len(g)

View File

@ -798,9 +798,10 @@ def kmean_anchors(path='../coco/train2017.txt', n=9, img_size=(320, 640)):
# Evolve
wh = torch.Tensor(wh)
f, ng = fitness(thr, wh, k), 1000 # fitness, generations
f, ng = fitness(thr, wh, k), 1000 # fitness, mutation probability, generations
for _ in tqdm(range(ng), desc='Evolving anchors'):
kg = (k.copy() * (1 + np.random.random() * np.random.randn(*k.shape) * 0.30)).clip(min=2.0)
v = ((np.random.random(n) < 0.1) * np.random.randn(n) * 0.3 + 1) ** 2.0 # 0.1 mutation probability, 0.3 sigma
kg = (k.copy() * v).clip(min=2.0)
fg = fitness(thr, wh, kg)
if fg > f:
f, k = fg, kg.copy()