コード例 #1
0
ファイル: bandits.py プロジェクト: CnrLwlss/hyperopt
def n_arms(N=2):
    """
    Each arm yields a reward from a different Gaussian.

    The correct arm is arm 0.

    """
    x = hp_choice('x', [0, 1])
    reward_mus = as_apply([-1] + [0] * (N - 1))
    reward_sigmas = as_apply([1] * N)
    return {'loss': scope.normal(reward_mus[x], reward_sigmas[x]),
            'loss_variance': 1.0}
コード例 #2
0
ファイル: bandits.py プロジェクト: GRSEB9S/optunity-benchmark
def n_arms(N=2):
    """
    Each arm yields a reward from a different Gaussian.

    The correct arm is arm 0.

    """
    x = hp_choice('x', [0, 1])
    reward_mus = as_apply([-1] + [0] * (N - 1))
    reward_sigmas = as_apply([1] * N)
    return {
        'loss': scope.normal(reward_mus[x], reward_sigmas[x]),
        'loss_variance': 1.0
    }
コード例 #3
0
def n_arms(N=2):
    """
    Each arm yields a reward from a different Gaussian.

    The correct arm is arm 0.

    """
    rng = np.random.RandomState(123)
    x = hp_choice('x', [0, 1])
    reward_mus = as_apply([-1] + [0] * (N - 1))
    reward_sigmas = as_apply([1] * N)
    return {
        'loss': scope.normal(reward_mus[x], reward_sigmas[x], rng=rng),
        'loss_variance': 1.0,
        'status': base.STATUS_OK
    }
コード例 #4
0
def gauss_wave():
    """
    Essentially, this is a high-frequency sinusoidal function plus a broad quadratic.
    One variable controls the position along the curve.
    The binary variable determines whether the sinusoidal is shifted by pi.

    So there are actually two maxima in this problem, it's just one is more
    probable.  The tricky thing here is dealing with the fact that there are two
    variables and one is discrete.

    """

    x = hp_uniform('x', -20, 20)
    t = hp_choice('curve', [x, x + np.pi])
    f1 = scope.sin(t)
    f2 = 2 * scope.exp(-(t / 5.0)**2)
    return {'loss': -(f1 + f2), 'status': base.STATUS_OK}
コード例 #5
0
def many_dists():
    a = hp_choice('a', [0, 1, 2])
    b = hp_randint('b', 10)
    c = hp_uniform('c', 4, 7)
    d = hp_loguniform('d', -2, 0)
    e = hp_quniform('e', 0, 10, 3)
    f = hp_qloguniform('f', 0, 3, 2)
    g = hp_normal('g', 4, 7)
    h = hp_lognormal('h', -2, 2)
    i = hp_qnormal('i', 0, 10, 2)
    j = hp_qlognormal('j', 0, 2, 1)
    k = hp_pchoice('k', [(.1, 0), (.9, 1)])
    z = a + b + c + d + e + f + g + h + i + j + k
    return {
        'loss': scope.float(scope.log(1e-12 + z**2)),
        'status': base.STATUS_OK
    }
コード例 #6
0
ファイル: bandits.py プロジェクト: CnrLwlss/hyperopt
def gauss_wave2():
    """
    Variant of the GaussWave problem in which noise is added to the score
    function, and there is an option to either have no sinusoidal variation, or
    a negative cosine with variable amplitude.

    Immediate local max is to sample x from spec and turn off the neg cos.
    Better solution is to move x a bit to the side, turn on the neg cos and turn
    up the amp to 1.
    """

    var = .1
    x = hp_uniform('x', -20, 20)
    amp = hp_uniform('amp', 0, 1)
    t = (scope.normal(0, var) + 2 * scope.exp(-(x / 5.0) ** 2))
    return {'loss': - hp_choice('hf', [t, t + scope.sin(x) * amp]),
            'loss_variance': var}
コード例 #7
0
ファイル: bandits.py プロジェクト: CnrLwlss/hyperopt
def gauss_wave():
    """
    Essentially, this is a high-frequency sinusoidal function plus a broad quadratic.
    One variable controls the position along the curve.
    The binary variable determines whether the sinusoidal is shifted by pi.

    So there are actually two maxima in this problem, it's just one is more
    probable.  The tricky thing here is dealing with the fact that there are two
    variables and one is discrete.

    """

    x = hp_uniform('x', -20, 20)
    t = hp_choice('curve', [x, x + np.pi])
    f1 = scope.sin(t)
    f2 = 2 * scope.exp(-(t / 5.0) ** 2)
    return {'loss': - (f1 + f2)}
コード例 #8
0
ファイル: bandits.py プロジェクト: GRSEB9S/optunity-benchmark
def gauss_wave2():
    """
    Variant of the GaussWave problem in which noise is added to the score
    function, and there is an option to either have no sinusoidal variation, or
    a negative cosine with variable amplitude.

    Immediate local max is to sample x from spec and turn off the neg cos.
    Better solution is to move x a bit to the side, turn on the neg cos and turn
    up the amp to 1.
    """

    var = .1
    x = hp_uniform('x', -20, 20)
    amp = hp_uniform('amp', 0, 1)
    t = (scope.normal(0, var) + 2 * scope.exp(-(x / 5.0)**2))
    return {
        'loss': -hp_choice('hf', [t, t + scope.sin(x) * amp]),
        'loss_variance': var
    }
コード例 #9
0
def q1_choice():
    o_x = hp_choice('o_x', [
        (-3, hp_uniform('x_neg', -5, 5)),
        (3, hp_uniform('x_pos', -5, 5)),
    ])
    return {'loss': (o_x[0] - o_x[1])**2, 'status': base.STATUS_OK}
コード例 #10
0
ファイル: bandits.py プロジェクト: CnrLwlss/hyperopt
def q1_choice():
    o_x = hp_choice('o_x', [
        (-3, hp_uniform('x_neg', -5, 5)),
        ( 3, hp_uniform('x_pos', -5, 5)),
        ])
    return {'loss': (o_x[0] - o_x[1])  ** 2}
コード例 #11
0
ファイル: bandits.py プロジェクト: GRSEB9S/optunity-benchmark
def q1_choice():
    o_x = hp_choice('o_x', [
        (-3, hp_uniform('x_neg', -5, 5)),
        (3, hp_uniform('x_pos', -5, 5)),
    ])
    return {'loss': (o_x[0] - o_x[1])**2}