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

ValueError: Layer weight shape (3, 3, 3, 64) not compatible with provided weight shape (64, 3, 3, 3) #39

Open
chikiuso opened this issue Apr 6, 2017 · 13 comments

Comments

@chikiuso
Copy link

chikiuso commented Apr 6, 2017

Hi, I got the following message running the command, it seems to be the weight shape problem , any idea on solving it? thanks :

Traceback (most recent call last):
File "/usr/local/bin/make_image_analogy.py", line 27, in
image_analogy.main.main(args, model_class)
File "/usr/local/lib/python2.7/dist-packages/image_analogy/main.py", line 69, in main
net = vgg16.get_model(img_width, img_height, weights_path=args.vgg_weights, pool_mode=args.pool_mode)
File "/usr/local/lib/python2.7/dist-packages/image_analogy/vgg16.py", line 89, in get_model
layer.set_weights(weights)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 1154, in set_weights
'provided weight shape ' + str(w.shape))
ValueError: Layer weight shape (3, 3, 3, 64) not compatible with provided weight shape (64, 3, 3, 3)

@awentzonline
Copy link
Owner

I suspect you have keras 2 installed, but this only runs on v1. I need to update the versions in setup.py. To confirm, run pip show keras.

@chikiuso
Copy link
Author

chikiuso commented Apr 7, 2017

Hi creator of project, yes, my keras version is 2.02

@AhmadBaracat
Copy link

Hi @awentzonline, are you planning on supporting Keras 2 anytime soon? Is there a workaround for the time being?

@pmlantos
Copy link

Hi, I had the same question as above. I don't have a way to access anything below Keras 2 as I'm using a shared computing cluster. Any suggestions?
Thanks!

@AhmadBaracat
Copy link

@pmlantos What I have done is to use virtualenv and instal Keras==1.1.1 on it. Not sure if that is feasible in your case.

@pmlantos
Copy link

pmlantos commented Apr 29, 2017 via email

@pmlantos
Copy link

Unfortunately I can't get this package to run within a virtual environment, though setting the environment up seems straightforward. Wonder if I can find a way to cheaply do it on AWS.

@AhmadBaracat
Copy link

That's what worked for me. Hope it helps.

  1. Activate the virtualenv
  2. Check the version of keras installed using pip show keras
  3. If it is Keras version 2 then pip uninstall keras followed by pip install keras==1.1.1.
  4. Uninstall image-analogies
  5. Reinstall image-analogies

@pmlantos
Copy link

pmlantos commented Apr 30, 2017 via email

@AhmadBaracat
Copy link

AhmadBaracat commented Apr 30, 2017

No worries, but I think that if you are using virtualenv then you don't need to depend on shared parts because you get to create an isolated environment.

@oceanjack
Copy link

I have same problem as first

make sure that

requirements.txt

Cython==0.23.4
h5py==2.5.0
Keras==1.1.1
numpy==1.10.4
Pillow==3.1.1
PyYAML==3.11
scipy==0.17.0
scikit-learn==0.17.0
six==1.10.0
-e git://github.com/Theano/Theano.git@954c3816a40de172c28124017a25387f3bf551b2#egg=Theano

and I use sudo pip install theano==0.9.0b1

than it works~

@oceanjack
Copy link

and make sure that you have edit ~/.keras/keras.json like this
{
"image_dim_ordering": "th",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "theano"
}

@HeadstrongCatgirl
Copy link

HeadstrongCatgirl commented Oct 12, 2017

I have replaced the 94th line in image_analogy/vgg16.py with
weights[0] = np.transpose(np.array(weights[0])[:, :, ::-1, ::-1], (2, 3, 1, 0))
and it works like charm now.

zkneupper added a commit to zkneupper/image-analogies that referenced this issue Oct 17, 2017
…, 3) to (3, 3, 3, 64) for keras versions 2.0.0 and above.
zkneupper added a commit to zkneupper/image-analogies that referenced this issue Oct 17, 2017
…, 3) to (3, 3, 3, 64) for keras versions 2.0.0 and above.
rharriso added a commit to rharriso/image-analogies that referenced this issue Oct 23, 2018
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

6 participants