Update `np.random.random()` to `random.random()` (#3967)
Browse files- utils/autoanchor.py +3 -1
utils/autoanchor.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
# Auto-anchor utils
|
2 |
|
|
|
|
|
3 |
import numpy as np
|
4 |
import torch
|
5 |
import yaml
|
@@ -149,7 +151,7 @@ def kmean_anchors(path='./data/coco128.yaml', n=9, img_size=640, thr=4.0, gen=10
|
|
149 |
for _ in pbar:
|
150 |
v = np.ones(sh)
|
151 |
while (v == 1).all(): # mutate until a change occurs (prevent duplicates)
|
152 |
-
v = ((npr.random(sh) < mp) *
|
153 |
kg = (k.copy() * v).clip(min=2.0)
|
154 |
fg = anchor_fitness(kg)
|
155 |
if fg > f:
|
|
|
1 |
# Auto-anchor utils
|
2 |
|
3 |
+
import random
|
4 |
+
|
5 |
import numpy as np
|
6 |
import torch
|
7 |
import yaml
|
|
|
151 |
for _ in pbar:
|
152 |
v = np.ones(sh)
|
153 |
while (v == 1).all(): # mutate until a change occurs (prevent duplicates)
|
154 |
+
v = ((npr.random(sh) < mp) * random.random() * npr.randn(*sh) * s + 1).clip(0.3, 3.0)
|
155 |
kg = (k.copy() * v).clip(min=2.0)
|
156 |
fg = anchor_fitness(kg)
|
157 |
if fg > f:
|