common#

(s3prl.nn.common)

Common probing models

Authors:
  • Leo 2022

FrameLevel#

class s3prl.nn.common.FrameLevel(input_size: int, output_size: int, hidden_sizes: Optional[List[int]] = None, activation_type: Optional[str] = None, activation_conf: Optional[dict] = None)[source][source]#

Bases: Module

The common frame-to-frame probing model

Parameters:
  • input_size (int) – input size

  • output_size (int) – output size

  • hidden_sizes (List[int]) – a list of hidden layers’ hidden size. by default is [256] to project all different input sizes to the same dimension. set empty list to use the vanilla single layer linear model

  • activation_type (str) – the activation class name in torch.nn. Set None to disable activation and the model is pure linear. Default: None

  • activation_conf (dict) – the arguments for initializing the activation class. Default: empty dict

property input_size: int[source]#
property output_size: int[source]#
forward(x, x_len)[source][source]#
Parameters:
  • x (torch.FloatTensor) – (batch_size, seq_len, input_size)

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

Returns:

tuple

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

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

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

UtteranceLevel#

class s3prl.nn.common.UtteranceLevel(input_size: int, output_size: int, hidden_sizes: Optional[List[int]] = None, activation_type: Optional[str] = None, activation_conf: Optional[dict] = None, pooling_type: str = 'MeanPooling', pooling_conf: Optional[dict] = None)[source][source]#

Bases: Module

Parameters:
  • input_size (int) – input_size

  • output_size (int) – output_size

  • hidden_sizes (List[int]) – a list of hidden layers’ hidden size. by default is [256] to project all different input sizes to the same dimension. set empty list to use the vanilla single layer linear model

  • activation_type (str) – the activation class name in torch.nn. Set None to disable activation and the model is pure linear. Default: None

  • activation_conf (dict) – the arguments for initializing the activation class. Default: empty dict

  • pooling_type (str) – the pooling class name in s3prl.nn.pooling. Default: MeanPooling

  • pooling_conf (dict) – the arguments for initializing the pooling class. Default: empty dict

property input_size: int[source]#
property output_size: int[source]#
forward(x, x_len)[source][source]#
Parameters:
  • x (torch.FloatTensor) – (batch_size, seq_len, input_size)

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

Returns:

torch.FloatTensor

(batch_size, output_size)

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