AttributeError: 'types.SimpleNamespace' object has no attribute 'get_registered_object' from return keras.saving.get_registered_object(config["registered_name"]) in keras_nlp\src\utils\preset_utils.py
want to run the demo in the local by following the getting started guide and config the kaggle API credentials with this doc but get error when run the setup 5: `import keras import keras_nlp import os
os.environ["KERAS_BACKEND"] = "jax"
gemma_lm = keras_nlp.models.GemmaCausalLM.from_preset("gemma_2b_en")`
what is the reason for this ? and how to fix that ?
Hi @jsplyy ,
It seems to be version issue for me. Could you please confirm the keras_nlp and keras version being used ? Please install latest versions of both and let us know the outcome. Thanks!
Hi @SuryanarayanaY I am using, Name: keras-nlp Version: 0.9.1 https://pypi.org/project/keras-nlp/ Name: keras Version: 2.10.0
try to update keras with command: pip upgrade keras
it will be updated to 3.1.1,
but when try to update keras_nlp with command: pip install --upgrade keras_nlp
keras-2.10.0 will be installed again.
keras_nlp seems to depends on and install 2.10.0 keras?
I checked the keras-nlp doc https://github.com/keras-team/keras-nlp/tree/master
it documented that both keras2 and keras3 are supported.
Which version should I install ?
keras_nlp seems to depends on and install 2.10.0 keras?
Hi @jsplyy ,
No, it don't have any dependency on Keras 2.10.0 . Please ensure all the dependencies in requirements.txt installed. Keras_nlp needs Tensorflow also. May be you might have TF2.10v which might be reason for this behaviour.
I also faced the same error and I have installed Tensorflow
is this issue still happening? can someone confirm?
@gustheman I'm still having this issue. When installing keras_nlp==0.12.1 it installs keras==2.10.0 and tf 2.10.1. Also when using keras_nlp==0.14.1 it doesn't let to import to jupyter due missing ops module. Somehow it works when installing libaries in the following order:
!pip install -U -q keras-nlp !pip install -q -U keras>=3
KerasNLP no longer supports Keras 2, we are focusing on Keras 3. This means a few things...
- The latest versions of KerasNLP or Keras do not work with TensorFlow 2.14 or earlier.
- For TensorFlow 2.15. You need the weird install line @jvrapp showed. This is because Tensorflow 2.15 will pull in Keras 2 during installation.
!pip install -U -q keras-nlp
!pip install -q -U keras>=3
- For TensorFlow 2.16 and greater. Everything should work normally. Tensorflow 2.16 will pull in Keras 3. Everything cooperates.
So TL;DR, make sure you base installation has tensorflow >2.16 and tensorflow-text >2.16 and things should be fine.
In a colab environment, this should be quite simple. Colab now comes with TensorFlow 2.17. So
!pip install keras-nlp will do the right thing and pull in all necessary dependancies.
With a base environment where Tensorflow is older, you might want to do something like this to make sure your tf is upgraded...
!pip install -U keras-nlp tensorflow tensorflow-text
Hope that helps!
Hi @JingsaiLu,
Could you please confirm if this issue is resolved for you with the above comment ? Please feel free to close the issue if it is resolved ?
Thank you.
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.
This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.