コード例 #1
0
def test_continuous_uniform():
    h1 = hp.UniformContinuousHyperParameter('h1', 0.0, 1.0)

    assert h1.name == 'h1'
    assert h1.num_choices == 0
    assert h1.min_value == 0.0
    assert h1.max_value == 1.0
    assert repr(h1)
コード例 #2
0
def test_continuous_uniform_encode_decode_log_space():
    h1 = hp.UniformContinuousHyperParameter('h1', 0.0, 1.0, log_encode=True)
    sample = h1.sample()

    encoded = h1.encode(sample)
    assert encoded == -0.5999965965916227

    decoded = h1.decode(encoded)
    assert decoded == sample
コード例 #3
0
def test_continuous_uniform_encode_decode():
    h1 = hp.UniformContinuousHyperParameter('h1', 0.0, 1.0)
    sample = h1.sample()

    encoded = h1.encode(sample)
    assert encoded == sample

    decoded = h1.decode(encoded)
    assert decoded == sample
コード例 #4
0
def test_uniform_serialization_deserialization():
    h1 = hp.UniformContinuousHyperParameter('h1', 0.0, 1.0, log_encode=True)

    config = h1.get_config()
    assert 'name' in config
    assert 'min_value' in config
    assert 'max_value' in config
    assert 'log_encode' in config

    min, max = config['min_value'], config['max_value']
    assert min == 0.0
    assert max == 1.0

    h2 = hp.UniformContinuousHyperParameter.load_from_config(config)
    config = h2.get_config()

    assert 'name' in config
    assert 'min_value' in config
    assert 'max_value' in config
    assert 'log_encode' in config

    min, max = config['min_value'], config['max_value']
    assert min == 0.0
    assert max == 1.0
コード例 #5
0
def test_continuous_uniform_sample():
    h1 = hp.UniformContinuousHyperParameter('h1', 0.0, 1.0)
    sample = h1.sample()
    assert 0.0 <= sample and sample < 1.0
コード例 #6
0
def test_continuous_uniform_no_values():
    with pytest.raises(ValueError):
        hp.UniformContinuousHyperParameter(None, 0, 1)

    with pytest.raises(ValueError):
        hp.UniformContinuousHyperParameter('h1', None, None)
コード例 #7
0
def get_hyperparameter_list():
    h1 = hp.DiscreteHyperParameter('h1', [0, 1, 2])
    h2 = hp.DiscreteHyperParameter('h2', [3, 4, 5, 6])
    h3 = hp.UniformContinuousHyperParameter('h3', 7, 10)
    h4 = hp.DiscreteHyperParameter('h4', ['v1', 'v2'])
    return [h1, h2, h3, h4]
コード例 #8
0
ファイル: test_keras_engine.py プロジェクト: mahmud83/pyshac
def get_branin_hyperparameter_list():
    h1 = hp.UniformContinuousHyperParameter('h1', -5.0, 10.0)
    h2 = hp.UniformContinuousHyperParameter('h2', 0.0, 15.0)
    return [h1, h2]
コード例 #9
0
ファイル: test_keras_engine.py プロジェクト: mahmud83/pyshac
def get_hartmann6_hyperparameter_list():
    h = [hp.UniformContinuousHyperParameter('h%d' % i, 0.0, 1.0) for i in range(6)]
    return h