fluid.layers.py_reader可否支持重复创建
Created by: alexqdh
python 2.7 paddle 1.3
每次训练都会重新读取一遍训练,想先把训练数据load到内存,然后每次训练的时候都重新创建一个reader,报了一个错:
EnforceNotMet: LoDTensorBlockingQueueHolder::InitOnce() can only be called once at [/paddle/paddle/fluid/operators/reader/lod_tensor_blocking_queue.h:73]
代码:
def build_input(self, image_shape, is_train):
name = 'train_reader' if is_train else 'test_reader'
py_reader = fluid.layers.py_reader(
capacity=64,
shapes=[[-1] + image_shape, [-1, 1]],
lod_levels=[0, 0],
dtypes=["float32", "int64"],
use_double_buffer=True,
name=name)
return py_reader