Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'keras.backend' has no attribute 'logsumexp' #14647

Closed
gitfourteen opened this issue May 16, 2021 · 7 comments
Closed

Comments

@gitfourteen
Copy link

gitfourteen commented May 16, 2021

Using Colab
keras.version is 2.4.3 if import keras directly

when help(keras.backend.logsumexp), get error

AttributeError: module 'keras.backend' has no attribute 'logsumexp'

What's wrong?

@bizzmug
Copy link

bizzmug commented May 18, 2021

same thing =(
have u find out where it is?

@gitfourteen
Copy link
Author

gitfourteen commented May 22, 2021

same thing =(
have u find out where it is?

The best way is switch to tf.math.reduce_logsumexp. I don't want to change the default colab environment.

If checking 'logsumexp' in dir(K) in current colab setting, you will get a False

No matter using keras script in old style(keras.__version__ is 2.4.3)
import keras
from keras import backend as K

or in suggested way(keras.__version__ is 2.4.0)
from tensorflow import keras
from tensorflow.keras import backend as K

Don't know why this keras.backend keeps changing from version to version... I hope someone help elaborate more on this?

And I don't know whether the keras version 2.4.3 is equivalent to master. The keras.backend in master branch do have logsumexp

@jvishnuvardhan
Copy link
Contributor

@gitfourteen Is this still an issue for you?

I ran your code with recent TF2.7 and I don't see any error. Please check the gist here. Thanks!

@google-ml-butler
Copy link

This issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Thank you.

@google-ml-butler
Copy link

Closing as stale. Please reopen if you'd like to work on this further.

@gitfourteen
Copy link
Author

gitfourteen commented Mar 28, 2024

Holy... run into this problem again when playing colab... and google popping out the same old years ago...
Confused, really. To be able to use logsumexp, what are the appropriate way to import Keras 2 and Keras 3, respectively? (Update, there are no logsumexp when dir(K))

Here are what I have tried.
import 1:

import tensorflow as tf
import keras
import keras.backend as K

and test:

tf.__version__ #2.15.0
keras.__version__ # 2.15.0
help(K.logsumexp)

change runtime type and restart session.
import 2:

import tensorflow as tf
from tensorflow import keras
from keras import backend as K

and test:

tf.__version__ #2.15.0
K.logsumexp

Both get AttributeError: module 'keras.backend' has no attribute 'logsumexp'.

@gitfourteen
Copy link
Author

gitfourteen commented Mar 28, 2024

@gitfourteen Is this still an issue for you?

I ran your code with recent TF2.7 and I don't see any error. Please check the gist here. Thanks!

Test the way you import under tf of 2.14, 2.15, 2.16.1 and all perfectly failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants