espnet2.samplers package

espnet2.samplers.unsorted_batch_sampler

class espnet2.samplers.unsorted_batch_sampler.UnsortedBatchSampler(batch_size: int, key_file: str, drop_last: bool = False, utt2category_file: str = None)[source]

Bases: espnet2.samplers.abs_sampler.AbsSampler

BatchSampler with constant batch-size.

Any sorting is not done in this class, so no length information is required, This class is convenient for decoding mode, or not seq2seq learning e.g. classification.

Parameters:
  • batch_size

  • key_file

espnet2.samplers.abs_sampler

class espnet2.samplers.abs_sampler.AbsSampler(data_source: Optional[Sized])[source]

Bases: torch.utils.data.sampler.Sampler, abc.ABC

generate(seed)[source]

espnet2.samplers.num_elements_batch_sampler

class espnet2.samplers.num_elements_batch_sampler.NumElementsBatchSampler(batch_bins: int, shape_files: Union[Tuple[str, ...], List[str]], min_batch_size: int = 1, sort_in_batch: str = 'descending', sort_batch: str = 'ascending', drop_last: bool = False, padding: bool = True)[source]

Bases: espnet2.samplers.abs_sampler.AbsSampler

espnet2.samplers.length_batch_sampler

class espnet2.samplers.length_batch_sampler.LengthBatchSampler(batch_bins: int, shape_files: Union[Tuple[str, ...], List[str]], min_batch_size: int = 1, sort_in_batch: str = 'descending', sort_batch: str = 'ascending', drop_last: bool = False, padding: bool = True)[source]

Bases: espnet2.samplers.abs_sampler.AbsSampler

espnet2.samplers.folded_batch_sampler

class espnet2.samplers.folded_batch_sampler.FoldedBatchSampler(batch_size: int, shape_files: Union[Tuple[str, ...], List[str]], fold_lengths: Sequence[int], min_batch_size: int = 1, sort_in_batch: str = 'descending', sort_batch: str = 'ascending', drop_last: bool = False, utt2category_file: str = None)[source]

Bases: espnet2.samplers.abs_sampler.AbsSampler

espnet2.samplers.__init__

espnet2.samplers.sorted_batch_sampler

class espnet2.samplers.sorted_batch_sampler.SortedBatchSampler(batch_size: int, shape_file: str, sort_in_batch: str = 'descending', sort_batch: str = 'ascending', drop_last: bool = False)[source]

Bases: espnet2.samplers.abs_sampler.AbsSampler

BatchSampler with sorted samples by length.

Parameters:
  • batch_size

  • shape_file

  • sort_in_batch – ‘descending’, ‘ascending’ or None.

  • sort_batch

espnet2.samplers.build_batch_sampler

espnet2.samplers.build_batch_sampler.build_batch_sampler(type: str, batch_size: int, batch_bins: int, shape_files: Union[Tuple[str, ...], List[str]], sort_in_batch: str = 'descending', sort_batch: str = 'ascending', drop_last: bool = False, min_batch_size: int = 1, fold_lengths: Sequence[int] = (), padding: bool = True, utt2category_file: str = None) → espnet2.samplers.abs_sampler.AbsSampler[source]

Helper function to instantiate BatchSampler.

Parameters:
  • type – mini-batch type. “unsorted”, “sorted”, “folded”, “numel”, or, “length”

  • batch_size – The mini-batch size. Used for “unsorted”, “sorted”, “folded” mode

  • batch_bins – Used for “numel” model

  • shape_files – Text files describing the length and dimension of each features. e.g. uttA 1330,80

  • sort_in_batch

  • sort_batch

  • drop_last

  • min_batch_size – Used for “numel” or “folded” mode

  • fold_lengths – Used for “folded” mode

  • padding – Whether sequences are input as a padded tensor or not. used for “numel” mode