specaug#

(s3prl.nn.specaug)

Specaug modules

Authors:
  • Xuankai Chang 2021

  • ShampooWang, cornliu 2021

  • Leo 2022

ModelWithSpecaug#

class s3prl.nn.specaug.ModelWithSpecaug(model: Module, **specaug_conf)[source][source]#

Bases: Module

Insert a Specaug module in front of the input model

Parameters:
  • model (torch.nn.Module) –

  • specaug_conf (dict) – the arguments for SpecAug

property input_size: int[source]#
property output_size: int[source]#
forward(x, x_len, **others)[source][source]#

The input x will be augmented with Specaug and feed into the following model

Parameters:
  • x (torch.FloatTensor) – (batch_size, seq_len, input_size)

  • x_len (torch.LongTensor) – (batch_size)

Returns:

The exact returns as that of the model during initialization

call_super_init: bool = False[source]#
dump_patches: bool = False[source]#
training: bool[source]#

SpecAug#

class s3prl.nn.specaug.SpecAug(apply_time_warp: bool = True, time_warp_window: int = 5, time_warp_mode: str = 'bicubic', apply_freq_mask: bool = True, freq_mask_width_range: tuple = (0, 20), num_freq_mask: int = 2, apply_time_mask: bool = True, time_mask_width_range: tuple = (0, 100), num_time_mask: int = 2, adaptive_number_ratio: float = 0.04, adaptive_size_ratio: float = 0.04, max_n_time_masks: int = 20, adaptive: bool = False)[source][source]#

Bases: Module

apply_specaug(x, x_lengths=None)[source][source]#
forward(x, x_len)[source][source]#
Parameters:
  • x (torch.FloatTensor) – (batch_size, seq_len, input_size)

  • x_len (torch.LongTensor) – (batch_size, )

Returns:

  1. y (torch.FloatTensor): (batch_size, seq_len, output_size)

  2. y_len (torch.LongTensor): (batch_size, )

Return type:

tuple

call_super_init: bool = False[source]#
dump_patches: bool = False[source]#
training: bool[source]#