Keras experimental Error

Traceback (most recent call last):
File “C:\Users\k\project\tensorflow\TFODCourse\Tensorflow\models\research\object_detection\builders\”, line 24, in
from import model_builder
File “C:\Users\k\project\tensorflow\tfod\Lib\site-packages\object_detection-0.1-py3.11.egg\object_detection\builders\”, line 26, in
from import hyperparams_builder
File “C:\Users\k\project\tensorflow\tfod\Lib\site-packages\object_detection-0.1-py3.11.egg\object_detection\builders\”, line 27, in
from object_detection.core import freezable_sync_batch_norm
File “C:\Users\k\project\tensorflow\tfod\Lib\site-packages\object_detection-0.1-py3.11.egg\object_detection\core\”, line 20, in
class FreezableSyncBatchNorm(tf.keras.layers.experimental.SyncBatchNormalization
AttributeError: module ‘keras._tf_keras.keras.layers’ has no attribute ‘experimental’

1 Like

The error indicates that the SyncBatchNormalization class, which you’re trying to access via tf.keras.layers.experimental , either no longer exists in the experimental namespace or has been moved to a stable part of TensorFlow’s API in the version you’re using. To fix this, update your TensorFlow installation, and adjust your code to use the new location of SyncBatchNormalization , likely under tf.keras.layers directly. Check the TensorFlow documentation for the exact changes and compatibility of the Object Detection API with your TensorFlow version.

I faced the same issue with tensorflow 2.15.0 and I think the problem is with keras 2.15.0 that comes with this tf version. For me downgrading to 2.14.0 solved the issue.

change the library to ```
tf.keras.layers.BatchNormalization in the required python file.


According to the documentation you need to set that flag in your python file before importing tensorflow os.environ[“TF_USE_LEGACY_KERAS”] = “1”