-
Notifications
You must be signed in to change notification settings - Fork 413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ValueError: Negative dimension size caused by subtracting 2 from 1 for 'max_pooling2d_1/MaxPool' #14
Comments
I also got these problem....... |
This caused by the different version of Keras. You could do the following changes.
|
It doesn't work. After change input_shape to (28, 28, 1), got the following |
The default parameter of 'data_format' for Conv2d layer and pooling layer is 'channel_last', see [Keras doc] While the input data format is 'channel_first', it causes the conflict. You can either change the parameters, or change the input shape. This is my version and it works fine in my environment( Keras==2.0.4 && Python==3.6). |
I just modified the code to fit tensorflow backend, you can try to use this one. |
Hi,
|
I also got these problem.......,have you solved? |
You need to change the order of the data. Tensorflow uses [samples][height][width][channels] order, while Theano is in reverse order. |
The shape of the input should have the channel last as you are using Tensorflow. |
@MacwinWin You forgot to add the batch size which needs to be the first element. |
The problem you have is very simple. The MaxPooling2D layer in Tf uses padding='valid' as default. When the input shape is defined, model is built alongside checking the architecture, in some cases the architecture raises a computing problem (when few functions are mathematically incooperative). To solve the problem, you need not change the input shape(HxWxchannel - 224, 224, 1), but just go over to the code line and change the parameter padding='valid' to padding='same'. If there is no padding='valid in your code, then add it as below. model.add(MaxPooling2D((2,2), strides=(2,2), padding='same')) more info on the topic can be found here - https://www.tensorflow.org/api_docs/python/tf/keras/layers/MaxPool2D |
When I try to run:
python dcgan.py --mode train --batch_size 100
I get the following:Any ideas what is going wrong here?
The text was updated successfully, but these errors were encountered: