ageron / ageron/handson-ml2

Chapter 10 runtime error from grid search neural network paramaters

未关闭
#103 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Jupyter Notebook
星标
30k
派生
13.1k
PR 合并指标
30 天内没有已合并 PR

描述

```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?

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。