AttributeError: module 'keras.api._v2.keras.layers' has no attribute 'Pooling2D'
时间: 2023-10-10 08:07:01 浏览: 158
根据引用中的资料,正确的导入方式是从tensorflow中导入keras模块。对于属性'Pooling2D'的错误提示,可能是因为该属性在导入时使用了错误的命名空间。
您可以尝试使用以下导入方式来解决此问题:
```
from tensorflow.keras.layers import MaxPooling2D
```
这样,您就可以正确地使用MaxPooling2D模块了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [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%"]
- *2* [菜尼奥排错之keras ‘tensorflow.compat.v2.__internal__‘ has no attribute ‘register_clear_session_...](https://blog.csdn.net/yueyueniaolzp/article/details/121820916)[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* [module ‘tensorflow.compat.v2.__internal__‘ has no attribute ‘tf2](https://blog.csdn.net/weixin_44731100/article/details/121356206)[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 ]
阅读全文