mxnet.gluon.data.DataLoader / RandomSampler shuffle


#1

Dear all,

in the documentation of mxnet.gluon.data.DataLoader one of the options of this object is shuffle = True my question: does shuffling happen every time a new epoch starts automatically, or do I need to declare the object again to get a clean new shuffled order of input, labels?

Thank you very much in advance.


#2

Hey @feevos,

It is shuffled every time you reach the end of your iterator.
See this simple test:

dataset = gluon.data.ArrayDataset(np.arange(5))
dataloader = gluon.data.DataLoader(dataset, batch_size=1, shuffle=True)

for data in dataloader:
    print(data.asscalar())
4
2
0
3
1

for data in dataloader:
    print(data.asscalar())
3
2
1
4
0

#3

Thank you very much @ThomasDelteil, extremely appreciated.