错误:AttributeError: module 'tensorflow' has no attribute 'placeholder'
错误信息:
AttributeError: module 'tensorflow' has no attribute 'placeholder'
错误原因:
TensorFlow 2中使用TensorFlow 1中的API
解决方法:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
替换
import tensorflow as tf
本文详细介绍了在TensorFlow2环境中遇到使用TensorFlow1 API时出现的AttributeError错误,具体错误为模块'tensorflow'没有属性'placeholder'。文章提供了有效的解决方法,通过导入tensorflow.compat.v1并禁用v2行为来兼容TF1的API。
2万+

被折叠的 条评论
为什么被折叠?



