You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just started using the Recbole library. I want to do hyper parameter optimization on AutoInt which is a context-aware model. I did a tutorial before and I didn't keep the parameters in a .yaml file, but instead with the dictionary I named parameter_dict = {...} as follows:
I created Config by writing config = Config(model='AutoInt', dataset='recbole_format', config_dict=parameter_dict) code and I achieved to train, evaluate and predict from the model.
Similarly, I want to make parameter tuning using the parameter dictionary I created as follows:
Note: I have also model.hyper file wich includes:
learning_rate loguniform -8,0
embedding_size choice [64,96,128]
mlp_hidden_size choice ['[64,64,64]','[128,128]']
from recbole.trainer import HyperTuning
from recbole.quick_start import objective_function
hp = HyperTuning(objective_function=objective_function, algo='exhaustive', early_stop=10,
max_evals=100, params_file='model.hyper', fixed_config_file_list= parameter_dict)
hp.run()
But I got this error:
---->
hp.run()
File ~/anaconda3/envs/RecBole/lib/python3.8/site-packages/recbole/trainer/hyper_tuning.py:411, in HyperTuning.run(self)
408 r"""begin to search the best parameters"""
409 from hyperopt import fmin
--> 411 fmin(
412 self.trial,
413 self.space,
414 algo=self.algo,
415 max_evals=self.max_evals,
416 early_stop_fn=self.early_stop_fn,
417 )
418 if self.display_file is not None:
419 self.plot_hyper()
File ~/anaconda3/envs/RecBole/lib/python3.8/site-packages/hyperopt/fmin.py:553, in fmin(fn, space, algo, max_evals, timeout, loss_threshold, trials, rstate, allow_trials_fmin, pass_expr_memo_ctrl, catch_eval_exceptions, verbose, return_argmin, points_to_evaluate, max_queue_len, show_progressbar, early_stop_fn, trials_save_file)
550 rval.catch_eval_exceptions = catch_eval_exceptions
552 # next line is where the fmin is actually executed
--> 553 rval.exhaust()
555 if return_argmin:
556 if len(trials.trials) == 0:
File ~/anaconda3/envs/RecBole/lib/python3.8/site-packages/hyperopt/fmin.py:292, in FMinIter.run(self, N, block_until_done)
289 time.sleep(self.poll_interval_secs)
290 else:
291 # -- loop over trials and do the jobs directly
--> 292 self.serial_evaluate()
294 self.trials.refresh()
295 if self.trials_save_file != "":
File ~/anaconda3/envs/RecBole/lib/python3.8/site-packages/hyperopt/fmin.py:170, in FMinIter.serial_evaluate(self, N)
168 ctrl = base.Ctrl(self.trials, current_trial=trial)
169 try:
--> 170 result = self.domain.evaluate(spec, ctrl)
171 except Exception as e:
172 logger.error("job exception: %s" % str(e))
File ~/anaconda3/envs/RecBole/lib/python3.8/site-packages/hyperopt/base.py:907, in Domain.evaluate(self, config, ctrl, attach_attachments)
898 else:
899 # -- the "work" of evaluating config can be written
900 # either into the pyll part (self.expr)
901 # or the normal Python part (self.fn)
902 pyll_rval = pyll.rec_eval(
903 self.expr,
904 memo=memo,
905 print_node_on_error=self.rec_eval_print_node_on_error,
906 )
--> 907 rval = self.fn(pyll_rval)
909 if isinstance(rval, (float, int, np.number)):
910 dict_rval = {"loss": float(rval), "status": STATUS_OK}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I just started using the Recbole library. I want to do hyper parameter optimization on AutoInt which is a context-aware model. I did a tutorial before and I didn't keep the parameters in a .yaml file, but instead with the dictionary I named parameter_dict = {...} as follows:
parameter_dict = {
}
I created Config by writing config = Config(model='AutoInt', dataset='recbole_format', config_dict=parameter_dict) code and I achieved to train, evaluate and predict from the model.
Similarly, I want to make parameter tuning using the parameter dictionary I created as follows:
Note: I have also model.hyper file wich includes:
learning_rate loguniform -8,0
embedding_size choice [64,96,128]
mlp_hidden_size choice ['[64,64,64]','[128,128]']
from recbole.trainer import HyperTuning
from recbole.quick_start import objective_function
hp = HyperTuning(objective_function=objective_function, algo='exhaustive', early_stop=10,
max_evals=100, params_file='model.hyper', fixed_config_file_list= parameter_dict)
hp.run()
But I got this error:
---->
hp.run()
File ~/anaconda3/envs/RecBole/lib/python3.8/site-packages/recbole/trainer/hyper_tuning.py:411, in HyperTuning.run(self)
408 r"""begin to search the best parameters"""
409 from hyperopt import fmin
--> 411 fmin(
412 self.trial,
413 self.space,
414 algo=self.algo,
415 max_evals=self.max_evals,
416 early_stop_fn=self.early_stop_fn,
417 )
418 if self.display_file is not None:
419 self.plot_hyper()
File ~/anaconda3/envs/RecBole/lib/python3.8/site-packages/hyperopt/fmin.py:553, in fmin(fn, space, algo, max_evals, timeout, loss_threshold, trials, rstate, allow_trials_fmin, pass_expr_memo_ctrl, catch_eval_exceptions, verbose, return_argmin, points_to_evaluate, max_queue_len, show_progressbar, early_stop_fn, trials_save_file)
550 rval.catch_eval_exceptions = catch_eval_exceptions
552 # next line is where the fmin is actually executed
--> 553 rval.exhaust()
555 if return_argmin:
556 if len(trials.trials) == 0:
File ~/anaconda3/envs/RecBole/lib/python3.8/site-packages/hyperopt/fmin.py:356, in FMinIter.exhaust(self)
354 def exhaust(self):
355 n_done = len(self.trials)
--> 356 self.run(self.max_evals - n_done, block_until_done=self.asynchronous)
357 self.trials.refresh()
358 return self
File ~/anaconda3/envs/RecBole/lib/python3.8/site-packages/hyperopt/fmin.py:292, in FMinIter.run(self, N, block_until_done)
289 time.sleep(self.poll_interval_secs)
290 else:
291 # -- loop over trials and do the jobs directly
--> 292 self.serial_evaluate()
294 self.trials.refresh()
295 if self.trials_save_file != "":
File ~/anaconda3/envs/RecBole/lib/python3.8/site-packages/hyperopt/fmin.py:170, in FMinIter.serial_evaluate(self, N)
168 ctrl = base.Ctrl(self.trials, current_trial=trial)
169 try:
--> 170 result = self.domain.evaluate(spec, ctrl)
171 except Exception as e:
172 logger.error("job exception: %s" % str(e))
File ~/anaconda3/envs/RecBole/lib/python3.8/site-packages/hyperopt/base.py:907, in Domain.evaluate(self, config, ctrl, attach_attachments)
898 else:
899 # -- the "work" of evaluating
config
can be written900 # either into the pyll part (self.expr)
901 # or the normal Python part (self.fn)
902 pyll_rval = pyll.rec_eval(
903 self.expr,
904 memo=memo,
905 print_node_on_error=self.rec_eval_print_node_on_error,
906 )
--> 907 rval = self.fn(pyll_rval)
909 if isinstance(rval, (float, int, np.number)):
910 dict_rval = {"loss": float(rval), "status": STATUS_OK}
File ~/anaconda3/envs/RecBole/lib/python3.8/site-packages/recbole/trainer/hyper_tuning.py:346, in HyperTuning.trial(self, params)
344 self.params_list.append(params_str)
345 print("running parameters:", config_dict)
--> 346 result_dict = self.objective_function(config_dict, self.fixed_config_file_list)
347 self.params2result[params_str] = result_dict
348 model, score, bigger = (
349 result_dict["model"],
350 result_dict["best_valid_score"],
351 result_dict["valid_score_bigger"],
352 )
File ~/anaconda3/envs/RecBole/lib/python3.8/site-packages/recbole/quick_start/quick_start.py:133, in objective_function(config_dict, config_file_list, saved)
124 def objective_function(config_dict=None, config_file_list=None, saved=True):
125 r"""The default objective_function used in HyperTuning
126
127 Args:
(...)
130 saved (bool, optional): Whether to save the model. Defaults to
True
.131 """
--> 133 config = Config(config_dict=config_dict, config_file_list=config_file_list)
134 init_seed(config["seed"], config["reproducibility"])
135 logger = getLogger()
File ~/anaconda3/envs/RecBole/lib/python3.8/site-packages/recbole/config/configurator.py:81, in Config.init(self, model, dataset, config_file_list, config_dict)
79 self._init_parameters_category()
80 self.yaml_loader = self._build_yaml_loader()
---> 81 self.file_config_dict = self._load_config_files(config_file_list)
82 self.variable_config_dict = self._load_variable_config_dict(config_dict)
83 self.cmd_config_dict = self._load_cmd_line()
File ~/anaconda3/envs/RecBole/lib/python3.8/site-packages/recbole/config/configurator.py:150, in Config._load_config_files(self, file_list)
148 if file_list:
149 for file in file_list:
--> 150 with open(file, "r", encoding="utf-8") as f:
151 file_config_dict.update(
152 yaml.load(f.read(), Loader=self.yaml_loader)
153 )
154 return file_config_dict
FileNotFoundError: [Errno 2] No such file or directory: 'data_path'
Even if I have data_path in my parameter dictionary, do I need ho have a file or dictionary named "data_path"
I would be very grateful if you could help with the issue :)
Beta Was this translation helpful? Give feedback.
All reactions