目录 一、AttributeError: module ‘tensorflow‘ has no attribute ‘app‘ 二、AttributeError: module 'tensorflow' has no attribute 'placeholder' 三、AttributeError: module 'tensorflow' has no attribute 'variable_scope' 四、AttributeError: module 'tensorflow' has no attribute 'AUTO_REUSE' 一、AttributeError: module ‘tensorflow‘ has no attribute ‘app‘报错:AttributeError: module ‘tensorflow‘ has no attribute ‘app‘ 原因:在我的code中是由该命令 解决方法:由于tensorflow版本的原因,我的tensorflow的版本是2.10.0的,而源代码是tensorflow1.几版本的,所以只需要将源文件里面的import tensorflow as tf改为 import tensorflow.compat.v1 as tf
改了之后, 代码下方会出现黄色波浪线,但是没有报错了,代码可以正常运行。 二、AttributeError: module 'tensorflow' has no attribute 'placeholder'原因:表明你正在尝试访问TensorFlow模块中不存在的 解决方法: (1)使用TensorFlow 1.x的兼容性模式:如果你依赖于使用
(2)重写代码以使用TensorFlow 2.x的API:推荐的方法是更新你的代码以使用TensorFlow 2.x的原生API。在TensorFlow 2.x中,你不再需要 例如,如果你之前使用
三、AttributeError: module 'tensorflow' has no attribute 'variable_scope'原因:这个错误表明你正在尝试访问TensorFlow模块中不存在的 解决方法: (1)使用TensorFlow 1.x的兼容性模式: 如果你需要运行依赖于
此处我尝试了第一种方法,但是没有成功。因此,只能重新安装TensorFlow 1.x的版本,但是由于我的python环境是3.9不能安装TensorFlow 1.x的版本,所以没办法只能使用python3.6版本进行安装。 安装TensorFlow 1.x的版本之后,就可以成功运行了。 (2)重写代码以使用TensorFlow 2.x的API: 推荐的方法是更新你的代码以使用TensorFlow 2.x的API。在TensorFlow 2.x中,变量管理更加简单和直接。你可以使用
四、AttributeError: module 'tensorflow' has no attribute 'AUTO_REUSE'原因:通常是因为尝试访问 TensorFlow 模块中不存在的属性 在 TensorFlow 1.x 中, 解决方法: (1)使用
此处我尝试了第一种方法,但是没有成功。因此,只能重新安装TensorFlow 1.x的版本,但是由于我的python环境是3.9不能安装TensorFlow 1.x的版本,所以没办法只能使用python3.6版本进行安装。 安装TensorFlow 1.x的版本之后,就可以成功运行了。 (2)完全重写变量管理逻辑:如果你正在编写新代码或更新旧代码,考虑完全重写变量管理逻辑,使用 TensorFlow 2.x 的原生方式来创建和管理变量,例如使用 |
原文地址:https://blog.csdn.net/qq_45956730/article/details/135389003
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:https://www.msipo.com/article-653278.html 如若内容造成侵权/违法违规/事实不符,请联系MSIPO邮箱:3448751423@qq.com进行投诉反馈,一经查实,立即删除!
Copyright © 2024, msipo.com