Fix Tuner._mutate RNG collisions for sub-second iterations (#24451)
Signed-off-by: Onuralp SEZER <onuralp@ultralytics.com> Co-authored-by: Onuralp SEZER <onuralp@ultralytics.com>
This commit is contained in:
parent
a462bb65c8
commit
166604e39d
@ -406,7 +406,7 @@ class Tuner:
|
||||
|
||||
# Mutate if we have data, otherwise use defaults
|
||||
if x is not None:
|
||||
np.random.seed(int(time.time()))
|
||||
rng = np.random.default_rng()
|
||||
ng = len(self.space)
|
||||
|
||||
# Crossover
|
||||
@ -416,8 +416,8 @@ class Tuner:
|
||||
gains = np.array([v[2] if len(v) == 3 else 1.0 for v in self.space.values()]) # gains 0-1
|
||||
factors = np.ones(ng)
|
||||
while np.all(factors == 1): # mutate until a change occurs (prevent duplicates)
|
||||
mask = np.random.random(ng) < mutation
|
||||
step = np.random.randn(ng) * (sigma * gains)
|
||||
mask = rng.random(ng) < mutation
|
||||
step = rng.standard_normal(ng) * (sigma * gains)
|
||||
factors = np.where(mask, np.exp(step), 1.0).clip(0.25, 4.0)
|
||||
hyp = {k: float(genes[i] * factors[i]) for i, k in enumerate(self.space.keys())}
|
||||
else:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user