How to Train Your Energy-Based Model for Regression

Fredrik Gustafsson, Martin Danelljan, Radu Timofte, Thomas B. Schön

Abstract: Energy-Based Models (EBMs) offer a flexible framework for modeling complex, multi-modal distributions, making them highly suitable for continuous regression tasks in computer vision. However, the intractability of the partition function presents a significant training challenge. This work provides a comprehensive evaluation of EBM training objectives for regression and introduces NCE+, a numerically stable extension of Noise Contrastive Estimation. By explicitly accounting for label noise, NCE+ achieves state-of-the-art performance in object detection and visual tracking while maintaining computational efficiency.

Introduction

In machine learning, Energy-Based Models (EBMs) learn a probability density by using a neural network to output a scalar "energy" value for a given input. Unlike traditional probabilistic models, EBMs do not rely on restrictive mathematical assumptions, allowing them to model complex, multi-modal, and asymmetric distributions. While EBMs have gained significant traction in generative image modeling, their application to continuous regression—such as predicting bounding box coordinates—remains underexplored.

The primary hurdle is the normalizing constant (partition function), which requires calculating an intractable integral. Previous approaches relied on Importance Sampling (IS), which often suffers from numerical instability and poor scalability. This paper systematically investigates the optimal training strategies for regression EBMs to establish a robust methodology for the computer vision community.

Methodology

The authors benchmark six established training methods: Maximum Likelihood with Importance Sampling (ML-IS), KL Divergence with IS (KLD-IS), ML with Markov Chain Monte Carlo (MCMC), Noise Contrastive Estimation (NCE), Score Matching (SM), and Denoising Score Matching (DSM).

To address the limitations of existing methods, the authors propose NCE+. Standard NCE trains a model to distinguish the ground-truth label from a set of generated "noise" samples. However, real-world datasets often contain annotation noise, where human-provided labels are slightly imprecise. NCE+ addresses this by sampling a perturbed version of the ground truth (using zero-centered Gaussian noise) and training the model to discriminate this perturbed label from broader noise samples. At inference time, predictions are generated via gradient ascent, iteratively refining an initial guess to maximize the learned energy function.

Analysis of Training Stability

A key finding of the study is the superior numerical stability of contrastive methods over traditional sampling techniques. Importance Sampling methods (ML-IS, KLD-IS) are highly sensitive to the number of negative samples ($M$). When $M$ is small, these methods often experience numerical failure or significant performance degradation. In contrast, NCE and NCE+ remain stable even with a very small number of samples, which is crucial for reducing training costs and improving convergence speed.

Figure 2: KL Divergence ($D_{KL}$) vs. number of samples ($M$) for 1D regression. NCE methods show superior stability and convergence with fewer samples compared to IS-based approaches.

Experimental Results

The proposed NCE+ method was evaluated across 1D regression, object detection, and visual tracking tasks.

Object Detection

On the COCO dataset, NCE+ achieved a state-of-the-art Average Precision (AP) of 39.7%, outperforming both ML-IS (39.4%) and standard NCE (39.5%). Notably, NCE+ maintains high performance even when $M$ is drastically reduced, whereas IS methods fail under such constraints. This efficiency allows for high-quality training with minimal computational overhead.

Figure 3: Average Precision (AP) on COCO vs. number of samples ($M$). NCE+ achieves high performance even with a single noise sample, demonstrating its robustness and efficiency.

Visual Tracking

Integrating the NCE+ training method into a state-of-the-art tracking architecture (creating "DiMP-NCE+") yielded superior results across five rigorous benchmarks. It achieved 63.7% AUC on LaSOT and 78.7% Success on TrackingNet. Crucially, the tracker operates at a practical 30 FPS on a single GPU, proving that EBM-based regression is viable for real-time applications.

Conclusion

This study establishes NCE+ as a robust and efficient training recipe for regression EBMs. By explicitly modeling annotation noise and ensuring numerical stability, NCE+ enables the application of EBMs to complex vision tasks without the computational instability of traditional methods. While EBMs require iterative gradient ascent during inference, the performance gains in accuracy and robustness make them a compelling alternative to standard feed-forward regression networks. Future work will explore applying these methods to higher-dimensional tasks such as human pose estimation and age prediction.

Summary updated

BibTeX
@inproceedings{gustafsson2020how,
  author = {Fredrik Gustafsson and Martin Danelljan and Radu Timofte and Thomas B. Schön},
  title = {{How to Train Your Energy-Based Model for Regression}},
  booktitle = {BMVC},
  year = {2020},
}
Figure