hyperopt / hyperopt-sklearn

Hyper-parameter optimization for sklearn
hyperopt.github.io/hyperopt-sklearn
Other
1.58k stars 272 forks source link

module 'hyperopt.pyll' has no attribute 'base' #190

Closed rottentomato13 closed 2 years ago

rottentomato13 commented 2 years ago

Hi I tried using optim.minimize from hyperas but had an issue 'numpy.random.mtrand.RandomState' object has no attribute 'integers' then I downgraded hyperopt to v0.2.5 and reservoirpy to v0.3.2, but it gives me the following error

`File "C:\Users\FulviaYang\Desktop\python\src\lstm_attention.py", line 289, in best_run, best_model = optim.minimize(model=build_model, data=data, algo=tpe.suggest, max_evals=30, trials=Trials())

File "C:\Users\FulviaYang\anaconda3\lib\site-packages\hyperas\optim.py", line 59, in minimize best_run, space = base_minimizer(model=model,

File "C:\Users\FulviaYang\anaconda3\lib\site-packages\hyperas\optim.py", line 133, in base_minimizer fmin(keras_fmin_fnct,

File "C:\Users\FulviaYang\anaconda3\lib\site-packages\hyperopt\fmin.py", line 507, in fmin return trials.fmin(

File "C:\Users\FulviaYang\anaconda3\lib\site-packages\hyperopt\base.py", line 682, in fmin return fmin(

File "C:\Users\FulviaYang\anaconda3\lib\site-packages\hyperopt\fmin.py", line 553, in fmin rval.exhaust()

File "C:\Users\FulviaYang\anaconda3\lib\site-packages\hyperopt\fmin.py", line 356, in exhaust self.run(self.max_evals - n_done, block_until_done=self.asynchronous)

File "C:\Users\FulviaYang\anaconda3\lib\site-packages\hyperopt\fmin.py", line 292, in run self.serial_evaluate()

File "C:\Users\FulviaYang\anaconda3\lib\site-packages\hyperopt\fmin.py", line 170, in serial_evaluate result = self.domain.evaluate(spec, ctrl)

File "C:\Users\FulviaYang\anaconda3\lib\site-packages\hyperopt\base.py", line 894, in evaluate memo = self.memo_from_config(config)

File "C:\Users\FulviaYang\anaconda3\lib\site-packages\hyperopt\base.py", line 890, in memo_from_config memo[node] = config.get(label, pyll.base.GarbageCollected)

AttributeError: module 'hyperopt.pyll' has no attribute 'base'`

mandjevant commented 2 years ago

Hey there! So your problem is interesting and it revolves around the change in NumPy v1.16 where np.random.RandomState was deprecated in favour of np.random.Generator.

As of this moment, hyperopt-sklearn and hyperopt have edited their code to work with this change. However, Hyperas has not.

So to solve your problem, I think it's easiest if you downgraded hyperopt to v0.2.5 and numpy to before v1.16 If you also want to use hyperopt-sklearn you can use v0.03 and sklearn v0.23.0

I hope this fixes your problem. If it doesn't, I would suggest making an issue at hyperas.

rottentomato13 commented 2 years ago

Hey there! So your problem is interesting and it revolves around the change in NumPy v1.16 where np.random.RandomState was deprecated in favour of np.random.Generator.

As of this moment, hyperopt-sklearn and hyperopt have edited their code to work with this change. However, Hyperas has not.

So to solve your problem, I think it's easiest if you downgraded hyperopt to v0.2.5 and numpy to before v1.16 If you also want to use hyperopt-sklearn you can use v0.03 and sklearn v0.23.0

I hope this fixes your problem. If it doesn't, I would suggest making an issue at hyperas.

turn out it's an issue at [hyperas]! thank you! https://github.com/maxpumperla/hyperas/issues/284#issuecomment-1167058879