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

Too restrictive ModuleNotFoundError exception in convolutional #79

Closed
Algue-Rythme opened this issue Aug 14, 2023 · 2 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@Algue-Rythme
Copy link

Version

Tensorflow: 2.13
Deel.lip 1.4.0

Issue

In file : https://github.com/deel-ai/deel-lip/blob/master/deel/lip/layers/convolutional.py

There is the code:

try:
    from keras.utils import conv_utils  # in Keras for TF >= 2.6
except ModuleNotFoundError:
    from tensorflow.python.keras.utils import conv_utils  # in TF.python for TF <= 2.5

In tensorflow>=2.13 the new path for conv_utils is tensorflow.python.keras.utils. Unfortunately, attempting to import with from keras.utils import conv_utils does not yield a ModuleNotFoundError becasue the module exists: instead, it simply yield a ImportError.

Since ImportError is not ModuleNotFoundError the except does not catch anything.

Solution

However observe that per this post that ModuleNotFoundError is an instance of ImportError , therefore we should replace the exception with a more general one.

@cofri
Copy link
Collaborator

cofri commented Aug 21, 2023

Hi @Algue-Rythme,
TensorFlow indeed changed (again) the way conv_utils is imported... @danibene suggested in a previous PR to fix this issue (04b03f8). His commit was integrated in a broader PR #76 with corrections for other failures introduced by TF 2.13.

However, we didn't notice that ModuleNotFoundError is a subclass of ImportError. We can simplify the open PR #76 with your proposition.

@thib-s
Copy link
Member

thib-s commented Aug 21, 2023

Closing this issue as the suggested fix has been merged in #76 . Thank for the contribution !

@thib-s thib-s closed this as completed Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants