Giter Site home page Giter Site logo

Comments (5)

giild avatar giild commented on June 8, 2024

Some additional information, in case someone else runs into the same issue. If I move backend setting to after the imports, load throws this error. Here is the log from console.

Using TensorFlow backend
2.12.0
Traceback (most recent call last):
File "/Users/peterlin/kaggle/ATD-keras/keras/convert_keras_to_json.py", line 98, in
main()
File "/Users/peterlin/kaggle/ATD-keras/keras/convert_keras_to_json.py", line 25, in main
run(input, outputfile)
File "/Users/peterlin/kaggle/ATD-keras/keras/convert_keras_to_json.py", line 29, in run
inputmodel = tf.keras.models.load_model(inputfile)
File "/Users/peterlin/miniconda3/envs/tf2_kg/lib/python3.10/site-packages/keras/saving/saving_api.py", line 204, in load_model
return saving_lib.load_model(
File "/Users/peterlin/miniconda3/envs/tf2_kg/lib/python3.10/site-packages/keras/saving/saving_lib.py", line 277, in load_model
raise e
File "/Users/peterlin/miniconda3/envs/tf2_kg/lib/python3.10/site-packages/keras/saving/saving_lib.py", line 242, in load_model
model = deserialize_keras_object(
File "/Users/peterlin/miniconda3/envs/tf2_kg/lib/python3.10/site-packages/keras/saving/serialization_lib.py", line 502, in deserialize_keras_object
instance = cls.from_config(inner_config)
File "/Users/peterlin/miniconda3/envs/tf2_kg/lib/python3.10/site-packages/keras_core/src/models/model.py", line 515, in from_config
return functional_from_config(
File "/Users/peterlin/miniconda3/envs/tf2_kg/lib/python3.10/site-packages/keras_core/src/models/functional.py", line 519, in functional_from_config
process_node(layer, node_data)
File "/Users/peterlin/miniconda3/envs/tf2_kg/lib/python3.10/site-packages/keras_core/src/models/functional.py", line 466, in process_node
layer(*args, **kwargs)
File "/Users/peterlin/miniconda3/envs/tf2_kg/lib/python3.10/site-packages/keras/utils/traceback_utils.py", line 70, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/Users/peterlin/miniconda3/envs/tf2_kg/lib/python3.10/site-packages/keras/engine/input_spec.py", line 251, in assert_input_compatibility
ndim = x.shape.rank
AttributeError: Exception encountered when calling layer 'res_net_backbone' (type ResNetBackbone).

'tuple' object has no attribute 'rank'

Call arguments received by layer 'res_net_backbone' (type ResNetBackbone):
• inputs=<KerasTensor shape=(160, 256, 256, 3), dtype=float32, name=input_layer>
• training=None
• mask=None

from keras-core.

SuryanarayanaY avatar SuryanarayanaY commented on June 8, 2024

Hi @giild ,

There is a this note already in documentation.

Note that the that the backend must be configured before importing keras_core, and the backend cannot be changed after the package has been imported.

Please refer the attached snapshot.

Screenshot 2023-09-05 at 12 51 48 PM

from keras-core.

giild avatar giild commented on June 8, 2024

thanks for pointing out it was at the bottom. Not gonna lie, I looked at the home page several times and didn't even see it. I've been contributing to Apache for 20 years and often we have troubleshooting page/section for common errors. I would suggest moving the note above example and giving it more emphasis. It's too easy to miss the way it is formatted it right now. I've seen this countless times on a variety of apache projects. Often what apache devs thought was obvious wasn't due to how we formatted or organized the documentation.

from keras-core.

giild avatar giild commented on June 8, 2024

Something else to consider. https://keras.io/keras_core/ is the official docs. Often, I refer to the source instead of docs out of habit. Would it make sense to update the readme on https://github.com/keras-team/keras-core with similar note? I know most devs would rather write code than docs and maintaining the same information in multiple places sucks. Maybe have the readme link to the official documentation URL to lessen the maintenance overhead.

from keras-core.

SuryanarayanaY avatar SuryanarayanaY commented on June 8, 2024

@giild ,

Thanks for the explanation. I think we can add a note in README.md for better visibility. I can create a PR once Team reviews this and gives nod.

from keras-core.

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.