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

[BUG] TensorFlow 2.5.0 not supported #106

Open
ad12 opened this issue May 14, 2021 · 0 comments
Open

[BUG] TensorFlow 2.5.0 not supported #106

ad12 opened this issue May 14, 2021 · 0 comments

Comments

@ad12
Copy link
Owner

ad12 commented May 14, 2021

Describe the bug
With tensorflow==2.5.0, we get an error message like the one below:

tests/util.py:18: in <module>
    from dosma.cli import SUPPORTED_SCAN_TYPES, parse_args
dosma/cli.py:36: in <module>
    from dosma.models.seg_model import SegModel
dosma/models/__init__.py:1: in <module>
    from dosma.models import oaiunet2d, util
dosma/models/oaiunet2d.py:14: in <module>
    from keras.models import Model
/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/site-packages/keras/__init__.py:20: in <module>
    from . import initializers
/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/site-packages/keras/initializers/__init__.py:124: in <module>
    populate_deserializable_objects()
/opt/hostedtoolcache/Python/3.6.13/x64/lib/python3.6/site-packages/keras/initializers/__init__.py:49: in populate_deserializable_objects
    LOCAL.GENERATED_WITH_V2 = tf.__internal__.tf2.enabled()
E   AttributeError: module 'tensorflow.compat.v2.__internal__' has no attribute 'tf2'

To Reproduce

import dosma

Expected behavior
No error.

Stopgap solution
Install tensorflow and Keras with pip install tensorflow==2.4.1 keras==2.4.3

Potential Fix
As mentioned in this issue, tensorflow>=2.0 should import keras tools using import tensorflow.keras instead of import keras. All files where packages are imported from keras should first check the version for tensorflow and then rename keras. In pseudo-code, this is:

if tensorflow_version >= 2.0:
    import tensorflow.keras as keras

from keras...
@gattia gattia mentioned this issue Apr 27, 2024
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