'cannot import name 'BatchNormalization' from 'keras.layers.normalization'

I'm learning ObjectDetection from this website

I have installed ImageAI,Tensorflow and Keras.

Then when I run this in python

    from imageai.Detection import ObjectDetection

I got

Traceback (most recent call last): File "", line 1, in File "/home/carl/python-environments/env/lib/python3.9/site-packages/imageai/Detection/init.py", line 17, in from imageai.Detection.YOLOv3.models import yolo_main, tiny_yolo_main File "/home/carl/python-environments/env/lib/python3.9/site-packages/imageai/Detection/YOLOv3/models.py", line 8, in from keras.layers.normalization import BatchNormalization ImportError: cannot import name 'BatchNormalization' from 'keras.layers.normalization' (/home/carl/python-environments/env/lib/python3.9/site-packages/keras/layers/normalization/init.py)

Already tried:

    from keras.layers.normalization.batch_normalization import BatchNormalization
    from tensorflow.keras.layers import BatchNormalization

But still gave me the same error.



Solution 1:[1]

Tensorflow v2.8.0 support tf.keras.layers.BatchNormalization()

import tensorflow as tf
tf.keras.layers.BatchNormalization()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TFer