Tensorflow挂起sess.运行()被调用

2024-10-01 11:20:04 发布

您现在位置:Python中文网/ 问答频道 /正文

下面的代码将挂起(只有aCTRLz才能让我退出)。在

import tensorflow as tf
import cifar10 # from https://github.com/tensorflow/models/tree/master/tutorials/image/cifar10 (both cifar10.py & cifar10_input.py)

def main():
    print 'TensorFlow version: ',tf.__version__

    with tf.Session() as sess:

    with tf.device('/cpu:0'):
        images, labels = cifar10.distorted_inputs()

    input = tf.constant([[[1, 2, 3], [5, 5, 5]], [[4, 5, 6], [7, 7, 7]], [[7, 8, 9], [9, 9, 9]]])

    one=input[0]
    print "X1 ",type(input), one
    oneval = sess.run(one)
    print "X2 ",type(one), one, type(oneval), oneval

    two=images[0]
    print "Y1 ",type(images), two
    twoval = sess.run(two)
    print "Y2 ",type(two), two, type(twoval), twoval

main()

我得到以下输出(使用python2.7.5):

^{pr2}$

有谁有什么建议(或解决办法)?在

如果有人对背景感兴趣,我的最终目标是将distorted_inputs()返回的张量转换为一组JSON对象。因此,最简单的计划是遍历图像的每个元素并提取值。在


Tags: pyimportinputtftensorflowastypeone
2条回答

我在tf1.7中遇到了这个问题,降级到了1.3,它工作得很好。在

{我在这里找到了答案

关键是这两条线:

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

相关问题 更多 >