Skip to content
data

SequenceClassificationOutput

extendsModelOutput
SequenceClassificationOutput(logits: Tensor, loss: Tensor | None = None, hidden_states: tuple[Tensor, ...] | None = None, attentions: tuple[Tensor, ...] | None = None)

Output of any whole-sequence classification head.

Attributes

logitsTensor
Per-sequence class logits, shape (B, num_labels). A num_labels of 1 marks a regression head, whose loss is MSE rather than cross-entropy.
loss(Tensor or None, optional)
Scalar loss when labels were supplied.
hidden_states(tuple[Tensor, ...] or None, optional)
Per-layer hidden states.
attentions(tuple[Tensor, ...] or None, optional)
Per-layer attention weights.

Notes

Returned by every {Family}ForSequenceClassification head. It exists so a caller can tell a (B, num_labels) sentence logit apart from a (B, T, vocab_size) masked-LM logit by type rather than by inspecting shapes.

Examples

>>> import lucid
>>> from lucid.models import SequenceClassificationOutput
>>> out = SequenceClassificationOutput(logits=lucid.zeros(1, 2))
>>> out.logits.shape              # (B, num_labels)
(1, 2)

Used by 6