seqme.metrics.KID

seqme.metrics.KID#

class seqme.metrics.KID(reference, embedder, *, estimate='biased', degree=3, coef0=1.0, device='cpu', name='KID')[source]#

Kernel Inception Distance (KID). Maximum Mean Discrepancy (MMD) metric using a polynomial kernel.

Reference:

Binkowski et al. “Demystifying MMD GANS” (https://arxiv.org/abs/1801.01401)

__init__(reference, embedder, *, estimate='biased', degree=3, coef0=1.0, device='cpu', name='KID')[source]#

Initialize the metric.

Parameters:
  • reference (list[str]) – List of reference sequences representing real data.

  • embedder (Callable[[list[str]], ndarray]) – Function that maps a list of sequences to their embeddings. Should return a 2D array of shape (num_sequences, embedding_dim).

  • estimate (Literal['biased', 'unbiased']) – Expectation estimate.

  • degree (int) – Polynomial kernel degree.

  • coef0 (float) – Coefficient.

  • device (str) – Compute device, e.g., "cpu" or "cuda".

  • name (str) – Metric name.

__call__(sequences)[source]#

Compute the KID between embeddings of the input sequences and the reference.

Parameters:

sequences (list[str]) – Sequences to evaluate.

Returns:

KID score.

Return type:

MetricResult

Methods

__init__(reference, embedder, *[, estimate, ...])

Initialize the metric.

__call__(sequences)

Compute the KID between embeddings of the input sequences and the reference.

Attributes

name

Name of the metric.

objective

Whether lower or higher scores indicate better performance.