placeholder是TensorFlow的占位符节点,由placeholder方法创建,其也是一种常量,但是由用户在调用run方法是传递的,也可以将placeholder理解为一种形参。即其不像constant那样直接可以使用,需要用户传递常数值。
输入:
x = tf.placeholder(tf.int32, [batch_size, num_steps], name='input_placeholder')
y = tf.placeholder(tf.int32, [batch_size, num_steps], name='output_placeholder')
结果报错:
AttributeError: module 'tensorflow' has no attribute 'placeholder'
解决方法:
Tensorflow 1.x 版本提供placeholder,而 2.0版本暂时没有这个模块。
因此把Tensorflow 换回 1.x版本即可。