0
$\begingroup$

I created a CNN model and it is saved in h5 format. I used the Netron app, where I obtained the model architecture, however batchnormalization was not present.

CNN model:

model = Sequential()
model.add(Conv2D(16, (3, 3), input_shape=(height, width, 3), kernel_regularizer=l2(0.001)))
model.add(Activation('relu'))
# BatchNormalization()
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2)))

BatchNormalization()

model.add(Conv2D(32, (3, 3), kernel_regularizer=l2(0.001)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2)))

BatchNormalization()
model.add(Dropout(.5))

model.add(Conv2D(32, (3, 3), kernel_regularizer=l2(0.001)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2)))

BatchNormalization()
model.add(Dropout(.3))

model.add(Conv2D(64, (3, 3), kernel_regularizer=l2(0.001)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2), strides=(2)))

BatchNormalization()
model.add(Dropout(.3))

model.add(Flatten())

model.add(Dense(256))
model.add(Activation('relu'))

model.add(Dropout(.5))

model.add(Dense(4,activation='softmax'))

The output of Netron app:

enter image description here

I have saved this model in h5 format. Is there a method to determine whether this h5 model has a batchnormalization layer or not. Again, is it possible to know the learning rate?

$\endgroup$
1
  • $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$
    – Community Bot
    Commented Sep 18, 2022 at 23:08

1 Answer 1

1
$\begingroup$

We can't see the BatchNorm layer in Netron, so NO. It doesn't have BatchNorm but for good reason. In testing, you don't need BatchNorm (that is the possible reason why it has been done).

Second, for learning rate, you can't get that because .h5 stores the network and its weights. You don't need learning rate to test or run a model.

$\endgroup$
2
  • $\begingroup$ Your main answer seems to be correct, but it seems misleading to state that batchnorm is "not needed" during testing. It is certainly true one often does not want to update the batchnorm parameters during testing, but it does not follow that one should remove it - the normalization can still be crucial for the overall network to work if it was trained with batchnorm. $\endgroup$
    – mikkola
    Commented Sep 20, 2022 at 13:56
  • $\begingroup$ Could the batchnorm weight and bias be "adopted" to the subsequent layer's parameters? I think it is mathematically possible, but I have no idea whether the framework does that. I guess you could save and reload the model, and check. Actually dropout isn't needed either, don't you just multiply all outputs by a factor when running interference? $\endgroup$
    – NikoNyrh
    Commented Sep 20, 2022 at 18:42

Not the answer you're looking for? Browse other questions tagged .