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

import tensorflow as tf, tf_keras #13522

Open
cg-tester opened this issue Jan 16, 2025 · 5 comments
Open

import tensorflow as tf, tf_keras #13522

cg-tester opened this issue Jan 16, 2025 · 5 comments
Assignees
Labels
models:official models that come under official repository stale stat:awaiting response Waiting on input from the contributor type:bug Bug in the code

Comments

@cg-tester
Copy link

import tensorflow as tf, tf_keras

This is incorrect syntax.

Why use this import multiple times?

@cg-tester cg-tester added the type:bug Bug in the code label Jan 16, 2025
@mihaimaruseac
Copy link

mihaimaruseac commented Jan 16, 2025

Why do you say it's incorrect1? What error do you see? What is the version of Python that you are using? What operating system?

Is this the same setup as tensorflow/tensorflow#85074?

As a side note, here is what I see on Linux2

Python 3.11.9 (main, Jun 19 2024, 00:38:48) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf, keras
2025-01-16 13:17:41.202839: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
>>> type(tf)
<class 'module'>
>>> type(keras)
<class 'module'>
>>> tf.__path__
['/tmp/test-ms/venv/lib/python3.11/site-packages/keras/api/_v2', '/tmp/test-ms/venv/lib/python3.11/site-packages/keras/_tf_keras', '/tmp/test-ms/venv/lib/python3.11/site-packages/tensorflow', '/tmp/test-ms/venv/lib/python3.11/site-packages/tensorflow/_api/v2']
>>> keras.__path__
['/tmp/test-ms/venv/lib/python3.11/site-packages/keras', '/tmp/test-ms/venv/lib/python3.11/site-packages/keras/api']

This proves that the syntax is correct and both modules are properly installed

Footnotes

  1. It is a format that goes against the Python style guide, but it is not invalid, it does not result in an error.

  2. Note that I use keras instead of tf_keras because I did not install tf_keras. This should not matter

@cg-tester
Copy link
Author

I am using python 3.10
import tensorflow as tf, tf_keras
Is it correct syntax?
how can be 2 items after "as"?

@mihaimaruseac
Copy link

It is importing tensorflow as tf and then keras as a separate package, without an alias

@laxmareddyp laxmareddyp transferred this issue from tensorflow/models Jan 17, 2025
@mihaimaruseac
Copy link

This actually belongs in tensorflow/models since it refers to the documentation present in that repo, @laxmareddyp

@laxmareddyp laxmareddyp transferred this issue from tensorflow/tensorflow Jan 17, 2025
@laxmareddyp laxmareddyp added models:official models that come under official repository type:support and removed type:bug Bug in the code labels Jan 17, 2025
@mihaimaruseac mihaimaruseac added stat:awaiting response Waiting on input from the contributor type:bug Bug in the code and removed type:support labels Jan 17, 2025
Copy link

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

@github-actions github-actions bot added the stale label Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
models:official models that come under official repository stale stat:awaiting response Waiting on input from the contributor type:bug Bug in the code
Projects
None yet
Development

No branches or pull requests

5 participants