RecBole
RecBole copied to clipboard
[🐛BUG] 参数调优时numpy属性错误
描述这个 bug 我按照[(https://recbole.io/docs/user_guide/usage/parameter_tuning.html) []中的步骤进行HyperTuning参数搜索时,报错AttributeError: 'numpy.random.mtrand.RandomState' object has no attribute 'integers'
如何复现 python文件:
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=['example.yaml'])
# run
hp.run()
# export result to the file
hp.export_result(output_file='hyper_example.result')
# print best parameters
print('best params: ', hp.best_params)
# print best result
print('best result: ')
print(hp.params2result[hp.params2str(hp.best_params)])
yaml文件:
dataset: ml-100k
model: BPR
model.hyper文件:
learning_rate loguniform -8,0
embedding_size choice [64,96,128]
mlp_hidden_size choice ['[64,64,64]','[128,128]']
报错信息
ERROR in rec_eval
EXCEPTION
<class 'AttributeError'>
'numpy.random.mtrand.RandomState' object has no attribute 'integers'
NODE
0 randint
1 Literal{2}
2 size =
3 len
4 array_union
5 array_union
6 array_union
7 Literal{new_ids}
8 rng =
9 Literal{rng-placeholder}
================================================================================
0%| | 0/6 [00:00<?, ?trial/s, best loss=?]
Traceback (most recent call last):
File "D:/11714/AI/baseline/recbole test/main.py", line 8, in <module>
hp.run()
File "D:\11714\anaconda3\envs\graph\lib\site-packages\recbole\trainer\hyper_tuning.py", line 411, in run
fmin(
File "D:\11714\anaconda3\envs\graph\lib\site-packages\hyperopt\fmin.py", line 586, in fmin
rval.exhaust()
File "D:\11714\anaconda3\envs\graph\lib\site-packages\hyperopt\fmin.py", line 364, in exhaust
self.run(self.max_evals - n_done, block_until_done=self.asynchronous)
File "D:\11714\anaconda3\envs\graph\lib\site-packages\hyperopt\fmin.py", line 278, in run
new_trials = algo(
File "D:\11714\anaconda3\envs\graph\lib\site-packages\recbole\trainer\hyper_tuning.py", line 123, in exhaustive_search
idxs, vals = pyll.rec_eval(
File "D:\11714\anaconda3\envs\graph\lib\site-packages\hyperopt\pyll\base.py", line 902, in rec_eval
rval = scope._impls[node.name](*args, **kwargs)
File "D:\11714\anaconda3\envs\graph\lib\site-packages\hyperopt\pyll\stochastic.py", line 100, in randint
return rng.integers(low, high, size)
AttributeError: 'numpy.random.mtrand.RandomState' object has no attribute 'integers'
Process finished with exit code 1
实验环境(请补全下列信息):
- 操作系统: Windows
- RecBole 版本 1.1.1
- Python 版本 3.7
- PyTorch 版本 2.01
- numpy 版本 1.24
- hyperopt版本 0.2.6
@primising 你好! 这是由于hyperopt版本和numpy版本不兼容引起的,你可以尝试将hyperopt降为0.2.5版本。
@primising 你好! 这是由于hyperopt版本和numpy版本不兼容引起的,你可以尝试将hyperopt降为0.2.5版本。
谢谢你的建议,降版本之后成功跑通了,但是我没有找到[https://recbole.io/docs/user_guide/usage/parameter_tuning.html]中提到的html文件,请问你有什么头绪吗
中间还产生了如下报错,但是没有影响后续运行
2023-09-18 16:13:20,657 WARNING session.py:91 -- Session not detected. You should not be calling `report` outside `tuner.fit()` or while using the class API.
2023-09-18 16:13:20,657 WARNING session.py:97 -- File "D:/11714/AI/baseline/recbole test/main.py", line 8, in <module>
hp.run()
File "D:\11714\anaconda3\envs\graph\lib\site-packages\recbole\trainer\hyper_tuning.py", line 411, in run
fmin(
File "D:\11714\anaconda3\envs\graph\lib\site-packages\hyperopt\fmin.py", line 553, in fmin
rval.exhaust()
File "D:\11714\anaconda3\envs\graph\lib\site-packages\hyperopt\fmin.py", line 356, in exhaust
self.run(self.max_evals - n_done, block_until_done=self.asynchronous)
File "D:\11714\anaconda3\envs\graph\lib\site-packages\hyperopt\fmin.py", line 292, in run
self.serial_evaluate()
File "D:\11714\anaconda3\envs\graph\lib\site-packages\hyperopt\fmin.py", line 170, in serial_evaluate
result = self.domain.evaluate(spec, ctrl)
File "D:\11714\anaconda3\envs\graph\lib\site-packages\hyperopt\base.py", line 907, in evaluate
rval = self.fn(pyll_rval)
File "D:\11714\anaconda3\envs\graph\lib\site-packages\recbole\trainer\hyper_tuning.py", line 346, in trial
result_dict = self.objective_function(config_dict, self.fixed_config_file_list)
File "D:\11714\anaconda3\envs\graph\lib\site-packages\recbole\quick_start\quick_start.py", line 151, in objective_function
tune.report(**test_result)
@primising 你好! 这是由于hyperopt版本和numpy版本不兼容引起的,你可以尝试将hyperopt降为0.2.5版本。
谢谢你的建议,降版本之后成功跑通了,但是我没有找到[https://recbole.io/docs/user_guide/usage/parameter_tuning.html]中提到的html文件,请问你有什么头绪吗
你好!这是因为你在使用HyperTuning时没有传入display_file参数,如果需要可视化的html文件你可以通过该参数指定需要的地址。
@primising 你好! 这是由于hyperopt版本和numpy版本不兼容引起的,你可以尝试将hyperopt降为0.2.5版本。
谢谢你的建议,降版本之后成功跑通了,但是我没有找到[https://recbole.io/docs/user_guide/usage/parameter_tuning.html]中提到的html文件,请问你有什么头绪吗
你好!这是因为你在使用HyperTuning时没有传入display_file参数,如果需要可视化的html文件你可以通过该参数指定需要的地址。 谢谢你的回答,请问display_file的格式是什么样的,我没有找到相关示例
@primising 你好! 这是由于hyperopt版本和numpy版本不兼容引起的,你可以尝试将hyperopt降为0.2.5版本。
谢谢你的建议,降版本之后成功跑通了,但是我没有找到[https://recbole.io/docs/user_guide/usage/parameter_tuning.html]中提到的html文件,请问你有什么头绪吗
你好!这是因为你在使用HyperTuning时没有传入display_file参数,如果需要可视化的html文件你可以通过该参数指定需要的地址。 谢谢你的回答,请问display_file的格式是什么样的,我没有找到相关示例
这个参数是指定html文件的地址,比如display_file="C:\Users\xxx\Desktop\display.html"