Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: tf.data.Dataset` only supports Python-style iteration in eager mode or within tf.function. when deactivating eager execution #333

Open
bastian-f opened this issue Dec 11, 2024 · 0 comments

Comments

@bastian-f
Copy link

bastian-f commented Dec 11, 2024

Hello,

When trying the quickstart examples with eager mode deactivated, I get the following error:

12 fits failed with the following error:
Traceback (most recent call last):
  File "/home/bastian/.conda/envs/machine_learning/lib/python3.11/site-packages/sklearn/model_selection/_validation.py", line 895, in _fit_and_score
    estimator.fit(X_train, y_train, **fit_params)
  File "/home/bastian/.conda/envs/machine_learning/lib/python3.11/site-packages/sklearn/base.py", line 1474, in wrapper
    return fit_method(estimator, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bastian/.conda/envs/machine_learning/lib/python3.11/site-packages/sklearn/pipeline.py", line 475, in fit
    self._final_estimator.fit(Xt, y, **last_step_params["fit"])
  File "/home/bastian/.conda/envs/machine_learning/lib/python3.11/site-packages/scikeras/wrappers.py", line 1501, in fit
    super().fit(X=X, y=y, sample_weight=sample_weight, **kwargs)
  File "/home/bastian/.conda/envs/machine_learning/lib/python3.11/site-packages/scikeras/wrappers.py", line 770, in fit
    self._fit(
  File "/home/bastian/.conda/envs/machine_learning/lib/python3.11/site-packages/scikeras/wrappers.py", line 938, in _fit
    self._fit_keras_model(
  File "/home/bastian/.conda/envs/machine_learning/lib/python3.11/site-packages/scikeras/wrappers.py", line 535, in _fit_keras_model
    hist = self.model_.fit(x=X, y=y, **fit_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bastian/.conda/envs/machine_learning/lib/python3.11/site-packages/keras/src/utils/traceback_utils.py", line 122, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/home/bastian/.conda/envs/machine_learning/lib/python3.11/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 498, in __iter__
    raise RuntimeError("`tf.data.Dataset` only supports Python-style "
RuntimeError: `tf.data.Dataset` only supports Python-style iteration in eager mode or within tf.function.

Does this mean scikeras can only be used in eager mode? I also tried with eager mode but run_eagerly=True in model.compile or model.run_eagerly=True do not have any effect. The error is the same.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant