AttributeError: module ‘tensorflow’ has no attribute 'placeholder’
import tensorflow as tf
# weixin mitbaiyun
import numpy as np
import matplotlib.pyplot as plt
import tensorflow._api.v2.compat.v1 as tf
tf.disable_v2_behavior()
# weixin mitbaiyun
import numpy as np
import matplotlib.pyplot as plt
效果图

本文详细介绍了如何解决在使用TensorFlow时遇到的AttributeError:'module 'tensorflow' has no attribute 'placeholder''错误。通过更新导入方式,禁用v2行为,使代码与不同版本的TensorFlow兼容。
2万+

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



