map_readers

paddle.fluid.io.map_readers(func, *readers)[source]

Creates a data reader that outputs return value of function using output of each data reader as arguments.

If input readers output the following data entries: 2 3, and the input func is mul(x, y), the output of the resulted reader will be 6.

Parameters
  • func – a function to read data and compute result, the output of this function will be set as the output of the resulted data reader.

  • readers (Reader|list of Reader) – list of readers whose outputs will be used as arguments of func.

Returns

the resulted data reader (Reader)

Examples

import paddle.reader
d = {"h": 0, "i": 1}
def func(x):
    return d[x]
def reader():
    yield "h"
    yield "i"
map_reader_result = paddle.reader.map_readers(func, reader)