Comments (6)
from dask-searchcv.
The following code using dask_searchcv.GridSearchCV crashes, but if you comment-out the dask_searchcv import and uncomment the sklearn import, it runs.
from keras.models import Sequential
from keras.layers import Dense
from keras.wrappers.scikit_learn import KerasClassifier
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from dask_searchcv import GridSearchCV
#from sklearn.model_selection import GridSearchCV
def simple_nn(hidden_neurons):
model = Sequential()
model.add(Dense(hidden_neurons, activation='relu', input_dim=30))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy'])
return model
param_grid = {'hidden_neurons': [100, 200, 300]}
cv = GridSearchCV(KerasClassifier(build_fn=simple_nn), param_grid)
X, y = load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y)
cv.fit(X_train, y_train)
score = cv.score(X_test, y_test)
print('score = {} on train set with params={}.'.format(score, cv.best_params_))
from dask-searchcv.
from dask-searchcv.
File "kerasexample.py", line 21, in
cv.fit(X_train, y_train)
File "/phys/users/schuya/.local/lib/python2.7/site-packages/dask_searchcv/model_selection.py", line 867, in fit
out = scheduler(dsk, keys, num_workers=n_jobs)
File "/phys/users/schuya/.local/lib/python2.7/site-packages/dask/threaded.py", line 75, in get
pack_exception=pack_exception, **kwargs)
File "/phys/users/schuya/.local/lib/python2.7/site-packages/dask/local.py", line 521, in get_async
raise_exception(exc, tb)
File "/phys/users/schuya/.local/lib/python2.7/site-packages/dask/local.py", line 290, in execute_task
result = _execute_task(task, data)
File "/phys/users/schuya/.local/lib/python2.7/site-packages/dask/local.py", line 271, in _execute_task
return func(*args2)
File "/phys/users/schuya/.local/lib/python2.7/site-packages/dask_searchcv/methods.py", line 280, in fit_and_score
fields, params, fit_params)
File "/phys/users/schuya/.local/lib/python2.7/site-packages/dask_searchcv/methods.py", line 216, in fit
est.fit(X, y, **fit_params)
File "/phys/users/schuya/.local/lib/python2.7/site-packages/keras/wrappers/scikit_learn.py", line 203, in fit
return super(KerasClassifier, self).fit(x, y, **kwargs)
File "/phys/users/schuya/.local/lib/python2.7/site-packages/keras/wrappers/scikit_learn.py", line 147, in fit
history = self.model.fit(x, y, **fit_args)
File "/phys/users/schuya/.local/lib/python2.7/site-packages/keras/models.py", line 960, in fit
validation_steps=validation_steps)
File "/phys/users/schuya/.local/lib/python2.7/site-packages/keras/engine/training.py", line 1657, in fit
validation_steps=validation_steps)
File "/phys/users/schuya/.local/lib/python2.7/site-packages/keras/engine/training.py", line 1213, in _fit_loop
outs = f(ins_batch)
File "/phys/users/schuya/.local/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 2357, in call
**self.session_kwargs)
File "/phys/users/schuya/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 889, in run
run_metadata_ptr)
File "/phys/users/schuya/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 1067, in _run
+ e.args[0])
TypeError: Cannot interpret feed_dict key as Tensor: Tensor Tensor("dense_1_input:0", shape=(?, 30), dtype=float32) is not an element of this graph.
from dask-searchcv.
I believe that TensorFlow may have an issue where it doesn't like running in multiple Python threads. cc @bnaul who has dealt with this before. You might also want to do a web search on TensorFlow, Python, and Threads.
from dask-searchcv.
To answer your original question. To use Dask with the multi-threading scheduler your code should be able to be run in multiple threads (most code is, just not TensorFlow). To use Dask with the multiprocessing or distributed schedulers your code should be able to be serialized (most code is). You can always use Dask with the single-threaded scheduler if you want to see how things work out. To try this run the following line:
dask.set_options(get=dask.local.get_sync)
from dask-searchcv.
Related Issues (20)
- Efficiency for GridSearchCV on large graphs HOT 46
- re Custom Sklearn Transforms with Dask Apply inside HOT 4
- Asynchronous algorithms and "Good enough" RandomSearchCV HOT 7
- Memory Error when number of worker increase in daskgridsearch HOT 13
- pip installable HOT 4
- Works with stock Pipeline now? HOT 4
- Maybe add verbose parameter to "RandomizedSearchCV" ? HOT 9
- Wish: support multiple metric scoring as in scikit-learn 0.19
- Compatibility with scikit-learn 0.19 HOT 6
- TypeError: can't pickle NotImplementedType objects on sklearn.metrics.make_scorer and FeatureUnion HOT 8
- Failure on model pipeline that succeeds using stock scikit-learn HOT 7
- bayesian optimization for hyperparameter tuning HOT 1
- COMPAT: /Users/taugspurger/Envs/dask-dev/lib/python3.6/site-packages/scikit-learn/sklearn/base.py:114: DeprecationWarning: Estimator Pipeline modifies parameters in __init__. HOT 1
- AttributeError: 'unicode' object has no attribute 'version' - LooseVersion with Py 2.7 HOT 6
- Multi-threading or -processing doesn't work for simple sklearn Pipeline HOT 12
- Fold dask-searchcv into Dask-ML HOT 11
- BaseSearchCV throws IndexError for particular sized optional arguments to BaseSearchCV.fit HOT 2
- Implement partial_fit support in DaskBaseSearchCV HOT 2
- dask-searchcv incompatible with Dask v0.18 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dask-searchcv.