tensorflow 2.4中用哪个命令tf.placeholder替换?
我正在使用tensorflow 2.4.1和tensorflow 1中的代码。每当我运行下面的命令时,我都会得到一个错误tensorflow 2.4中用哪个命令tf.placeholder替换?,tensorflow,attributeerror,tensorflow2,Tensorflow,Attributeerror,Tensorflow2,我正在使用tensorflow 2.4.1和tensorflow 1中的代码。每当我运行下面的命令时,我都会得到一个错误 inputs = tf.placeholder(tf.int32, [None, None], name = 'input') 错误 AttributeError回溯(最近一次调用) 在() ---->1输入=tf.placeholder(tf.int32,[None,None],name='input') AttributeError:模块“tensorflow”没有属性
inputs = tf.placeholder(tf.int32, [None, None], name = 'input')
错误
AttributeError回溯(最近一次调用)
在()
---->1输入=tf.placeholder(tf.int32,[None,None],name='input')
AttributeError:模块“tensorflow”没有属性“占位符”
我尝试了tf.compat.v1.placeholder(),但出现了一个运行时错误。回答如下:为了在Tensorflow 2中使用tf.placeholder
,请按照import Tensorflow.compat.v1 as tf
这样的代码,然后执行tf.placeholder(tf.int32,[None],name='input')
。
AttributeError Traceback (most recent call last)
<ipython-input-14-c2404ca8696c> in <module>()
----> 1 inputs = tf.placeholder(tf.int32, [None, None], name = 'input')
AttributeError: module 'tensorflow' has no attribute 'placeholder'