def __init__(self): Base.__init__( self, dict( x=scope.uniform(-20, 20), hf=scope.one_of(dict(kind="raw"), dict(kind="negcos", amp=scope.uniform(0, 1))), ), )
def config0(): p0 = scope.uniform(0, 1) p1 = scope.uniform(2, 3) p2 = scope.one_of(-1, p0) p3 = scope.one_of(-2, p1) p4 = 1 p5 = [3, 4, p0] d = locals() del d['p1'] # -- don't sample p1 all the time s = as_apply(d) return s
def config0(): p0 = scope.uniform(0, 1) p1 = scope.uniform(2, 3) p2 = scope.one_of(-1, p0) p3 = scope.one_of(-2, p1) p4 = 1 p5 = [3, 4, p0] p6 = scope.one_of(-3, p1) d = locals() d['p1'] = None # -- don't sample p1 all the time, only if p3 says so s = as_apply(d) return s
def test_repeatable(): u = scope.uniform(0, 1) aa = as_apply(dict(u=u, n=scope.normal(5, 0.1), l=[0, 1, scope.one_of(2, 3), u])) dd1 = sample(aa, np.random.RandomState(3)) dd2 = sample(aa, np.random.RandomState(3)) dd3 = sample(aa, np.random.RandomState(4)) assert dd1 == dd2 assert dd1 != dd3
def test_repeatable(): u = scope.uniform(0, 1) aa = as_apply( dict(u=u, n=scope.normal(5, 0.1), l=[0, 1, scope.one_of(2, 3), u])) dd1 = sample(aa, np.random.RandomState(3)) dd2 = sample(aa, np.random.RandomState(3)) dd3 = sample(aa, np.random.RandomState(4)) assert dd1 == dd2 assert dd1 != dd3
def __init__(self): d = dict( # -- alphabetical order lu = scope.loguniform(-2, 2), qlu = scope.qloguniform(np.log(0.01), np.log(20), 2), qu = scope.quniform(-4.999, 5, 1), u = scope.uniform(0, 10), ) base.Bandit.__init__(self, as_apply(d))
def test_sample(): u = scope.uniform(0, 1) aa = as_apply(dict(u=u, n=scope.normal(5, 0.1), l=[0, 1, scope.one_of(2, 3), u])) print aa dd = sample(aa, np.random.RandomState(3)) assert 0 < dd["u"] < 1 assert 4 < dd["n"] < 6 assert dd["u"] == dd["l"][3] assert dd["l"][:2] == (0, 1) assert dd["l"][2] in (2, 3)
def test_sample(): u = scope.uniform(0, 1) aa = as_apply( dict(u=u, n=scope.normal(5, 0.1), l=[0, 1, scope.one_of(2, 3), u])) print aa dd = sample(aa, np.random.RandomState(3)) assert 0 < dd['u'] < 1 assert 4 < dd['n'] < 6 assert dd['u'] == dd['l'][3] assert dd['l'][:2] == (0, 1) assert dd['l'][2] in (2, 3)
def hp_uniform(label, *args, **kwargs): if not isinstance(label, basestring): raise TypeError('require string label') return scope.float( scope.hyperopt_param(label, scope.uniform(*args, **kwargs)))
def hp_uniform(label, *args, **kwargs): return scope.float( scope.hyperopt_param(label, scope.uniform(*args, **kwargs)))
def config1(): p0 = scope.uniform(0, 1) return as_apply(locals())
def __init__(self, sigma=10): """ The second peak is at x=-10. The prior mean is 0. """ Base.__init__(self, dict(x=scope.uniform(-15, 15)))
def __init__(self): Base.__init__(self, dict(x=scope.uniform(-5, 5)))
def hp_uniform(label, *args, **kwargs): if not isinstance(label, basestring): raise TypeError("require string label") return scope.float(scope.hyperopt_param(label, scope.uniform(*args, **kwargs)))
def __init__(self): Base.__init__(self, dict(curve=scope.one_of(0, 1), x=scope.uniform(-20, 20)))