def test_seeding(space):
    """Verify that seeding makes sampling deterministic"""
    optimizer = PrimaryAlgo(space, 'hyperband')

    optimizer.seed_rng(1)
    a = optimizer.suggest(1)[0]
    assert not numpy.allclose(a, optimizer.suggest(1)[0])

    optimizer.seed_rng(1)
    assert numpy.allclose(a, optimizer.suggest(1)[0])
Beispiel #2
0
def test_seeding(space):
    """Verify that seeding makes sampling deterministic"""
    bayesian_optimizer = PrimaryAlgo(space, 'bayesianoptimizer')

    bayesian_optimizer.seed_rng(1)
    a = bayesian_optimizer.suggest(1)[0]
    assert not numpy.allclose(a, bayesian_optimizer.suggest(1)[0])

    bayesian_optimizer.seed_rng(1)
    assert numpy.allclose(a, bayesian_optimizer.suggest(1)[0])
Beispiel #3
0
def test_seeding(space, algo):
    """Verify that seeding after init have no effects"""
    optimizer = PrimaryAlgo(space, algo)

    optimizer.seed_rng(1)
    a = optimizer.suggest(1)[0]
    assert not numpy.allclose(a, optimizer.suggest(1)[0])

    optimizer.seed_rng(1)
    assert not numpy.allclose(a, optimizer.suggest(1)[0])
def test_seed_rng(space):
    """Test that algo is seeded properly"""
    optimizer = PrimaryAlgo(space, 'hyperband')
    optimizer.seed_rng(1)
    a = optimizer.suggest(1)
    # Hyperband will always return the full first rung
    assert numpy.allclose(a, optimizer.suggest(1))

    optimizer.seed_rng(2)
    assert not numpy.allclose(a, optimizer.suggest(1))
def test_seeding(space):
    """Verify that seeding makes sampling deterministic"""
    tpe_optimizer = PrimaryAlgo(space, 'tpeoptimizer')

    tpe_optimizer.seed_rng(1)
    a = tpe_optimizer.suggest(1)[0]
    assert not numpy.allclose(a, tpe_optimizer.suggest(1)[0])

    tpe_optimizer.seed_rng(1)
    assert numpy.allclose(a, tpe_optimizer.suggest(1)[0])
Beispiel #6
0
def test_seeding(space):
    """Verify that seeding makes sampling deterministic"""
    optimizer = PrimaryAlgo(space, "meshadaptivedirectsearch")

    optimizer.seed_rng(1)
    a = optimizer.suggest(1)[0]
    with pytest.raises(AssertionError):
        numpy.testing.assert_equal(a, optimizer.suggest(1)[0])

    optimizer.seed_rng(1)
    numpy.testing.assert_equal(a, optimizer.suggest(1)[0])
Beispiel #7
0
def test_set_state(space):
    """Verify that resetting state makes sampling deterministic"""
    bayesian_optimizer = PrimaryAlgo(space, 'bayesianoptimizer')

    bayesian_optimizer.seed_rng(1)
    state = bayesian_optimizer.state_dict
    a = bayesian_optimizer.suggest(1)[0]
    assert not numpy.allclose(a, bayesian_optimizer.suggest(1)[0])

    bayesian_optimizer.set_state(state)
    assert numpy.allclose(a, bayesian_optimizer.suggest(1)[0])
def test_set_state(space):
    """Verify that resetting state makes sampling deterministic"""
    optimizer = PrimaryAlgo(space, 'hyperband')

    optimizer.seed_rng(1)
    state = optimizer.state_dict
    a = optimizer.suggest(1)[0]
    assert not numpy.allclose(a, optimizer.suggest(1)[0])

    optimizer.set_state(state)
    assert numpy.allclose(a, optimizer.suggest(1)[0])
def test_set_state(space):
    """Test that state is reset properly"""
    optimizer = PrimaryAlgo(space, 'hyperband')
    optimizer.seed_rng(1)
    state = optimizer.state_dict
    points = optimizer.suggest(1)
    # Hyperband will always return the full first rung
    assert numpy.allclose(points, optimizer.suggest(1))

    optimizer.seed_rng(2)
    assert not numpy.allclose(points, optimizer.suggest(1))

    optimizer.set_state(state)
    assert numpy.allclose(points, optimizer.suggest(1))