fchollet / deep-learning-models

Keras code and weights files for popular deep learning models.
MIT License
7.32k stars 2.46k forks source link

Error negative dimension creating resnet50, #76

Open chuski92 opened 7 years ago

chuski92 commented 7 years ago

Hello.

I have a problem while creating a resnet50 network. I used your script to create my network, but I have this error:

"ValueError: Negative dimension size caused by subtracting 7 from 3 for 'avg_pool/AvgPool' (op: 'AvgPool') with input shapes: [?,3,3,2048]."

The neural layers are the same that you use in your code, so I don't know what is the issue. I use tensorflow 1.3 and keras 2.0.6 in ubuntu using anaconda and spyder.

I have the same problem while creating GoogLeNet v1... I don't know what to do because I'm noob in deep learning.

Thank you very much.

vaibhav12345 commented 6 years ago

Check the keras.json file If it has "channels first", the first layer of the model must have the input_shape as input_shape=(channels,img_rows, img_cols)

Otherwise the input shape must be input_shape=(img_rows, img_cols,channels)

This should solve the negative dimension error

chuski92 commented 6 years ago

hello vaibhav! thank you for your reply. I found the problem. It is about the size of the image and the number of the strides in maxpool and avgpool, if the image is too small the strides has to be small.

lmbak commented 5 years ago

Detailed explenation by lewfish.