When you have this problem, it indicates that TF1 API is used under TF2
1. See if the version number is used incorrectly
In pychar, find the project, and then output the following command to see the version
import tensorflow as tf #Load the tensorflow environment
print(tf.__version__) #View tensorflow version
If it is shown in the figure below, you are using TF2
2. Put the code into the following code in TF environment
import tensorflow as tf
Replace with the following code
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
Run the program. The procedure is correct
Similar Posts:
- Tensorflow reported an error when using session module: attributeerror: module ‘tensorflow’ has no attribute ‘session’, which has been solved
- AttributeError: module ‘tensorflow_core._api.v2.nn’ has no attribute ‘rnn_cell’ tensorflow Version compatibility issues-solution
- Error reporting of importing tensorflow package from pycharm
- Error in importing tensorflow in Jupiter Notebook: no module named tensorflow solution
- AttributeError: module ‘tensorflow’ has no attribute ‘Session’
- [Solved] Python TensorFlow Error: ‘tensorflow.compat.v2.__internal__’ has no attribute ‘tf2’
- How to Solve Error: Failed to load the native TensorFlow runtime.
- ModuleNotFoundError: No module named ‘PyQt4’ [Spyder Import matplotlib Error]
- “Failed to get convolution algorithm. This is probably because cuDNN failed to initialize”
- ImportError: cannot import name’e.g. utils’from’tensorflow.as.utils’ 38382;’ 39064;