keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
62.06k stars 19.48k forks source link

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 #19456

Open JingsaiLu opened 7 months ago

JingsaiLu commented 7 months ago

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")`

image

what is the reason for this ? and how to fix that ?

SuryanarayanaY commented 7 months ago

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!

JingsaiLu commented 7 months ago

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, image

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? image

I checked the keras-nlp doc https://github.com/keras-team/keras-nlp/tree/master it documented that both keras2 and keras3 are supported. image

Which version should I install ?

SuryanarayanaY commented 7 months ago

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.

dongex commented 7 months ago

I also faced the same error and I have installed Tensorflow

gustheman commented 4 months ago

is this issue still happening? can someone confirm?

jvrapp commented 3 months ago

@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

mattdangerw commented 3 months ago

KerasNLP no longer supports Keras 2, we are focusing on Keras 3. This means a few things...

So TL;DR, make sure you base installation has tensorflow >2.16 and tensorflow-text >2.16 and things should be fine.

mattdangerw commented 3 months ago

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!

Gopi-Uppari commented 1 month ago

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.