def import_data(self, data): # for resuming experiment for trial in data: param = format_parameters(trial['parameter'], self.space) loss = trial['value'] if self.optimize_mode is OptimizeMode.Maximize: loss = -trial['value'] for key, value in param.items(): self._history[key].append(Record(value, loss)) _logger.info(f'Replayed {len(data)} trials')
def import_data(self, data): # for resuming experiment if isinstance(data, str): data = nni.load(data) for trial in data: if isinstance(trial, str): trial = nni.load(trial) param = format_parameters(trial['parameter'], self.space) loss = trial['value'] if isinstance(loss, dict) and 'default' in loss: loss = loss['default'] if self.optimize_mode is OptimizeMode.Maximize: loss = -loss for key, value in param.items(): self._history[key].append(Record(value, loss)) _logger.info(f'Replayed {len(data)} trials')
def test_resuming(): internal_space = format_search_space(user_space) assert format_parameters(user_params_1, internal_space) == resume_params_1 assert format_parameters(user_params_2, internal_space) == resume_params_2 assert format_parameters(user_params_3, internal_space) == resume_params_3