Frequency-selective measurements
A difference-of-Gaussians filter bank extracts subband information, enabling the SFL to evaluate spatial-frequency discrepancies between output and target images.
A subband-aware loss designed to mitigate spectral bias in deep neural networks and improve the learning of fine-scale image structures.
Pixel-wise losses tend to prioritize the learning of low-frequency components, which can impede the learning of high-frequency components. Spatial Frequency Loss (the SFL) complements the pixel-wise reconstruction loss by measuring discrepancies between corresponding frequency-selective responses of output and target images.
A difference-of-Gaussians filter bank extracts subband information, enabling the SFL to evaluate spatial-frequency discrepancies between output and target images.
The SFL weights the subbands to promote the learning of high-frequency components. Because these weights would otherwise become training hyperparameters, the Inverse Error Ratio (IER) was developed to determine them automatically in a data-driven manner.
The SFL directly reduces spatial-frequency discrepancies without relying on adversarial training or nonlinear features from a pre-trained model. No noticeable additional artifacts were observed in the evaluated experiments. This fidelity-oriented design may be particularly valuable in applications where artificially generated structures are undesirable, such as medical imaging and physics-based image processing.
The SFL can be integrated without modifying the model architecture, data loader, or optimizer. It is used as a regular PyTorch module, and its weighted loss is simply added to the existing loss function with only a minimal change to the training loop.
Let \(I_k^o(c,h,w)\) and \(I_k^t(c,h,w)\) denote the output and target images of sample \(k\), respectively, where \(c\), \(h\), and \(w\) are the channel, vertical-coordinate, and horizontal-coordinate indices. Their responses in the \(s\)-th Difference-of-Gaussians subband are denoted by \(I_k^o(c,h,w \mid \sigma_s)\) and \(I_k^t(c,h,w \mid \sigma_s)\), respectively, where \(\sigma_s\) is the scale of the Difference-of-Gaussians filter for subband \(s\). The Spatial Frequency Loss is the weighted sum of the corresponding subband losses:
Here, \(E_{\mathrm{SFL}}(k \mid \sigma_s)\) is the subband loss at scale \(\sigma_s\), and \(w_{\mathrm{SFL}}(\sigma_s)\) is its weight. Smaller Gaussian scales correspond approximately to higher spatial frequencies. A large loss at a smaller scale therefore indicates insufficient reconstruction of high-spatial-frequency components.
The Inverse Error Ratio compares the pixel-wise L2 error over the entire image with the error in each subband:
A subband with a smaller reconstruction error receives a larger IER value. In natural-image datasets, high-frequency subbands generally have lower energy and smaller losses, so the IER tends to assign larger values to these subbands. The subband weights are obtained by averaging the IER over the calibration data:
This data-driven weighting gives greater emphasis to subbands with smaller initial errors and helps balance learning across spatial frequencies. In the public implementation, the calibration workflow estimates these weights before normal optimization and then keeps the calibrated weights fixed during training.
The SFL was evaluated using a VQ-VAE trained on the FFHQ and COCO2017 datasets. Compared with the baseline pixel-wise loss, incorporating the SFL produced sharper output images with better-preserved fine-scale structures.






The quantitative results are consistent with the visual comparisons. Incorporating the SFL improved PSNR, SSIM, and LPIPS on the validation data of both datasets.
| Dataset | Loss condition | PSNR (dB) ↑ | SSIM ↑ | LPIPS (×10−2) ↓ |
|---|---|---|---|---|
| FFHQ | Baseline | 25.83 | 0.7552 | 32.85 |
| FFHQ | Baseline + the SFL | 29.47 | 0.8558 | 16.60 |
| COCO2017 | Baseline | 23.85 | 0.6783 | 39.63 |
| COCO2017 | Baseline + the SFL | 25.77 | 0.7558 | 27.20 |
Lower values indicate smaller discrepancies between the corresponding frequency-selective responses of the output and target images. SB1–SB3 correspond approximately to high spatial frequencies, while the subsequent subbands cover progressively lower spatial-frequency ranges. The results show that the SFL substantially reduces the losses in the high-frequency subbands. In addition to reducing the overall L2 error, the SFL redistributes the remaining error across subbands to prioritize the learning of high-frequency components.
| Dataset | Loss condition | SB1 | SB2 | SB3 | SB4 | SB5 | SB6 | SB7 |
|---|---|---|---|---|---|---|---|---|
| FFHQ | Baseline | 17.17 | 22.84 | 23.06 | 12.40 | 6.747 | 5.167 | 24.36 |
| FFHQ | Baseline + the SFL | 11.91 | 11.83 | 9.083 | 5.915 | 3.633 | 2.429 | 14.40 |
| COCO2017 | Baseline | 56.65 | 59.47 | 41.48 | 17.22 | 7.097 | 4.086 | 16.09 |
| COCO2017 | Baseline + the SFL | 43.93 | 38.65 | 23.73 | 12.58 | 6.001 | 3.067 | 16.00 |
The SFL was also evaluated on an image-inpainting task using the DIV2K dataset and a convolutional network substantially different from the VQ-VAE used in the main experiments. The input image contains a central missing region covering 25% of the image area. Compared with the pixel-wise L2 loss alone, incorporating the SFL recovered sharper and more detailed structures within the missing region. This example corresponds to Fig. S9 in the Supplementary Material.




The paper measured FFHQ training with 40,000 images resized to 256 × 256, batch size 4, and three complete epochs of 10,000 iterations each. The interval included GPU transfer, forward propagation, loss computation, backward propagation, and the optimizer update.
| Loss condition | Training time (ms/iteration) | Relative time |
|---|---|---|
| Baseline | 50.50 ± 0.043 | 1.00 |
| Baseline + FFL | 52.15 ± 0.033 | 1.03 |
| Baseline + FRL | 59.67 ± 0.063 | 1.18 |
| Baseline + SFL, conv2d | 267.9 ± 0.724 | 5.31 |
| Baseline + SFL, separable | 66.85 ± 0.021 | 1.32 |
The first four rows are from Table 6 of the paper, where FFL and FRL stand for Focal Frequency Loss and Feature Reconstruction Loss, respectively. The original SFL implementation used the conv2d backend, which was retained throughout the paper to ensure fair comparisons across experiments. Because separable filtering is mathematically equivalent and substantially faster, the separable backend was implemented after publication and is used as the default in the public software. A post-publication measurement under the same measurement procedure found an approximately 4.01-fold speed-up over the original SFL implementation and an approximately 75.05% reduction in SFL training time.
This example shows the simplest workflow in which the SFL automatically determines the subband weights using the Inverse Error Ratio (IER) before training. The model architecture, data loader, and optimizer do not require modification.
from spatial_frequency_loss import SpatialFrequencyLosssfl = SpatialFrequencyLoss(
num_image_channels=3,
base_scale=0.6,
num_subbands=7,
ier_update_mode="calibration",
).to(device)
mse_loss = torch.nn.MSELoss()The calibration mode is specified explicitly for clarity, although it is the default update mode for the IER. The default filtering backend is separable.
model.eval()
sfl.eval()
with torch.no_grad():
for inputs, targets in calibration_loader:
inputs = inputs.to(device)
targets = targets.to(device)
outputs = model(inputs)
sfl.accumulate_calibration_ier(
outputs,
targets,
)
sfl.finalize_ier_calibration()The existing model and data loader are used for a forward-only calibration pass. The SFL accumulates the subband errors and automatically determines the weights based on the IER. No model parameters are updated during this step.
model.train()
sfl.train()
for epoch in range(num_epochs):
for inputs, targets in train_loader:
inputs = inputs.to(device)
targets = targets.to(device)
optimizer.zero_grad()
outputs = model(inputs)
l2_loss = mse_loss(
outputs,
targets,
)
(
subband_losses,
weighted_sfl,
_,
_,
_,
) = sfl(
outputs,
targets,
)
total_loss = l2_loss + weighted_sfl
total_loss.backward()
optimizer.step()Naoyuki Ichimura, “Spatial frequency loss for mitigating spectral bias in deep neural networks,” Machine Vision and Applications 37, 173 (2026). DOI: 10.1007/s00138-026-01927-5.