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

tflearn import issue #1172

Open
krinali1901 opened this issue Jun 11, 2023 · 5 comments
Open

tflearn import issue #1172

krinali1901 opened this issue Jun 11, 2023 · 5 comments

Comments

@krinali1901
Copy link

Hello,

I am trying to run a code using tflearn. But even if i just try to import tflearn then it gives the below error
WARNING:tensorflow:From /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/compat/v2_compat.py:107: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term

mportError: cannot import name 'is_sequence' from 'tensorflow.python.util.nest' (/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/util/nest.py)

What can be done to resolve this?

@rela-v
Copy link

rela-v commented Jun 13, 2023

Hi! Thanks for your question.

tl;dr: everywhere you say "is_sequence" in your code, replace it with "is_sequence_or_composite".

Your problem

  • If you try to do the following:
    from tensorflow.python.util.nest import is_sequence
  • The following error results:
    ImportError: cannot import name 'is_sequence' from 'tensorflow.python.util.nest'
    (/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/tensorflow/python/util/nest.py)

Explanation of the Problem

If this is indeed the problem, then I encountered the same issue several days ago and was able to resolve it. The reason you are experiencing the error is that, as the error message says, you
cannot import name 'is_sequence' from 'tensorflow.python.util.nest'
which means that there was some issue in the import process. Indeed, cursory research reveals that there is no longer any name "is_sequence" in the nest.py module (per tensorflow/tensorflow@f564400).

Solution

If you visit the provided link above, there is a new function which will serve your purpose well named "is_sequence_or_composite()", which according to the source code does the same exact thing as "is_nested_or_composite()" (use whichever one floats your boat!).
Thus, replacing the "is_sequence" function with the "is_sequence_or_composite" function will resolve the error.
For more information on what a "nested structure" is, which is what this function actually checks for, see the following link:
https://www.tensorflow.org/api_docs/python/tf/nest

Thank you so much again for asking. I hope this works for you, and feel free to ask for any help you may need along the way!

-Rela

@MihaMarkic
Copy link

@rela-v It happens if one doesn't use is_sequence explictly, simple import tflearn is enough to trigger the error. So, it is not possible to correct the error which is most probably somewhere in tflearn code.

@MihaMarkic
Copy link

And as expected, is_sequence is imported in tflearn/layers/recurrent.py file.

@MihaMarkic
Copy link

Created a PR

@awsumbill
Copy link

In the meantime you can pip install tensorflow<2.13 to get around this untill it's fixed

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

No branches or pull requests

4 participants