paddle.fluid.io.shuffle ( shuffle ) is recommended to use, and paddle.reader.shuffle is an alias.
This API creates a decorated reader that outputs the shuffled data.
The output data from the origin reader will be saved into a buffer, and then shuffle the data. The size of buffer is determined by argument buf_size.
reader (callable) – the original reader whose data will be shuffled.
buf_size (int) – the size of shuffled buffer.
a decorated reader.
- Return type
import paddle.fluid as fluid def reader(): for i in range(5): yield i shuffled_reader = fluid.io.shuffle(reader, 3) for e in shuffled_reader(): print(e) # outputs are 0~4 unordered arrangement