espnet2.iterators.sequence_iter_factory.RawSampler
espnet2.iterators.sequence_iter_factory.RawSampler
class espnet2.iterators.sequence_iter_factory.RawSampler(batches)
Bases: AbsSampler
RawSampler is a class that inherits from AbsSampler and provides a mechanism to
sample raw batches of data.
batches
A sequence of batches to be sampled.
Type: Sequence[Sequence[Any]]
Parameters:batches (Sequence *[*Sequence *[*Any ] ]) – A sequence of batches that the sampler will iterate over.
Returns: None
Yields:Sequence[Any] – The next batch of data during iteration.
Raises:None –
####### Examples
>>> sampler = RawSampler([[1, 2], [3, 4], [5, 6]])
>>> len(sampler)
3
>>> list(sampler)
[[1, 2], [3, 4], [5, 6]]
>>> sampler.generate(seed=42)
[[1, 2], [3, 4], [5, 6]]
NOTE
The generate method returns the list of batches without any modifications based on the seed.
generate(seed)
Generate a list of batches based on the provided seed.
This method returns the batches that were initialized in the RawSampler. The seed can be used to ensure that the same batches are produced consistently, allowing for reproducibility in experiments.
- Parameters:seed (int) – The seed used for generating the batches. This seed is added to the base seed to ensure variability in the generated batches across different epochs.
- Returns: A list containing the batches as defined in the : RawSampler.
- Return type: list
####### Examples
>>> sampler = RawSampler([[1, 2], [3, 4], [5, 6]])
>>> batches = sampler.generate(seed=42)
>>> print(batches)
[[1, 2], [3, 4], [5, 6]]