Skip to content

Add TPE algorithm into Orion #381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/functional/algos/test_algos.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def test_simple(monkeypatch, config_file):
@pytest.mark.usefixtures("null_db_instances")
def test_random_stop(monkeypatch):
"""Test a simple usage scenario."""
# TODO: TPE should support this case once discrete is added,
# then parametrized config_file should be used
config_file = 'random_config.yaml'
monkeypatch.chdir(os.path.dirname(os.path.abspath(__file__)))
orion.core.cli.main(["hunt", "--config", config_file,
Expand Down
9 changes: 6 additions & 3 deletions tests/unittests/algo/test_tpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ def test_adaptive_parzen_normal_estimator_weight():
# prior weight
mus, sigmas, weights = adaptive_parzen_estimator(obs_mus, low, high, prior_weight=0.5,
equal_weight=False, flat_num=25)
print(weights)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left-over print. :)

prior_pos = numpy.searchsorted(mus, 2)
assert numpy.all(weights[:30 - 25] == (numpy.linspace(1.0 / 30, 1.0, num=30 - 25) / 31))
assert numpy.all(weights[33 - 25:prior_pos] == 1 / 31)
assert weights[prior_pos] == 0.5 / 31
assert numpy.all(weights[31 - prior_pos:] == weights[-1])
assert numpy.all(weights[prior_pos + 1:] == 1 / 31)
assert numpy.all(sigmas == 6 / 10)


Expand Down Expand Up @@ -170,7 +173,7 @@ def test_sample(self, tpe):
def test_get_loglikelis(self):
"""Test to get log likelis of points"""
mus = numpy.linspace(-10, 10, num=10, endpoint=False)
weights = [0.009, 0.006, 0.1, 0.02, 0.004, 0.26, 0.04, 0.5, 0.06, 0.001]
weights = [0.009, 0.006, 0.1, 0.02, 0.003, 0.26, 0.04, 0.5, 0.061, 0.001]

sigmas = [0.00001] * 10
gmm_sampler = GMMSampler(tpe, mus, sigmas, -11, 9, weights)
Expand Down Expand Up @@ -256,7 +259,7 @@ def test_unsupported_space(self):
assert 'TPE now only supports 1D shape' in str(ex.value)

def test_split_trials(self, tpe):
"""Test observed trails can be split based on TPE gamma"""
"""Test observed trials can be split based on TPE gamma"""
space = Space()
dim1 = Real('yolo1', 'uniform', -3, 6)
space.register(dim1)
Expand Down