<p>This thread is misleading.  Tried commenting on Lucas Ramadan's answer, but I don't have the right privileges yet, so I'll just put this here.</p>

<p>Batch normalization works best after the activation function, and <a href="https://arxiv.org/abs/1502.03167" rel="noreferrer">here</a> or <a href="https://standardfrancis.wordpress.com/2015/04/16/batch-normalization/" rel="noreferrer">here</a> is why: it was developed to prevent internal covariate shift. Internal covariate shift occurs when the distribution of the <em>activations</em> of a layer shifts significantly throughout training.  Batch normalization is used so that the distribution of the inputs (and these inputs are literally the result of an activation function) to a specific layer doesn't change over time due to parameter updates from each batch (or at least, allows it to change in an advantageous way).  It uses batch statistics to do the normalizing, and then uses the batch normalization parameters (gamma and beta in the original paper) "to make sure that the transformation inserted in the network can represent the identity transform" (quote from original paper).  But the point is that we're trying to normalize the inputs to a layer, so it should always go immediately before the next layer in the network.  Whether or not that's after an activation function is dependent on the architecture in question.</p>
Where do I call the BatchNormalization function in Keras?
<p>If I want to use the BatchNormalization function in Keras, then do I need to call it once only at the beginning?</p>

<p>I read this documentation for it: <a href="http://keras.io/layers/normalization/">http://keras.io/layers/normalization/</a></p>

<p>I don't see where I'm supposed to call it. Below is my code attempting to use it:</p>

<pre><code>model = Sequential()
keras.layers.normalization.BatchNormalization(epsilon=1e-06, mode=0, momentum=0.9, weights=None)
model.add(Dense(64, input_dim=14, init='uniform'))
model.add(Activation('tanh'))
model.add(Dropout(0.5))
model.add(Dense(64, init='uniform'))
model.add(Activation('tanh'))
model.add(Dropout(0.5))
model.add(Dense(2, init='uniform'))
model.add(Activation('softmax'))

sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='binary_crossentropy', optimizer=sgd)
model.fit(X_train, y_train, nb_epoch=20, batch_size=16, show_accuracy=True, validation_split=0.2, verbose = 2)
</code></pre>

<p>I ask because if I run the code with the second line including the batch normalization and if I run the code without the second line I get similar outputs. So either I'm not calling the function in the right place, or I guess it doesn't make that much of a difference.</p>