utterance_classification_task#

(s3prl.task.utterance_classification_task)

Utterance Classification Tasks

Authors
  • Leo 2022

UtteranceClassifierExample#

class s3prl.task.utterance_classification_task.UtteranceClassifierExample(input_size=3, output_size=4)[source][source]#

Bases: Module

input_size[source]#

int

output_size[source]#

int

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

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

Returns:

(batch_size, output_size)

Return type:

output (torch.Tensor)

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

UtteranceClassificationTask#

class s3prl.task.utterance_classification_task.UtteranceClassificationTask(model: UtteranceClassifierExample, category: CategoryEncoder)[source][source]#

Bases: Task

input_size[source]#

defined by model.input_size

Type:

int

output_size[source]#

defined by len(categories)

Type:

int

predict(x: Tensor, x_len: LongTensor)[source][source]#
Parameters:
  • x (torch.Tensor) – (batch_size, timestamps, input_size)

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

Returns:

(batch_size, output_size) prediction (list): prediction strings

Return type:

logits (torch.Tensor)

forward(_mode: str, x: Tensor, x_len: LongTensor, class_id: LongTensor, label: List[str], unique_name: List[str], _dump_dir: Optional[str] = None)[source][source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

reduction(_mode: str, cached_results: List[dict], _dump_dir: Optional[str] = None)[source][source]#
call_super_init: bool = False[source]#
dump_patches: bool = False[source]#
get_state()[source]#
parse_cached_results(cached_results: List[dict])[source]#
set_state(state: dict)[source]#
abstract test_reduction()[source]#
abstract test_step()[source]#
abstract train_reduction()[source]#
abstract train_step()[source]#
abstract valid_reduction()[source]#
abstract valid_step()[source]#
training: bool[source]#