How does Keras BatchNormalization work? I have read some articles and watched some videos by Andrew Ng stating that it makes more sense to use batch normalization before applying the activation function.
model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3), activation='relu', input_shape=input_shape))
model.add(BatchNormalization())
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(BatchNormalization())
model.add(Conv2D(64, kernel_size=(3, 3), activation='relu'))
model.add(BatchNormalization())
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(BatchNormalization())
model.add(Flatten())
model.add(Dense(256, activation='relu'))
model.add(BatchNormalization())
model.add(Dense(no_classes, activation='softmax'))

We add layers to the sequential model, apply the activation function to the layer itself, and then add a batch normalization layer. So, is it similar to applying the activation function before normalizing the values? If so, is there a way to apply batch normalization before applying the activation function?
Check out this answer, and other answers too. They explained the what the ideal order is and why so. Also, you can just add layer of activation function.
from tensorflow.keras import layers
from tensorflow.keras import activations

model.add(layers.Activation(activations.relu))

They are actually first things when you search on google, so I kindly recommend you to search before asking