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

Chapter 10 neither attribute keras.wrapper nor keras.__version__ being found :/ #618

Open
bbradz opened this issue Jun 26, 2023 · 1 comment

Comments

@bbradz
Copy link

bbradz commented Jun 26, 2023

I'm receiving errors with my keras package where it isn't recognizing the .version or .wrapper attributes.

In [11] in the official notebook :

keras.__version__

This yields this error:

AttributeError                            Traceback (most recent call last)
Cell In[9], line 1
----> 1 keras.__version__

File ~/miniconda3/envs/cs200-env/lib/python3.9/site-packages/tensorflow/python/util/lazy_loader.py:59, in LazyLoader.__getattr__(self, item)
     57 def __getattr__(self, item):
     58   module = self._load()
---> 59   return getattr(module, item)

AttributeError: module 'keras.api._v2.keras' has no attribute '__version__'

And.... In [95] in the official notebook :

keras_reg = keras.wrappers.scikit_learn.KerasRegressor(build_model)

This code yields this error...

AttributeError                            Traceback (most recent call last)
Cell In[92], line 1
----> 1 keras_reg = keras.wrappers.scikit_learn.KerasRegressor(build_model)

File ~/miniconda3/envs/cs200-env/lib/python3.9/site-packages/tensorflow/python/util/lazy_loader.py:59, in LazyLoader.__getattr__(self, item)
     57 def __getattr__(self, item):
     58   module = self._load()
---> 59   return getattr(module, item)

AttributeError: module 'keras.api._v2.keras' has no attribute 'wrappers'

I'm using...

  • OS: [e.g. MacOSV 13.3.1
  • Python: 3.9.16
  • Keras: .api._v2.keras
  • TensorFlow: 2.13.0-rcl
@hugomorg
Copy link

Hi @bbradz

I had the same problem as you. Still can't get the version to display properly.

But with regards to the second issue, I fixed that by installing scikeras (the class seems to have moved packages)

python3 -m pip install -U scikeras

then you can import it and use it in the same way the book describes:

from scikeras.wrappers import KerasRegressor

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

2 participants