AttributeError: module 'tensorflow' has no attribute 'Session '
时间: 2023-09-06 16:11:47 浏览: 175
当出现"AttributeError: module 'tensorflow' has no attribute 'Session'"的错误时,通常是因为使用了错误的`tensorflow`版本。在新版的`tensorflow`中,`Session`被移除并且不再被支持。相反,使用`tf.compat.v1.Session()`来创建会话对象。所以,解决这个问题的方法是将代码中的`tf.Session()`替换为`tf.compat.v1.Session()`。引用<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Tensorflow 2.0 - AttributeError: module ‘tensorflow‘ has no attribute ‘Session](https://blog.csdn.net/YINTENAXIONGNAIER/article/details/125660868)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [AttributeError: module 'tensorflow.compat.v1' has no attribute '](https://download.csdn.net/download/qq_38766019/86272235)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [AttributeError: module ‘tensorflow‘ has no attribute ‘Session](https://blog.csdn.net/qq_42095950/article/details/130015868)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文