Skip to content
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

vgg.load_weights(VGG_Weights_path) Error: input shapes: [102400,4096], [25088,4096] #3

Closed
VeniVidiGavi opened this issue Sep 28, 2017 · 15 comments

Comments

@VeniVidiGavi
Copy link

I am getting an error at the line:
vgg.load_weights(VGG_Weights_path)

the error is:
ValueError: Dimension 0 in both shapes must be equal, but are 102400 and 25088 for 'Assign_26' (op: 'Assign') with input shapes: [102400,4096], [25088,4096].

Please note that:
I am running Keras with the Tensorflow backend because, with the Theano backend, I am getting an error which causes Theano to run on the CPU rather thsan the GPU (and only on 1 Core of the CPU).
ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: ('nvcc return status', 2, ....

@divamgupta
Copy link
Owner

Yes, This error is because of the Tensorflow backend. We don;t support tensorflow backend currently. Try installing latest version of nvcc and theano.

@anas-899
Copy link

anas-899 commented Oct 9, 2017

@VeniVidiGavi did you discover how to solve it? .. I got the same error

@noamgal
Copy link

noamgal commented Oct 24, 2017

@anas-899 @VeniVidiGavi I just removed the arguments input_width and input_height for both train.py and predict.py and it worked well

@DawnMe
Copy link

DawnMe commented Nov 20, 2017

@noamgal It works well, thanks! I got another error after the fix AttributeError: 'itertools.cycle' object has no attribute 'next', but changes to next(zipped) at "/image-segmentation-keras/LoadBatches.py" and now it works.

@gpkc
Copy link

gpkc commented May 3, 2018

If you remove the input_width and input_height it will simply use the default size of 224x224 I believe.

@quelibrio
Copy link

Yes default values don't work. Just go to /home/.keras/keras.json and change to
{
"floatx": "float32",
"epsilon": 1e-07,
"backend": "theano",
"image_data_format": "channels_last"
}

@gpkc
Copy link

gpkc commented May 9, 2018

Then you'll be changing your backend to Theano. Some people can't use Theano (for example if you want to train on Google Cloud ML).

@quelibrio
Copy link

Ye you won't be able to train on google cloud, but since authors state "We don't support tensorflow backend currently" i don't see other option

@Cbanyungong
Copy link

This error happens because VGG16 was designed for images with size of 224. But the given code uses Input(shape=(3,416,608). If you do not replace the input shape with (3,224,224),you will meet the error that "ValueError: Dimension 0 in both shapes must be equal, but are ***** and 25088 for 'Assign_26' (op: 'Assign') with input shapes: [****,4096], [25088,4096]".Remove arguments input_width and input_height for both train.py and predict.py and it worked well becasue the train.py and predict.py use default arguments" 224".I find the code don't support tensorflow backend because tensorflow uses "channels_last" and theano uses "channels_first" .So if you want the code support tensorflow backend,just change input shape with (224,224,3) and change "data_format='channels_first'" with " data_format='channels_last". @VeniVidiGavi @anas-899 @quelibrio @gpkc

@gpkc
Copy link

gpkc commented Jun 22, 2018

@Cbanyungong Why is it exactly that makes it necessary to keep the size 224? Aren't CNNs kernel-based and therefore independent of input size (i.e. they just train the kernel weights)?

@Ployl
Copy link

Ployl commented Jun 26, 2018

I'm getting this error in Line 105 of the FCN8 ( o = Add()([ o , o2 ])):
ValueError: Operands could not be broadcast together with shapes (14, 16, 10) (14, 14, 10)

Any ideas why this is happening?

I try to use tensorflow as backend aswell and did everything mentioned in this post.

@mgq1507
Copy link

mgq1507 commented Oct 7, 2018

@noamgal It works well, thanks! I got another error after the fix AttributeError: 'itertools.cycle' object has no attribute 'next', but changes to next(zipped) at "/image-segmentation-keras/LoadBatches.py" and now it works.

Have you solved the problem?

@shodme
Copy link

shodme commented Oct 12, 2018

@mgq1507 you can try to replace zipped.next() with zipped._next_() in LoadBatches.py

@patrikoss
Copy link

@gpkc

Why is it exactly that makes it necessary to keep the size 224? Aren't CNNs kernel-based and therefore independent of input size (i.e. they just train the kernel weights)?

CNNs are indeed independent of input size, but VGG net is not fully convolutional. It has some fully-connected layers at the end. At the time of flattening the input the mismatch of the shape occur.

@divamgupta
Copy link
Owner

Image segmentation keras has been updated. The new version should fix the issue.

divamgupta pushed a commit that referenced this issue Apr 1, 2020
duraes-antonio added a commit to duraes-antonio/image-segmentation-keras that referenced this issue Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests