Keras Maxpooling2d layer gives ValueError

后端 未结 7 1698
难免孤独
难免孤独 2021-02-07 00:10

I am trying to replicate VGG16 model in keras, the following is my code:

model = Sequential()
model.add(ZeroPadding2D((1,1),input_shape=(3,224,224)))
model.add(C         


        
7条回答
  •  遥遥无期
    2021-02-07 00:32

    The accepted answer works. But you can also do the following:

        model.add(MaxPooling2D((2, 2), name='block1_pool', data_format='channels_last')
    

    Keras assumes input to be (width, height, channels) for TensorFlow backend and (channel, width, height) for Theano backend. Since your input_shape=(3,224,224), specifying data_format='channels_last' should do the trick.

提交回复
热议问题