forked from RUCAIBox/RecBole
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_hyper.py
35 lines (28 loc) · 1.2 KB
/
run_hyper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: utf-8 -*-
# @Time : 2020/7/24 15:57
# @Author : Shanlei Mu
# @Email : [email protected]
# @File : run_hyper.py
# UPDATE:
# @Time : 2020/8/20 21:17, 2020/8/29
# @Author : Zihan Lin, Yupeng Hou
# @Email : [email protected], [email protected]
import argparse
from recbole.trainer import HyperTuning
from recbole.quick_start import objective_function
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--config_files', type=str, default=None, help='fixed config files')
parser.add_argument('--params_file', type=str, default=None, help='parameters file')
args, _ = parser.parse_known_args()
# plz set algo='exhaustive' to use exhaustive search, in this case, max_evals is auto set
config_file_list = args.config_files.strip().split(' ') if args.config_files else None
hp = HyperTuning(objective_function, algo='exhaustive',
params_file=args.params_file, fixed_config_file_list=config_file_list)
hp.run()
hp.export_result(output_file='hyper_example.result')
print('best params: ', hp.best_params)
print('best result: ')
print(hp.params2result[hp.params2str(hp.best_params)])
if __name__ == '__main__':
main()