Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.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 Tensorflow:如何读取记录直到文件结束_Python_Tensorflow - Fatal编程技术网

Python Tensorflow:如何读取记录直到文件结束

Python Tensorflow:如何读取记录直到文件结束,python,tensorflow,Python,Tensorflow,我有一个用于训练RNN的数据集,其中样本序列包含在单个文件中 timeSeries1.bin timeSeries2.bin 在每个timeseries.bin中都有不同数量的样本。当文件名存在于tf.train.string\u input\u producer中时,如何从一个timeseries加载所有样本?我需要能够丢弃序列之间的RNN状态,这意味着我需要知道序列何时结束 这是我的输入管道函数: def input_pipeline(instructions, base_director

我有一个用于训练RNN的数据集,其中样本序列包含在单个文件中

timeSeries1.bin
timeSeries2.bin
在每个timeseries.bin中都有不同数量的样本。当文件名存在于tf.train.string\u input\u producer中时,如何从一个timeseries加载所有样本?我需要能够丢弃序列之间的RNN状态,这意味着我需要知道序列何时结束

这是我的输入管道函数:

def input_pipeline(instructions, base_directory):

    files = [f for f in os.listdir(base_directory) if f.endswith('.bin')]

    filename_list = [os.path.join(base_directory, x) for x in files]
    filename_queue = tf.train.string_input_producer(
        filename_list, shuffle=True, capacity=100)
    example, label, feature_name_list = read_binary_format(filename_queue, instructions)

    num_preprocess_threads = 16
    capacity = 20

    example, label = tf.train.batch(
        [example, label],
        batch_size=700,
        capacity=capacity,
        num_threads=num_preprocess_threads)

    return example, label

我知道我需要根据文件名队列中当前文件的大小来更改批大小,但我不知道如何执行此操作。

文件之间更改的是批大小还是序列长度?读取二进制格式返回什么?您的问题的解决方案可能涉及用零填充序列,但考虑到是批大小还是序列长度在文件之间发生了变化?读取二进制格式返回什么?不过,问题的解决方案可能涉及用零填充序列