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

Fix for issue #39. #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

zkneupper
Copy link

This pull request is intended to fix issue #39 (ValueError: Layer weight shape (3, 3, 3, 64) not compatible with provided weight shape (64, 3, 3, 3) ) and to make the image-analogies package compatible with keras versions 2.0.0 and above.

I only made changes to the vgg16.py file.

The newly added code does the following:

  1. It checks if your version of keras is version '2.0.0' or above;

  2. If your version of keras is version '2.0.0' or above, then it (1) converts each element x of the list 'weights' into a numpy array, (2) transposes each of those arrays, and (3) saves the list of transposed arrays back to the 'weights' list.

         weights_T = [np.array(x).T for x in weights]
         weights = weights_T            
    
  3. If your version of keras is version not '2.0.0' or above, the 'weights' list is left unchanged; the elements of 'weights' are left untransposed.

Transposing the weights is necessary for compatibility with keras is version '2.0.0' or above.

The code should still be compatible with earlier versions of keras before version '2.0.0'.

…, 3) to (3, 3, 3, 64) for keras versions 2.0.0 and above.
…, 3) to (3, 3, 3, 64) for keras versions 2.0.0 and above.
@rharriso
Copy link

Thanks! curled this into my installed package and started working just fine!

@mike-truk
Copy link

This worked for me as well -- many thanks!

@ljslj
Copy link

ljslj commented May 17, 2019

图片
why i run the make_image_analoy.py,the result is that, i don't know how to solve it? thanks.
图片

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

Successfully merging this pull request may close these issues.

4 participants