# biome.text.modules.heads.classification.classification Module

# ClassificationHead Class


class ClassificationHead (
    backbone: ModelBackbone,
    labels: List[str],
    multilabel: bool = False,
)

Base abstract class for classification problems

Initializes internal Module state, shared by both nn.Module and ScriptModule.

# Ancestors

  • TaskHead
  • torch.nn.modules.module.Module
  • allennlp.common.registrable.Registrable
  • allennlp.common.from_params.FromParams

# Subclasses

# add_label Method


def add_label (
  self,
  instance: allennlp.data.instance.Instance,
  label: Union[List[str], List[int], str, int],
  to_field: str = 'label',
)  -> Union[allennlp.data.instance.Instance, NoneType]

Includes the label field for classification into the instance data

# decode Method


def decode (
  self,
  output: TaskOutput,
)  -> TaskOutput

Completes the output for the prediction

Mainly adds probabilities and keys for the UI.

Parameters

output
The output from the head's forward method

Returns

completed_output
 

# get_metrics Method


def get_metrics (
  self,
  reset: bool = False,
)  -> Dict[str, float]

Get the metrics of our classifier, see :func:~allennlp_2.models.Model.get_metrics.

Parameters

reset
Reset the metrics after obtaining them?

Returns

A dictionary with all metric names and values.

# single_label_output Method


def single_label_output (
  self,
  logits: torch.Tensor,
  label: Union[torch.IntTensor, NoneType] = None,
)  -> TaskOutput

# multi_label_output Method


def multi_label_output (
  self,
  logits: torch.Tensor,
  label: Union[torch.IntTensor, NoneType] = None,
)  -> TaskOutput

# Inherited members

Maintained by