Git Product home page Git Product logo

Comments (3)

yuan-w-gao avatar yuan-w-gao commented on July 26, 2024

Tutorial works as expected on keras 2.1.* (probably should add this to README if this is only intended to work with older versions of keras)

However with keras 2.2.* it generates the following error
Traceback (most recent call last): File "006_autoencoder.py", line 90, in <module> SEG.decode_all_images(d, data_dir) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/aitom/classify/deep/unsupervised/autoencoder/seg_src.py", line 61, in decode_all_images autoencoder = KM.load_model(op_join(data_dir, 'model', 'model-autoencoder.h5')) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/keras/engine/saving.py", line 419, in load_model model = _deserialize_model(f, custom_objects, compile) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/keras/engine/saving.py", line 258, in _deserialize_model .format(len(layer_names), len(filtered_layers)) ValueError: You are trying to load a weight file containing 7 layers into a model with 0 layers

Possible cause of this error include:

  1. the use of keras Input layer
  2. the presence of the input_shape parameter in function calls to keras.layers

Please refer to this issue for more details

Another possible workaround is proposed here. This workaround doesn't require changing the code line by line and add the additional parameter, but it seems a bit "hacky".

from aitom.

xulabs avatar xulabs commented on July 26, 2024

hi @buptwhr can you check the problem detected by @yg422 ?

from aitom.

buptwhr avatar buptwhr commented on July 26, 2024

@yg422 I've noticed this problem, so I put keras==2.1.0 in requirements.txt. As for the issue you've mentioned, I read it before. But I don't know how to avoid Input or input_shape.
By using autoencoder.load_weights() rather than KM.load_model(), I can solve the problem. But there are so many KM.load_model() and save_model in the project. I am not sure it'a stable choice.
I suggest using keras==2.1.0 to make minimal change to the original code.

from aitom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.