handson-ml2
handson-ml2 copied to clipboard
Chapter 10 neither attribute keras.wrapper nor keras.__version__ being found :/
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
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