为什么我在pycharm中出错而在其他地方却正常

2024-04-20 00:45:41 发布

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

我在jupyter笔记本上运行程序,终端正常,但是用pycharm打开它是不正常的 相同的tensorflow版本和python版本,相同的.py文件 我很困惑 可能是关键代码:

def generate_batch(feats, labels, batch_size, shuffle, min_queue_examples):

    num_preprocess_threads = 2
    if shuffle:
        feat_batch, label_batch = tf.train.shuffle_batch(
            [feats, labels],
            batch_size=batch_size,
            #num_threads=num_preprocess_threads,
            capacity=min_queue_examples + 3*batch_size,
            min_after_dequeue=min_queue_examples,
            allow_smaller_final_batch=True)
    else:
        feat_batch, label_batch = tf.train.batch(
            [feats, labels],
            batch_size=batch_size,
            #num_threads=num_preprocess_threads,
            allow_smaller_final_batch=True,
            capacity=min_queue_examples + 3*batch_size)
    print(label_batch)
    print(feat_batch)
    return feat_batch, tf.reshape(label_batch,[-1])

OutOfRangeError (see above for traceback): FIFOQueue '_1_batch/fifo_queue' is closed and has insufficient elements (requested 50, current size 0) [[Node: batch = QueueDequeueUpToV2[component_types=[DT_FLOAT, DT_INT64], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/device:CPU:0"](batch/fifo_queue, batch/n)]]


Tags: 版本sizelabelsqueuetfbatchminexamples