Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
TensorFlow:将批处理功能读取到阵列_Tensorflow - Fatal编程技术网

TensorFlow:将批处理功能读取到阵列

TensorFlow:将批处理功能读取到阵列,tensorflow,Tensorflow,我正在使用tf.contrib.learn.ReadBatchFeatures()读取示例protos作为输入函数的一部分,该函数返回张量对象的dict。在训练我的模型之后,在我的估计器上调用predict,将返回一批作为数组的预测,我想将其与已知值进行比较 我试图通过调用tf.Session().run(labels)来获取已知值,其中labels是从输入函数返回的已知值的张量。但是,此时,我的程序挂起。我怀疑它陷入了从磁盘读取标签的无限循环中,而不是像我所希望的那样只读取一批 这是获得标签中

我正在使用
tf.contrib.learn.ReadBatchFeatures
()读取
示例
protos作为输入函数的一部分,该函数返回
张量
对象的dict。在训练我的模型之后,在我的
估计器上调用
predict
,将返回一批作为数组的预测,我想将其与已知值进行比较

我试图通过调用
tf.Session().run(labels)
来获取已知值,其中
labels
是从输入函数返回的已知值的
张量。但是,此时,我的程序挂起。我怀疑它陷入了从磁盘读取标签的无限循环中,而不是像我所希望的那样只读取一批

这是获得
标签中一批值的正确方法吗

编辑:我已尝试启动队列运行程序,以下操作是否正确

_, labels = eval_input_fn()
with tf.Session().as_default():
  tf.local_variables_initializer()
  tf.train.start_queue_runners()
  label_values = labels.eval()
print(label_values)

您需要的整个设置是:

_, labels = eval_input_fn()

with tf.Session() as sess:
        sess.run([
            tf.local_variables_initializer(),
            tf.global_variables_initializer()
        ])

        coord = tf.train.Coordinator()
        threads = tf.train.start_queue_runners(sess=sess, coord=coord)

        try:
            while not coord.should_stop():
                print(sess.run(label))

        except tf.errors.OutOfRangeError as error:
            coord.request_stop(error)
        finally:
            coord.request_stop()
            coord.join(threads)

您需要的整个设置是:

_, labels = eval_input_fn()

with tf.Session() as sess:
        sess.run([
            tf.local_variables_initializer(),
            tf.global_variables_initializer()
        ])

        coord = tf.train.Coordinator()
        threads = tf.train.start_queue_runners(sess=sess, coord=coord)

        try:
            while not coord.should_stop():
                print(sess.run(label))

        except tf.errors.OutOfRangeError as error:
            coord.request_stop(error)
        finally:
            coord.request_stop()
            coord.join(threads)

也许您没有启动队列运行程序,而您的队列是空的?从空队列读取谢谢,我现在记得文档中提到了这一点,但我忘记了。我的会话仍然挂起,您能告诉我出了什么问题吗?添加超时以查看挂起的操作,类似于
config=tf.ConfigProto();配置操作超时时间(单位:毫秒)=60000;sess=tf.InteractiveSession(config=config)
也许您没有启动队列运行程序,而您的队列是空的?从空队列读取谢谢,我现在记得文档中提到了这一点,但我忘记了。我的会话仍然挂起,您能告诉我出了什么问题吗?添加超时以查看挂起的操作,类似于
config=tf.ConfigProto();配置操作超时时间(单位:毫秒)=60000;sess=tf.InteractiveSession(config=config)