scores.EnergyScore

Energy-based confidence score.

Usage

Source

scores.EnergyScore()

Computes the free energy of the logit distribution. Lower energy (more negative) indicates higher confidence. Supports multiclass, binary, and multilabel tasks.

Parameters

temperature: float or None = None

Optional initial temperature. If None, temperature is fitted if labels are provided to fit.

task: ("multiclass", "binary", "multilabel") = "multiclass"
Task type for score computation.

Examples

import torch
from seapig.scores.logits import EnergyScore
logits = torch.randn(2, 3)
EnergyScore().score(logits)

Attributes

Name Description
ident str(object=’’) -> str

ident

str(object=’’) -> str

ident: str = "energy"

str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

Methods

Name Description
score() Compute energy for query logits (task-aware).

score()

Compute energy for query logits (task-aware).

Usage

Source

score(query_logits)

Returns a 1-D tensor of shape (M,) where lower values are more confident.

See Also