Data input and output¶
Fluid supports two methods for data input, including:
1. Python Reader: A pure Python Reader. The user defines the
fluid.layers.data layer on the Python side and builds the network.
Then, read the data by calling
executor.run(feed=...) . The process of data reading and model training/inference is performed simultaneously.
2. PyReader: An Efficient and flexible C++ Reader interface. PyReader internally maintains a queue with size of
capacity (queue capacity is determined by
capacity parameter in the
fluid.layers.py_reader interface ). Python side call queue
push to feed the training/inference data, and the C++ side training/inference program calls the
pop method to retrieve the data sent by the Python side. PyReader can work in conjunction with
double_buffer to realize asynchronous execution of data reading and model training/inference.
For details, please refer to py_reader.
Fluid supports obtaining data for the current batch in the training/inference phase.
The user can fetch expected variables from
executor.run(fetch_list=[...], return_numpy=...) . User can determine whether to convert the output data to numpy array by setting the
False , data of type
LoDTensor will be returned.