pyFDN.AsymmetricFlatMagnitude#

class pyFDN.AsymmetricFlatMagnitude(*, peak_power=4.0)[source]#

Flatness that punishes peaks far harder than dips – colorless.

The asymmetric sibling of FlatMagnitude: a resonant peak rings audibly at its own pitch while a dip of the same size is largely inaudible, so this measures \(|H|\) against the response’s own RMS and raises the two sides of the deviation to different powers,

\[d[f] = \frac{|H[f]|}{\sqrt{\langle |H|^2 \rangle_f}} - 1, \qquad \mathcal{L} = \Big\langle \big(d^{+}\big)^{p} + \big(d^{-}\big)^{2} \Big\rangle_f,\]

with peak_power \(p \ge 2\). Flat stays the unique minimum at every peak_power and the loss is gain-invariant (add Energy to pin the level). The exponent, not a weight, is what makes it bite, and the linear magnitude (not dB) is deliberate; see the design note for why, and for what a higher exponent costs in convergence.

Parameters:

peak_power (float) – Exponent on the peak side; dips are always quadratic. Must be at least 2 (the symmetric-shape reference, still peak-biased since a peak is unbounded and a dip is not). 4 is the default; 6 is slower but steadier. The advantage over FlatMagnitude is not unconditional – measure your own case. Loss values are not comparable across peak_power or with FlatMagnitude; compare the responses.

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__(*, peak_power=4.0)[source]#

Methods

__init__(*[, peak_power])

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