class chainer.iterators.ShuffleOrderSampler(random_state=None)[source]

Sampler that generates random orders.

This is expected to be used together with Chainer’s iterators. An order sampler is called by an iterator every epoch.

The two initializations below create basically the same objects.

>>> dataset = [(1, 2), (3, 4)]
>>> it = chainer.iterators.MultiprocessIterator(dataset, 1, shuffle=True)
>>> it = chainer.iterators.MultiprocessIterator(
...     dataset, 1, order_sampler=chainer.iterators.ShuffleOrderSampler())

random_state (numpy.random.RandomState) – Pseudo-random number generator.


__call__(current_order, current_position)[source]

Sample the next order.

  • current_order (numpy.ndarray) – 1-D array of indices. The length should be the same as the dataset to sample data from.

  • current_position (int) – The current position of an iterator.


1-D array of indices. This is the order in which examples are sampled from a dataset in the next epoch.

Return type



Return self==value.


Return self!=value.


Return self<value.


Return self<=value.


Return self>value.


Return self>=value.