Data input and output

Data input

Fluid supports two methods for data input, including:

1. Python Reader: A pure Python Reader. The user defines the layer on the Python side and builds the network. Then, read the data by calling . 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.

Data output

Fluid supports obtaining data for the current batch in the training/inference phase.

The user can fetch expected variables from[...], return_numpy=...) . User can determine whether to convert the output data to numpy array by setting the return_numpy parameter. If return_numpy is False , data of type LoDTensor will be returned.

For specific usage, please refer to the relevant API documentation Executor and ParallelExecutor.