Comments (9)
I'm having the same issue; attempting import tensorflow_hub
(which imports tf_keras
) fails with this error:
AttributeError: module 'tensorflow._api.v2.compat.v2.__internal__'
has no attribute 'register_load_context_function'.
Did you mean: 'register_call_context_function'?
This seems to be the result of some in-process refactoring of tf_keras/src/saving/legacy/saved_model
that has since been completed, so presumably a later release will fix.
At the moment, the default installs of tensorflow
and tensorflow_hub
install tensorflow 2.16.0rc0
and tf-keras 2.15
:
$ # start with new venv
$ python -m pip freeze | grep -e tensor -e keras
$ python -m pip install tensorflow keras tf-keras --no-cache-dir > /dev/null
$ python -m pip freeze | grep -e tensor -e keras
keras==3.0.5
tensorboard==2.16.2
tensorboard-data-server==0.7.2
tensorflow==2.16.0rc0
tf-keras==2.15.0
I've been trying to work around the incompatibility by reverting to a prior tensorflow release. I expect to be able to install out-of-date versions via pip
like this:
$ python -m pip index versions tf-keras
WARNING: pip index is currently an experimental command.
It may be removed/changed in a future release without prior warning.
tf-keras (2.15.0)
Available versions: 2.15.0, 2.14.1
$ python -m pip install tf-keras==2.14.1
Collecting tf-keras==2.14.1
Using cached tf_keras-2.14.1-py3-none-any.whl.metadata (1.6 kB)
Using cached tf_keras-2.14.1-py3-none-any.whl (1.7 MB)
Installing collected packages: tf-keras
Successfully installed tf-keras-2.14.1
However, this approach is not working with tensorflow. I don't see anything obviously broken at PyPI, but I've not been able to install prior tensorflow releases via pip.
$ python -m pip install tensorflow==2.15.0
ERROR: Could not find a version that satisfies the requirement tensorflow==2.15.0 (from versions: 2.16.0rc0)
ERROR: No matching distribution found for tensorflow==2.15.0
$ python -m pip index versions tensorflow
WARNING: pip index is currently an experimental command.
It may be removed/changed in a future release without prior warning.
ERROR: No matching distribution found for tensorflow
from tf-keras.
@MaxiBoether,
Could you please try to replace it from tensorflow import keras with import tf_keras as keras. Kindly find the gist for the reference.
Thank you!
from tf-keras.
Thanks for the swift response. This leads to the same error as outlined. Note that I tried two things: import tensorflow.keras
(which is equivalent to from tensorflow import keras) which imports keras 3 as expected, but importing import tf_keras (it shouldn't matter whether I add as keras
as requested since that's just the imported module name) fails. My goal is to import the legacy Keras 2 in a tf2.16 environment
from tf-keras.
Okay, I know what the issue is: By default (at least on my mac in a clean conda env), pip install tensorflow
installs tf2.16, and pip install tf_keras
installs tf_keras==2.15. On colab, pip install tensorflow defaults to v2.15. Since I just ran pip install tensorflow tf_keras
, we run into this issue.
The version mismatch (if enforced on colab) leads to this error.
from tf-keras.
It appears 2.16.0rc0 is a pre-release version of tensorflow. Running the same commands on a different host (ubuntu under wsl) gives me 2.15.0.post1
, which is what I would expect based on PyPI:
$ python -m pip index versions tensorflow
tensorflow (2.15.0.post1)
Available versions: 2.15.0.post1, 2.15.0, 2.14.1, 2.14.0, 2.13.1, 2.13.0, 2.12.1, 2.12.0, 2.11.1, 2.11.0, 2.10.1, 2.10.0, 2.9.3, 2.9.2, 2.9.1, 2.9.0, 2.8.4, 2.8.3, 2.8.2, 2.8.1, 2.8.0
INSTALLED: 2.15.0.post1
LATEST: 2.15.0.post1
Overall:
$ python -m pip freeze | grep -e tensor -e keras
keras==2.15.0
tensorboard==2.15.2
tensorboard-data-server==0.7.2
tensorflow==2.15.0.post1
tensorflow-estimator==2.15.0
tensorflow-hub==0.16.1
tensorflow-io-gcs-filesystem==0.36.0
tf-keras==2.15.0
With tensorflow 2.15.0.post1, tf-keras
loads correctly under tensorflow-hub
. I must have somehow misconfigured pip
to pull pre-release versions on the other machine. Time for a rebuild...
from tf-keras.
When you use TensorFlow 2.16 with RC0 and testing Keras 2 path, please install pip install tf-keras~=2.16.0rc0
(will install RC2). If you use pip install tf-keras
instead, it will install tf-keras==2.15
which is not compatible with TensorFlow 2.16.
The core of the issue is, in tf-keras 2.15
we didn't add a dependency to TensorFlow 2.15, so pip doesn't enforce that version compatibility. We fixed it in tf-keras 2.16
, but may be we need to add a patch release for tf-keras 2.15
to avoid this.
@robertbcalhoun - Can you try this and confirm?
from tf-keras.
This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.
from tf-keras.
Just trying to avoid this issue becoming stale :-)
from tf-keras.
This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.
from tf-keras.
Related Issues (20)
- Error while importing tf_keras HOT 11
- shape issue for y_pred for a custom made loss function HOT 3
- UNIMPLEMENTED: Cast string to float is not supported; CANCELLED: Function was cancelled before it was started HOT 3
- TextVectorization: output_mode={multi_hot, count} promise int arrays but output floats
- Cloning a TextVectorization Layer with Split Function Doesn't Work HOT 6
- Mirrored strategy model.load_weights() failure HOT 2
- sparse_categorical_crossentropy with ignore_class=-1 makes loss to `nan` HOT 3
- Addition of Reflect Padding Functionality for tf.keras Convolutional Layers HOT 2
- AttributeError: module 'tf_keras.backend' has no attribute 'logsumexp' HOT 6
- Custom Keras RNN with constants changes constants shape when saving HOT 3
- ValueError: (F1Score|FBetaScore) expects 2D inputs with shape (batch_size, output_dim). HOT 8
- LSTM - different outputs for same weights across CPU and GPU, when using float32 + tf-keras + NVIDIA A100 HOT 4
- RetinaNet with custom backbone and custom dataset HOT 3
- IntegerLookup with XLA Compilation Fails to Enable JIT in TensorFlow 2.16.1 and Keras 3.2.1 HOT 3
- conda-forge release HOT 1
- Failed to build Python package due to missing layer/experimental build HOT 2
- TF-Keras mixed precision training leads to autograph errors HOT 4
- Showing warning just after importing tf_keras HOT 2
- Error loading the trained model. HOT 1
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 tf-keras.