pyFDN.SpectralFlatness#

class pyFDN.SpectralFlatness(target=1.0, *, channels='none')[source]#

Spectral flatness measure of \(|H|\) fit to flat – colorless.

The ratio of the geometric to the arithmetic mean of \(|H|\), the classic flatness measure: 1 for a perfectly flat spectrum, towards 0 for a peaky one. Unlike FlatMagnitude, both means scale the same way with an overall gain, so the loss is gain-invariant without needing to assume \(|H| \approx 1\). A silent response has flatness 0, the opposite end from flat.

Parameters:
  • target (float) – The flatness to fit, in [0, 1] (1 is perfectly flat). Default 1.0.

  • channels (Literal['sum', 'mean', 'none']) – How the output channels are combined before the flatness ratio is computed. "none" (default) scores each input/output path on its own flatness.

Notes

A lossless FDN has every pole exactly on the unit circle, where the frequency-domain evaluation breaks down; check() warns if the model was built without the alias_decay_db that avoids it.

__init__(target=1.0, *, channels='none')[source]#

Methods

__init__([target, channels])

check(model)

Preflight against the model it will train, before the first step.

terms()

Flatten into (weight, loss) leaves.

Attributes

name

Short label, used as the key in pyFDN.TrainLog.loss_log.

check(model)[source]#

Preflight against the model it will train, before the first step.

Override to reject or warn about a model this loss cannot be fit on – raising here beats a silently useless optimization run. Most losses place no demands on the model, hence the no-op default.

Return type:

None