Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.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
如何调试冻结在一行上的Python程序?_Python_Tensorflow - Fatal编程技术网

如何调试冻结在一行上的Python程序?

如何调试冻结在一行上的Python程序?,python,tensorflow,Python,Tensorflow,当我运行代码时,它只停留在行image\u batch,label\u batch=sess.run([test\u images,test\u labels])中,没有任何错误提示。它只是呆在这里,不能移动 这是我的密码: # coding=utf-8 from color_1 import read_and_decode, get_batch, get_test_batch import color_inference import cv2 import os import time im

当我运行代码时,它只停留在行
image\u batch,label\u batch=sess.run([test\u images,test\u labels])
中,没有任何错误提示。它只是呆在这里,不能移动

这是我的密码:

# coding=utf-8
from  color_1 import read_and_decode, get_batch, get_test_batch
import color_inference
import cv2
import os
import time
import numpy as np
import tensorflow as tf
import color_train
import math

batch_size=128
num_examples = 10000
crop_size=56

def evaluate():
    image_holder = tf.placeholder(tf.float32, [batch_size, 56, 56, 3], name='x-input')
    label_holder = tf.placeholder(tf.int32, [batch_size], name='y-input')

    test_image, test_label = read_and_decode('val.tfrecords')
    test_images, test_labels = get_test_batch(test_image, test_label, batch_size, crop_size)
    y=color_inference.inference(image_holder)

    num_iter = int(math.ceil(num_examples / batch_size))
    true_count = 0
    total_sample_count = num_iter * batch_size

    top_k_op = tf.nn.in_top_k(y, label_holder, 1)
    saver = tf.train.Saver()
    with tf.Session() as sess:

        ckpt=tf.train.get_checkpoint_state(color_train.MODEL_SAVE_PATH)
        if ckpt and ckpt.model_checkpoint_path:
            ckpt_name = os.path.basename(ckpt.model_checkpoint_path)
            global_step = ckpt.model_checkpoint_path.split('/')[-1].split('-')[-1]
            saver.restore(sess, os.path.join(color_train.MODEL_SAVE_PATH, ckpt_name))
            print('Loading success, global_step is %s' % global_step)

            image_batch, label_batch = sess.run([test_images, test_labels])
            predictions = sess.run([top_k_op], feed_dict={image_holder: image_batch,
                                                          label_holder: label_batch})
            true_count += np.sum(predictions)
            print("Count is:%g" % true_count)
            precision = true_count * 1.0 / total_sample_count
            print("After %s training step,the prediction is :%g",global_step,precision)
        else:
            print('No checkpoint file found')
            return

def main(argv=None):
    evaluate()

if __name__=='__main__':
    tf.app.run()

我的最后一个问题与此类似,但代码与此略有不同,也许您可以在最后一个问题中得到一些信息。

似乎您没有正确启动队列运行程序/初始化变量。当我忘了这么做时,我在我的模特身上也看到过类似的行为。 在这种情况下,你很可能会被困在生产线上

image_batch, label_batch = sess.run([test_images, test_labels])
因为从TFR记录中提取数据的线程尚未启动

在初始化会话之前,请设置一个用于初始化变量的op和线程协调器:

init_op = tf.group(tf.global_variables_initializer(), tf.local_variables_initializer())
coord = tf.train.Coordinator()
然后在会话开始时,在从TFR记录中提取任何数据之前,运行op并启动队列运行程序:

sess.run(init_op)
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
# main loop goes here, like training and evaluating

似乎您没有正确启动队列运行程序/初始化变量。当我忘了这么做时,我在我的模特身上也看到过类似的行为。 在这种情况下,你很可能会被困在生产线上

image_batch, label_batch = sess.run([test_images, test_labels])
因为从TFR记录中提取数据的线程尚未启动

在初始化会话之前,请设置一个用于初始化变量的op和线程协调器:

init_op = tf.group(tf.global_variables_initializer(), tf.local_variables_initializer())
coord = tf.train.Coordinator()
然后在会话开始时,在从TFR记录中提取任何数据之前,运行op并启动队列运行程序:

sess.run(init_op)
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
# main loop goes here, like training and evaluating

非常感谢你。你能帮我回答另一个问题吗?问题名称是“Fetch参数不能解释为张量”。在我的另一个问题中。我需要你的帮助!非常感谢,非常感谢。你能帮我回答另一个问题吗?问题名称是“Fetch参数不能解释为张量”。在我的另一个问题中。我需要你的帮助!非常感谢你