module 'tensorflow' has no attribute 'Session'. Did you mean: 'version'?
时间: 2023-10-10 22:15:19 浏览: 153
This error message is indicating that you are trying to use the `Session` attribute in TensorFlow, but it is not available in the version you are using. Starting from TensorFlow 2.0, the eager execution mode is enabled by default, which means that you don't need to use sessions explicitly anymore.
If you are following an old tutorial or code example that uses sessions, you can try to modify it to work with TensorFlow 2.0+ by removing the session-related code and using the eager execution mode instead.
If you still need to use sessions in your code, you can try to downgrade your TensorFlow version to a version that supports sessions, such as TensorFlow 1.x. However, it is recommended to migrate your code to use the new TensorFlow API instead of relying on sessions.
阅读全文