Keras BatchNormalization layer incompatibility error

412 Views Asked by At

I have the following (part of) network architecture:

enter image description here

Obtained by

...
pool = GlobalAvgPool()(gc_2)
predictions = Dense(units=32, activation='relu', use_bias=False)(pool)
predictions = BatchNormalization()(predictions)
...

I am trying to insert a batch normalization layer, but I get the following error:

ValueError: Input 0 of layer batch_normalization_1 is incompatible with the layer: expected ndim=2, found ndim=3. Full shape received: [None, 1, 32]

I am guessing the second dimension is causing this mishap. Is there any way I can get rid of it?

1

There are 1 best solutions below

0
On

If your model is complied successfully, there is no problem with your model definition.

This is more likely to happen because of the input data shape and dimensions are incompatible with your model's desired input shape.

expected ndim=2, found ndim=3. means that the model requires a 2D tensor with