keras icon indicating copy to clipboard operation
keras copied to clipboard

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

Open JingsaiLu opened this issue 1 year ago • 9 comments

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 ?

JingsaiLu avatar Apr 07 '24 07:04 JingsaiLu

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!

SuryanarayanaY avatar Apr 08 '24 05:04 SuryanarayanaY

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 ?

JingsaiLu avatar Apr 08 '24 06:04 JingsaiLu

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.

SuryanarayanaY avatar Apr 08 '24 07:04 SuryanarayanaY

I also faced the same error and I have installed Tensorflow

dongex avatar Apr 17 '24 00:04 dongex

is this issue still happening? can someone confirm?

gustheman avatar Jul 17 '24 15:07 gustheman

@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

jvrapp avatar Jul 30 '24 15:07 jvrapp

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.

mattdangerw avatar Aug 01 '24 16:08 mattdangerw

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!

mattdangerw avatar Aug 01 '24 16:08 mattdangerw

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.

Gopi-Uppari avatar Sep 30 '24 05:09 Gopi-Uppari

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.

github-actions[bot] avatar Dec 07 '24 02:12 github-actions[bot]

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.

github-actions[bot] avatar Dec 22 '24 02:12 github-actions[bot]

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Dec 22 '24 02:12 google-ml-butler[bot]