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

Support of TensorFlow 2.13 #76

Merged
merged 4 commits into from
Aug 21, 2023
Merged

Support of TensorFlow 2.13 #76

merged 4 commits into from
Aug 21, 2023

Conversation

cofri
Copy link
Collaborator

@cofri cofri commented Jul 26, 2023

TensorFlow 2.13 introduces three problems raising errors in unit tests:

  • Module conv_utils from Keras, required for our convolutional layers, has been moved (again) in a different Keras folder. Depending on TF version, we import this module from different paths.
  • Serialization/deserialization of h5 models with custom objects (here, custom initializer) is not supported anymore in TF 2.13. The new .keras format is now preferred, instead of h5 format.
  • One of our unit test was failing (comparison of SVD and power iteration for a Dense kernel). This is not a problem from TF 2.13 but from non-deterministic computation: for some random cases, the power iteration algorithm had difficulties to converge close enough to the true value. This failing test is now deterministic with seeded kernel and initialization u.

danibene and others added 3 commits August 21, 2023 16:13
conv_utils module has been moved again in TF 2.13, and can be imported as in
TF <= 2.5. The error raised is ImportError, which was added to the try/except
clause. ModuleNotFoundError is a subclass of ImportError; it is then removed.
… TF2.13

It seems that (de)serialization of h5 models in TF 2.13 has been changed:
custom objects, even with "register_keras_serializable", cannot be loaded.
Two solutions are possible:
- use "with_custom_object_scope()" to load a model with custom objects.
- save model in Keras format and not h5.

The second option was chosen because this format is now preferred for saving
models.
The power iteration test for Dense was sometimes failing due to a random
choice of kernel and initialization vector u. Even if np.random.seed(42)
was set at the beginning of the file.

To ensure a fully deterministic test (deterministic kernel and
initialization u), a random generator np.random.default_rng(42) was created
and used to create both kernel and u.
The results for Dense test are then deterministic, either for a single test
file or for the whole unittest. Note that this is the only test modified;
other tests of the file pass, they have not been changed with deterministic
initializations.
@thib-s thib-s merged commit f37c1e0 into master Aug 21, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants