0
点赞
收藏
分享

微信扫一扫

TensorFlow 复制placeholder


用这种方式复制placeholder:

= tf.placeholder(tf.int32, 
[batch_size, sequence_len],
name="input")

copy_input = tf.Variable(initial_value=input_placeholder,
trainable=False)

然后这句报错:you must feed a value for placeholder tensor

sess.run(tf.global_variables_initializer())

解决方案:
用这种方式复制placeholder:

copy_input = tf.get_variable(
initializer=tf.constant(0, shape=[batch_size, sequence_len]),
name="copy_placeholder",
dtype=tf.int32, trainable=False)
copy_input.assign(input_placeholder)


举报

相关推荐

0 条评论