Exemple #1
0
    def testExpandSearchSpace(self):
        exp = {"test-exp": {"run": "f1", "config": {"a": {"d": "dummy"}}}}
        space = SearchSpace([
            DiscreteSpace("a.b.c", [1, 2]),
            DiscreteSpace("a.d", ["a", "b"]),
        ])
        searcher = GridSearch(space, "reward")
        searcher.add_configurations(exp)
        trials = searcher.next_trials()

        self.assertEqual(len(trials), 4)
        self.assertTrue(trials[0].config["a"]["b"]["c"] in [1, 2])
        self.assertTrue(trials[1].config["a"]["d"] in ["a", "b"])
Exemple #2
0
    def testExpandSearchSpace(self):
        exp = {"test-exp": {"run": "f1", "config": {"a": {'d': 'dummy'}}}}
        space = SearchSpace([
            DiscreteSpace('a.b.c', [1, 2]),
            DiscreteSpace('a.d', ['a', 'b']),
        ])
        searcher = GridSearch(space, 'reward')
        searcher.add_configurations(exp)
        trials = searcher.next_trials()

        self.assertEqual(len(trials), 4)
        self.assertTrue(trials[0].config['a']['b']['c'] in [1, 2])
        self.assertTrue(trials[1].config['a']['d'] in ['a', 'b'])
Exemple #3
0
    def testSearchRound(self):
        exp = {"test-exp": {"run": "f1", "config": {"a": {"d": "dummy"}}}}
        space = SearchSpace([
            DiscreteSpace("a.b.c", [1, 2]),
            DiscreteSpace("a.d", ["a", "b"]),
        ])
        searcher = GridSearch(space, "reward")
        searcher.add_configurations(exp)
        trials = searcher.next_trials()

        self.assertEqual(len(searcher.next_trials()), 0)
        for trial in trials[1:]:
            searcher.on_trial_complete(trial.trial_id)
        searcher.on_trial_complete(trials[0].trial_id, error=True)

        self.assertTrue(searcher.is_finished())
    def testSearchRound(self):
        exp = {"test-exp": {"run": "f1", "config": {"a": {'d': 'dummy'}}}}
        space = SearchSpace([
            DiscreteSpace('a.b.c', [1, 2]),
            DiscreteSpace('a.d', ['a', 'b']),
        ])
        searcher = GridSearch(space, 'reward')
        searcher.add_configurations(exp)
        trials = searcher.next_trials()

        self.assertEqual(len(searcher.next_trials()), 0)
        for trial in trials[1:]:
            searcher.on_trial_complete(trial.trial_id)
        searcher.on_trial_complete(trials[0].trial_id, error=True)

        self.assertTrue(searcher.is_finished())
Exemple #5
0
    def testBestTrial(self):
        exp = {"test-exp": {"run": "f1", "config": {"a": {"d": "dummy"}}}}
        space = SearchSpace([
            DiscreteSpace("a.b.c", [1, 2]),
            DiscreteSpace("a.d", ["a", "b"]),
        ])
        searcher = GridSearch(space, "reward")
        searcher.add_configurations(exp)
        trials = searcher.next_trials()

        self.assertEqual(len(searcher.next_trials()), 0)
        for i, trial in enumerate(trials):
            rewards = list(range(i, i + 10))
            random.shuffle(rewards)
            for reward in rewards:
                searcher.on_trial_result(trial.trial_id, {"reward": reward})

        best_trial = searcher.get_best_trial()
        self.assertEqual(best_trial, trials[-1])
        self.assertEqual(best_trial.best_result["reward"], 3 + 10 - 1)
Exemple #6
0
    def testBestTrial(self):
        exp = {"test-exp": {"run": "f1", "config": {"a": {'d': 'dummy'}}}}
        space = SearchSpace([
            DiscreteSpace('a.b.c', [1, 2]),
            DiscreteSpace('a.d', ['a', 'b']),
        ])
        searcher = GridSearch(space, 'reward')
        searcher.add_configurations(exp)
        trials = searcher.next_trials()

        self.assertEqual(len(searcher.next_trials()), 0)
        for i, trial in enumerate(trials):
            rewards = [x for x in range(i, i + 10)]
            random.shuffle(rewards)
            for reward in rewards:
                searcher.on_trial_result(trial.trial_id, {"reward": reward})

        best_trial = searcher.get_best_trial()
        self.assertEqual(best_trial, trials[-1])
        self.assertEqual(best_trial.best_result['reward'], 3 + 10 - 1)