Keras does not work with tensorflow-macos

Hi,

I installed tensorflow-macos according to the instructions. There were multiple issues with numpy, scikit-learn etc. which I overcame. However, with Keras I still have problems I can't overcome. When trying to import keras I get

AttributeError: module 'keras.engine.base_layer' has no attribute 'BaseRandomLayer'

The longer error is like this

  File "/Users/mattihonkanen/miniforge3/lib/python3.9/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Users/mattihonkanen/miniforge3/lib/python3.9/site-packages/keras/__init__.py", line 25, in <module>
    from keras import models
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Users/mattihonkanen/miniforge3/lib/python3.9/site-packages/keras/models.py", line 20, in <module>
    from keras import metrics as metrics_module
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Users/mattihonkanen/miniforge3/lib/python3.9/site-packages/keras/metrics.py", line 24, in <module>
    from keras import activations
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Users/mattihonkanen/miniforge3/lib/python3.9/site-packages/keras/activations.py", line 20, in <module>
    from keras.layers import advanced_activations
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Users/mattihonkanen/miniforge3/lib/python3.9/site-packages/keras/layers/__init__.py", line 30, in <module>
    from keras.layers.preprocessing.image_preprocessing import CenterCrop
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "/Users/mattihonkanen/miniforge3/lib/python3.9/site-packages/keras/layers/preprocessing/image_preprocessing.py", line 212, in <module>
    class RandomCrop(base_layer.BaseRandomLayer):
AttributeError: module 'keras.engine.base_layer' has no attribute 'BaseRandomLayer'

Here the list of the packages I have

----------------------- -------------------
absl-py                 0.10.0
aiohttp                 3.8.1
aiosignal               1.2.0
astunparse              1.6.3
async-timeout           4.0.1
attrs                   21.4.0
blinker                 1.4
brotlipy                0.7.0
cached-property         1.5.2
cachetools              4.2.2
certifi                 2021.10.8
cffi                    1.15.0
charset-normalizer      2.0.12
click                   8.0.4
colorama                0.4.4
conda                   4.12.0
conda-package-handling  1.8.0
cryptography            36.0.2
flatbuffers             2.0
frozenlist              1.2.0
gast                    0.4.0
google-auth             2.6.0
google-auth-oauthlib    0.4.1
google-pasta            0.2.0
grpcio                  1.42.0
h5py                    2.10.0
idna                    3.3
importlib-metadata      4.11.3
joblib                  1.1.0
Keras                   2.0.8
Keras-Preprocessing     1.1.2
libclang                14.0.1
Markdown                3.3.4
multidict               5.2.0
numpy                   1.22.3
oauthlib                3.1.0
opt-einsum              3.3.0
pandas                  1.4.2
pip                     22.0.4
protobuf                3.19.1
pyasn1                  0.4.8
pyasn1-modules          0.2.8
pycosat                 0.6.3
pycparser               2.21
PyJWT                   2.3.0
pyOpenSSL               22.0.0
PySocks                 1.7.1
python-dateutil         2.8.2
pytz                    2022.1
PyYAML                  6.0
requests                2.27.1
requests-oauthlib       1.3.0
rsa                     4.7.2
ruamel-yaml-conda       0.15.80
scikit-learn            1.0.2
scipy                   1.8.0
setuptools              62.1.0
six                     1.15.0
tensorboard             2.8.0
tensorboard-data-server 0.6.0
tensorboard-plugin-wit  1.6.0
tensorflow-macos        2.8.0
tensorflow-metal        0.4.0
termcolor               1.1.0
tf-estimator-nightly    2.8.0.dev2021122109
threadpoolctl           2.2.0
tqdm                    4.63.0
typing-extensions       3.7.4.3
urllib3                 1.26.9
Werkzeug                2.0.3
wheel                   0.35.1
wrapt                   1.12.1
yarl                    1.6.3
zipp                    3.7.0

Keras does not work with tensorflow-macos
 
 
Q