cannot import name 'ops' from 'keras' when importing keras_hub

87 views
Skip to first unread message

Nicky Mac

unread,
Dec 13, 2024, 4:09:46 PM12/13/24
to Keras-users
very excited by the keras_hub presentation
 
I have keras 2.10.0 and now installed keras-hub 0.18.1 with no dependency conflicts.
I am on windows10 with python3.9 and have to stay with tensorflow 2.10.0
?what version of keras should I have to fix this problem:

    import keras_hub
Traceback (most recent call last):
  File "D:/OurStuff/AI/keras/keras_inference.py", line 1, in <module>
    import keras_hub
  File "C:\Python\Python39\lib\site-packages\keras_hub\__init__.py", line 10, in <module>
    from keras_hub.api import *  # noqa: F403
  File "C:\Python\Python39\lib\site-packages\keras_hub\api\__init__.py", line 7, in <module>
    from keras_hub.api import bounding_box
  File "C:\Python\Python39\lib\site-packages\keras_hub\api\bounding_box\__init__.py", line 7, in <module>
    from keras_hub.src.bounding_box.converters import convert_format
  File "C:\Python\Python39\lib\site-packages\keras_hub\src\bounding_box\converters.py", line 4, in <module>
    from keras import ops
ImportError: cannot import name 'ops' from 'keras' (C:\Python\Python39\lib\site-packages\keras\__init__.py)
   

Matias Valdenegro

unread,
Dec 13, 2024, 7:01:09 PM12/13/24
to keras...@googlegroups.com

keras.ops is only available in Keras 3, this you have a version of keras that is too old, you probably need Keras 3 instead of 2.10.

Nicky Mac

unread,
Dec 14, 2024, 8:30:25 AM12/14/24
to Matias Valdenegro, keras...@googlegroups.com
thankyou friends.  It seems that having tensorflow 2.10.0 restricts keras to 2.10 or 2.11
I;ve upgraded keras to 3.7.0 anyway to see what happens...
Nick

--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/keras-users/2472731.EWBfLOe8Lm%40vsd-grey-wolf.


--
Nick "Mac" McElwaine

Sitam Meur

unread,
Dec 15, 2024, 12:23:44 PM12/15/24
to Nicky Mac, Keras-users

So the concept of ops is actually from keras 3 version. As you say you are using the keras 2 version. So that's why you are getting this error. To resolve this you need to have keras 3 installed.


--
You received this message because you are subscribed to the Google Groups "Keras-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to keras-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages