Search code examples
pythondeep-learningkerasdata-sciencekeras-layer

The depth of pooling layer and prior convolution layer should same. But it is not same, kindly let me know the solutions


model = Sequential()

model.add(keras.layers.InputLayer(input_shape=input_shape))

model.add(keras.layers.convolutional.Conv2D(filters, filtersize, strides=(1, 1), padding='valid', data_format="channels_last", activation='relu'))

model.summary()

and output summary is :

_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
input_10 (InputLayer)        (None, 300, 300, 3)       0         
_________________________________________________________________
conv2d_16 (Conv2D)           (None, 296, 296, 10)      760       
_________________________________________________________________
max_pooling2d_13 (MaxPooling (None, 296, 148, 5)       0         
_________________________________________________________________

Above for conv2d_16 layer 10 is depth where as Maxpooling layer 5, how does it possible?


Solution

  • You're very probably using the setting data_format='channels_first' in the pooling layer.

    I see you added 'channels_last' to the convolutional layer, but you probably didn't add it to the pooling layer.

    If you want to change the default setting for keras, find the <user>/.keras/keras.json file and change it there.