Nghiệp Le
Nghiệp Le

Reputation: 1

How to resolved the import error with scipy when using keras_tuner?

I have download the tensorflow nightly version 2.19.0.dev20241219 (cpu version) and download the version keras_tuner 1.4.7 and keras 3.7.0. I also check my system has the scipy version 1.15.0. However, the system keep request to download scipy. Here the error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[95], line 1
----> 1 tuner_CNN_M_LSTM = keras_tuner.BayesianOptimization(
      2     create_model_CNN_M_LSTM_model,
      3     objective='mse',
      4     max_trials=10,
      5     executions_per_trial=1,
      6     directory=os.path.normpath('./data_folder/tuning'),
      7     project_name='test_paper_1',
      8     overwrite=True,
      9     max_retries_per_trial=2,
     10     max_consecutive_failed_trials=8,
     11     )

File c:\Users\lengh\anaconda3\envs\fy\Lib\site-packages\keras_tuner\src\tuners\bayesian.py:381, in BayesianOptimization.__init__(self, hypermodel, objective, max_trials, num_initial_points, alpha, beta, seed, hyperparameters, tune_new_entries, allow_new_entries, max_retries_per_trial, max_consecutive_failed_trials, **kwargs)
    365 def __init__(
    366     self,
    367     hypermodel=None,
   (...)
    379     **kwargs
    380 ):
--> 381     oracle = BayesianOptimizationOracle(
    382         objective=objective,
    383         max_trials=max_trials,
    384         num_initial_points=num_initial_points,
    385         alpha=alpha,
    386         beta=beta,
    387         seed=seed,
    388         hyperparameters=hyperparameters,
    389         tune_new_entries=tune_new_entries,
    390         allow_new_entries=allow_new_entries,
    391         max_retries_per_trial=max_retries_per_trial,
    392         max_consecutive_failed_trials=max_consecutive_failed_trials,
    393     )
    394     super().__init__(oracle=oracle, hypermodel=hypermodel, **kwargs)

File c:\Users\lengh\anaconda3\envs\fy\Lib\site-packages\keras_tuner\src\tuners\bayesian.py:104, in BayesianOptimizationOracle.__init__(self, objective, max_trials, num_initial_points, alpha, beta, seed, hyperparameters, allow_new_entries, tune_new_entries, max_retries_per_trial, max_consecutive_failed_trials)
     89 def __init__(
     90     self,
     91     objective=None,
   (...)
    101     max_consecutive_failed_trials=3,
    102 ):
    103     if scipy is None:
--> 104         raise ImportError(
    105             "Please install scipy before using the `BayesianOptimization` "
    106             "with `pip install keras-tuner[bayesian]`."
    107         )
    109     if sklearn is None:
    110         raise ImportError(
    111             "Please install scikit-learn (sklearn) before using the "
    112             "`BayesianOptimization` with "
    113             "`pip install keras-tuner[bayesian]`."
    114         )

ImportError: Please install scipy before using the `BayesianOptimization` with `pip install keras-tuner[bayesian]`.

I have try to using pip install keras-tuner[bayesian] to get the version of scipy that system request, but the error persists.

I also tried to use commercial tensorflow version instead of nightly version, and I also tried to downgrade the version of scipy to 1.7.0, but none of this work.

How can I run the bayesian tuner using keras_tuner with tensorflow.

Upvotes: 0

Views: 29

Answers (0)

Related Questions