【发布时间】:2020-07-10 21:36:10
【问题描述】:
我正在尝试运行以下代码:
input_img = Input((height, width, 1), name='img')
model = get_unet(input_img, n_filters=16, dropout=0.05, batchnorm=True)
model.compile(optimizer=Adam(), loss="binary_crossentropy", metrics=["accuracy"])
但我收到“AttributeError: module 'tensorflow' has no attribute 'placeholder'”。 任何地方都推荐使用
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
但我仍然不断收到这样的错误。
【问题讨论】:
-
你在使用 Anaconda 发行版
-
是的,对于 Python 3.7
-
那么问题可能是 conda 分布。尝试重新安装tenserflow
-
首先使用“conda remove tensorflow-gpu tensorflow tensorflow-base”卸载tensorflow
-
然后在 Anaconda Prompt (Anaconda3) 中使用“conda install -c anaconda tensorflow”进行安装
标签: python-3.x tensorflow neural-network