gpt4 book ai didi

python - TensorFlow, "' 模块的对象没有属性 'placeholder' “

转载 作者:IT老高 更新时间:2023-10-28 21:14:46 27 4
gpt4 key购买 nike

我已经尝试使用 tensorflow 两天了,现在在 python2.7 和 3.4 中一遍又一遍地安装和重新安装它。无论我做什么,在尝试使用 tensorflow.placeholder() 时都会收到此错误消息

这是非常样板的代码:

tf_in = tf.placeholder("float", [None, A]) # Features

无论我做什么,我总能得到回溯:

Traceback (most recent call last):
File "/home/willim/PycharmProjects/tensorflow/tensorflow.py", line 2, in <module>
import tensorflow as tf
File "/home/willim/PycharmProjects/tensorflow/tensorflow.py", line 53, in <module>
tf_in = tf.placeholder("float", [None, A]) # Features
AttributeError: 'module' object has no attribute 'placeholder'

有人知道我该如何解决这个问题吗?

最佳答案

如果升级到 TensorFlow 2.0 后出现此错误,您仍然可以通过替换来使用 1.X API:

import tensorflow as tf

通过

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

关于python - TensorFlow, "' 模块的对象没有属性 'placeholder' “,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37383812/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com