compose*readers, **kwargs)[source]

Creates a data reader whose output is the combination of input readers.

If input readers output following data entries: (1, 2) 3 (4, 5) The composed reader will output: (1, 2, 3, 4, 5)

  • readers (Reader|list of Reader) – readers that will be composed together.

  • check_alignment (bool, optional) – Indicates whether the input readers are checked for alignment. If True, whether input readers are aligned correctly will be checked, else alignment will not be checkout and trailing outputs will be discarded. Defaults to True.


the new data reader (Reader).


ComposeNotAligned – outputs of readers are not aligned. This will not raise if check_alignment is set to False.


import paddle.fluid as fluid
def reader_creator_10(dur):
    def reader():
       for i in range(10):
           yield i
    return reader
reader =, reader_creator_10(0))