使用feed_dict时参数关联错误

时间:2018-12-10 18:34:21

标签: python tensorflow

我一直不断收到此错误,无法弄清原因

InvalidArgumentError:您必须为dtype int32和形状[10,1]的占位符张量“ Placeholder_7”提供一个值

def return_array(tensor_obj):
    with tf.Session() as ses:
       coord = tf.train.Coordinator()
       threads = tf.train.start_queue_runners(coord=coord)
       array = ses.run(tensor_obj) 
       coord.request_stop()
       coord.join(threads)  
    return tf.constant(array)

param = tf.constant([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])
tensor_ob = tf.placeholder(tf.int32, shape = (10, 1))
parameter = return_array(tensor_ob)
init = tf.global_variables_initializer()
with tf.Session() as sess:
    coord = tf.train.Coordinator()
    threads = tf.train.start_queue_runners(coord=coord)
    sess.run(init)
    print(sess.run(parameter, feed_dict={tensor_ob : param}))
    coord.request_stop()
    coord.join(threads)

0 个答案:

没有答案