Comments (5)
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.
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.
from keras-core.
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.
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.
@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)
- tflite cannot fuse `BatchNormalization` in Keras Core as effectively as in the original Keras
- How can we use `ops.reshape` when the `new_shape` is obtained from `ops.shape`? HOT 3
- GSOC Program Organization ( question ) HOT 1
- Constant Initializer supports only Scalar values HOT 1
- Add support for RaggedTensors to JAX and Pytorch Backend HOT 1
- Saving broken between tf.keras and Keras Core HOT 9
- Ensure workflow reliability by hash-pinning GitHub Actions HOT 1
- Run actions.yml with read-only permissions
- Segmentation metrics HOT 3
- Use of PyTorch loss functions inside Keras
- Is possible serialize models which use torch functions? HOT 5
- Expose `Operation` without `src` import hacks HOT 1
- v0.1.6 bug: AttributeError: 'GPT2CausalLM' object has no attribute 'compiled' HOT 2
- Adam with amsgrad=True + JAX backend is broken HOT 1
- Inconsistent type handling between backends HOT 1
- Matmul - tensorflow does not broadcast/expand dimensions correctly HOT 3
- Casting dtype in losses.Loss base class HOT 2
- TypeError: copy() got an unexpected keyword argument 'overwrite' HOT 2
- Error when running the model.fit on the wrapped model "Only input tensors may be passed as positional arguments."
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keras-core.