pyFDN.FlatMagnitude#

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

Mean squared error of \(|H|\) against a flat target – colorless.

Fits the magnitude spectrum of the (rectangularly truncated) impulse response to a constant, after Differentiable FDNs for Colorless Reverberation (Dal Santo et al.). Its frequency resolution is the model’s nfft, which makes the fit sensitive to it; see the design note and FlatSpectrogram for a resolution-independent alternative.

Parameters:
  • target (float) – The flat magnitude to fit. The default of 1 matches pyFDN.build_fdn()’s normalized input/output gains, which put the initial \(|H|\) near unity.

  • channels (Literal['sum', 'mean', 'none']) – How the output channels are combined before the comparison. "sum" (default) reproduces FLAMO’s mse_loss convention. "none" fits each input/output pair to flat on its own, the well-posed choice for a multi-output FDN.

Notes

The optimization crosses long plateaus on this objective; train_fdn’s default patience=10 stops inside one. Raise it (~100) for a converged fit. 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='sum')[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