what is the meaning of (axis = 3) in the BatchNormalization?
Asked Answered
S

2

6
inputs = Input((img_height, img_width, img_ch))
conv1 = Conv2D(n_filters, (k, k), padding=padding)(inputs)
conv1 = BatchNormalization(scale=False, axis=3)(conv1)
conv1 = Activation('relu')(conv1)    
conv1 = Conv2D(n_filters, (k, k),  padding=padding)(conv1)
conv1 = BatchNormalization(scale=False, axis=3)(conv1)
conv1 = Activation('relu')(conv1)    
pool1 = MaxPooling2D(pool_size=(s, s))(conv1)

What is the meaning of (axis =3) in the BatchNormalization I read keras documentation but I coudln't understand it, can any one explain what does axis means?

Sanctitude answered 26/8, 2018 at 7:49 Comment(0)
G
5

It depends on how dimensions of your "conv1" variable is ordered. First, note that batch normalization should be performed over channels after a convolution, for example if your dimension order are [batch, height, width, channel], you want to use axis=3. Basically you choose the axis index which represents your channels.

Guggle answered 26/8, 2018 at 10:47 Comment(0)
A
2

A small correction is required in the above answer. If the dimension is [height, width, channel] then the axis is 3. The batch is not part of the input dimension.

Annelid answered 27/4, 2020 at 20:11 Comment(1)
input tensor shape is (m, n_H_prev, n_W_prev, n_C_prev) , he is correctArteritis

© 2022 - 2024 — McMap. All rights reserved.