Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Fix NoneType object bug in Metis #814

Merged
merged 22 commits into from
Mar 6, 2019
Merged
Changes from all commits
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
14 changes: 9 additions & 5 deletions src/sdk/pynni/nni/metis_tuner/metis_tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def __init__(self, optimize_mode="maximize", no_resampling=True, no_candidates=T
self.samples_x = []
self.samples_y = []
self.samples_y_aggregation = []
self.history_parameters = set()
self.history_parameters = []
self.space = None
self.no_resampling = no_resampling
self.no_candidates = no_candidates
Expand Down Expand Up @@ -131,7 +131,7 @@ def update_search_space(self, search_space):
except Exception as ex:
logger.exception(ex)
raise RuntimeError("The format search space contains \
some key that didn't define in key_order." )
some key that didn't define in key_order." )

if key_type == 'quniform':
if key_range[2] == 1:
Expand Down Expand Up @@ -386,7 +386,7 @@ def _selection(self, samples_x, samples_y_aggregation, samples_y,

if next_improvement > temp_improvement:
logger.info("DEBUG: \"next_candidate\" changed: \
lowest mu might reduce from %f (%s) to %f (%s), %s\n" %\
lowest mu might reduce from %f (%s) to %f (%s), %s\n" %\
lm_current['expected_mu'], str(lm_current['hyperparameter']),\
threads_result['expected_lowest_mu'],\
str(threads_result['candidate']['hyperparameter']),\
Expand All @@ -412,8 +412,12 @@ def _selection(self, samples_x, samples_y_aggregation, samples_y,
outputs = self._pack_output(lm_current['hyperparameter'])
ap = random.uniform(0, 1)
if outputs in self.history_parameters or ap<=self.exploration_probability:
outputs = self._pack_output(next_candidate['hyperparameter'])
self.history_parameters.add(outputs)
if next_candidate is not None:
outputs = self._pack_output(next_candidate['hyperparameter'])
else:
random_parameter = _rand_init(self.x_bounds, self.x_types, 1)[0]
outputs = self._pack_output(random_parameter)
self.history_parameters.append(outputs)
return outputs


Expand Down