ageron / ageron/handson-ml2

Chapter 10 runtime error from grid search neural network paramaters

Open
#103 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
30k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

```python
keras_reg = keras.wrappers.scikit_learn.KerasRegressor(build_model)
keras_reg.fit(
X_train,
y_train,
epochs=100,
validation_data=(X_valid, y_valid),
callbacks=[keras.callbacks.EarlyStopping(patience=10)],
)
mse_test = keras_reg.score(X_test, y_test)

param_distribs = {
"n_hidden": [0, 1, 2, 3],
"n_neurons": np.arange(1, 100),
"learning_rate": reciprocal(3e-4, 3e-2),
}

rnd_search_cv = RandomizedSearchCV(keras_reg, param_distribs, n_iter=10, cv=3)
rnd_search_cv.fit(
X_train,
y_train,
epochs=100,
validation_data=(X_valid, y_valid),
callbacks=[keras.callbacks.EarlyStopping(patience=10)],
)
```

This code yields this error:

```python
Traceback (most recent call last):
File "", line 6, in
File "/home/nick/.cache/pypoetry/virtualenvs/hml-EoLX4ttF-py3.7/lib/python3.7/site-packages/sklearn/model_selection/_search.py", line 736, in fit
**self.best_params_))
File "/home/nick/.cache/pypoetry/virtualenvs/hml-EoLX4ttF-py3.7/lib/python3.7/site-packages/sklearn/base.py", line 82, in clone
(estimator, name))
RuntimeError: Cannot clone object , as the constructor either does not set or modifies parameter learning_rate
```

Any idea why?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.