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

Error with tensorflow 3.13 #503

Closed
sylvchev opened this issue Oct 12, 2023 · 1 comment
Closed

Error with tensorflow 3.13 #503

sylvchev opened this issue Oct 12, 2023 · 1 comment
Labels

Comments

@sylvchev
Copy link
Member

When upgrading to TF 3.13, the documentation building raise the following error :

In [2]: import tensorflow as tf
   ...: print(tf.reduce_sum(tf.random.normal([1000, 1000])))
2023-10-12 18:24:11.248019: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
tf.Tensor(1321.248, shape=(), dtype=float32)

In [3]: import moabb.pipelines.deep_learning
Tensorflow not install, you could not use those pipelines
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[3], line 1
----> 1 import moabb.pipelines.deep_learning

File ~/src/github/moabb-sylvchev/moabb/pipelines/deep_learning.py:32
     14 from keras.constraints import max_norm
     15 from keras.layers import (
     16     Activation,
     17     Add,
   (...)
     30     Permute,
     31 )
---> 32 from keras.layers.normalization.batch_normalization import BatchNormalization
     33 from keras.models import Model, Sequential
     34 from scikeras.wrappers import KerasClassifier

ModuleNotFoundError: No module named 'keras.layers.normalization'

You could see that MOABB indicates that Tensorflow not install, you could not use those pipelines even when tensorflow is correctly installed and working in the same environment.

Downgrading to tensorflow 3.12 solve the issue. @carraraig Do you have any idea why?

@sylvchev sylvchev added the bug label Oct 12, 2023
@brianjohannes
Copy link
Contributor

I found a potential solution to this here: https://stackoverflow.com/questions/69471749/importerror-cannot-import-name-batchnormalization-from-keras-layers-normaliz

The solution is to import BatchNormalization from keras.layers

from tensorflow.keras.layers import BatchNormalization

brianjohannes added a commit to brianjohannes/moabb that referenced this issue Feb 4, 2024
This fixes the issue where the "ModuleNotFoundError: No module named 'keras.layers.normalization'" issue when using TF 2.13.

I tested it with TF 2.12 and nothing seemed to break.
bruAristimunha pushed a commit that referenced this issue Feb 6, 2024
* Issue #503 Fix

This fixes the issue where the "ModuleNotFoundError: No module named 'keras.layers.normalization'" issue when using TF 2.13.

I tested it with TF 2.12 and nothing seemed to break.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

* Fixed BatchNormalization position for pre-commit

* Update whats_new.rst

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants