PyCharm cannot import tensorflow.keras
You can try using thiese two statements in the exact order:
import tensorflow as tf
tf.compat.v1.disable_eager_execution() # This turns off eager execution in TensorFlow
import keras
from keras import Sequential
from keras import Dense
请先登录再写评论。
Hello,
There are 2 related bug reports:
https://youtrack.jetbrains.com/issue/PY-53599/tensorflow.keras-subpackages-are-unresolved-in-Tensorflow-2.6.0 (in progress)
https://youtrack.jetbrains.com/issue/PY-50318/No-Code-tips-for-tensorflow.keras-2.6.0-and-keras
Please vote for them in order to increase its priority and be notified about any updates.