Analytical Uncertainty-Based Loss Weighting in Multi-Task Learning

Lukas Kirchdorfer, Cathrin Elich, Simon Kutsche, Heiner Stuckenschmidt, Lukas Schott, Jan M. Köhler · DOI

Abstract

With the rise of neural networks in various domains, multi-task learning (MTL) gained significant relevance. A key challenge in MTL is balancing individual task losses during neural network training to improve performance and efficiency through knowledge sharing across tasks. To address these challenges, we propose a novel task-weighting method by building on the most prevalent approach of Uncertainty Weighting and computing analytically optimal uncertainty-based weights, normalized by a softmax function with tunable temperature. Our approach yields comparable results to the combinatorially prohibitive, brute-force approach of Scalarization while offering a more cost-effective yet high-performing alternative. We conduct an extensive benchmark on various datasets and architectures. Our method consistently outperforms six other common weighting methods. Furthermore, we report noteworthy experimental findings for the practical application of MTL. For example, larger networks diminish the influence of weighting methods, and tuning the weight decay has a low impact compared to the learning rate.

Introduction

Multi-Task Learning (MTL) is a paradigm in deep learning where a single model is trained to perform multiple tasks simultaneously. This approach is inspired by human learning, where skills in one area often complement another. In computer vision, for instance, a model might simultaneously perform semantic segmentation, depth estimation, and surface normal prediction. The primary goal is to leverage shared representations to improve overall performance and efficiency.

However, training such models is notoriously difficult due to the "balancing act" required for task losses. If the loss for one task is significantly larger than others, it will dominate the gradient updates, causing the model to neglect the remaining tasks. This paper, "Analytical Uncertainty-Based Loss Weighting in Multi-Task Learning," introduces a novel method called Soft Optimal Uncertainty Weighting (UW-SO) to solve this fundamental challenge analytically.

The Problem: Why Equal Weighting Fails

The most straightforward way to combine multiple losses is through a weighted sum: $L_{total} = \sum_{k=1}^{K} w_k L_k$. Setting all $w_k = 1$ (Equal Weighting) is rarely optimal because different tasks have different loss scales and noise levels.

To address this, researchers often turn to Scalarization, which involves searching for a fixed set of weights that maximize performance. While effective, Scalarization is a brute-force approach that becomes mathematically impossible as the number of tasks grows. For example, the CelebA dataset contains 40 tasks; a grid search for 40 weights is computationally prohibitive.

The most popular automated alternative is Uncertainty Weighting (UW), which treats task weights as learnable parameters representing the "homoscedastic noise" of each task. However, the authors identify two critical flaws in UW:

  1. Update Inertia: Because weights are learned via gradient descent, they often start far from their optimal values and take a significant portion of the training time (sometimes over 100 epochs) to converge.
  2. Overfitting: UW can sometimes over-prioritize specific tasks during training, leading to high training accuracy but poor generalization on unseen test data.

Proposed Method: Soft Optimal Uncertainty Weighting (UW-SO)

The authors propose UW-SO to overcome these hurdles by calculating weights analytically rather than learning them iteratively.

The Analytical Leap

The core idea is to derive the analytically optimal values for the uncertainty parameters at any given moment in training. By analyzing the loss functions (such as $L_1$ or $L_2$), the authors show that the optimal weight for a task is directly related to the inverse of its current loss. For an $L_1$ loss, the optimal weight $w_k$ is simply $1/L_k$.

Softmax Smoothing and Temperature

To ensure numerical stability, the authors apply a tempered softmax function to the calculated inverse losses: $$w_k = \text{softmax}(1/L_k, T)$$ The introduction of the temperature parameter $T$ allows for control over the "aggressiveness" of the weighting. A high $T$ pushes the weights toward equality, while a low $T$ allows the method to focus more sharply on tasks with smaller losses (which are often the ones needing more precision).

Key Insights and Experimental Findings

The researchers conducted extensive benchmarks using architectures like SegNet, ResNet-50, and ResNet-101 across datasets including NYUv2, Cityscapes, and CelebA.

Visualizing Update Inertia

One of the paper's most compelling contributions is the visual demonstration of "update inertia." In standard UW, the weights for segmentation, depth, and normal tasks take a long time to stabilize. UW-SO eliminates this lag by computing the optimal weights instantly based on the current state of the model.

Evolution of task weights over training epochs for standard Uncertainty Weighting (UW), illustrating the 'update inertia' where weights take significant time to stabilize.

The Role of Network Capacity

An unexpected finding was that the importance of the weighting method decreases as the network size increases. With a large backbone like ResNet-101, the performance difference between various weighting methods (including simple Equal Weighting) becomes less pronounced. This suggests that larger models have the capacity to handle task imbalances more gracefully than smaller ones.

Practical Optimization

For practitioners, the study highlights that the Learning Rate (LR) is the most critical hyperparameter to tune when using these weighting methods. In contrast, Weight Decay (WD) had a relatively low impact on the final multi-task performance.

Results and Conclusion

UW-SO consistently outperformed or matched existing state-of-the-art methods. On the CelebA dataset (40 tasks), UW-SO achieved a relative performance gain ($\Delta_m$) of -4.0%, significantly better than the standard UW's -0.1%. Across all benchmarks, UW-SO was frequently the top-performing method, providing a high-performance alternative to the expensive grid searches required by Scalarization.

UW-SO represents a significant step forward in Multi-Task Learning. By replacing iterative weight learning with an analytical solution, it solves the problem of update inertia and provides a more robust, scalable way to balance complex multi-task losses. Future work will focus on developing heuristics to automatically set the temperature $T$, potentially removing the need for manual hyperparameter tuning in MTL.

Summary updated

BibTeX
@misc{kirchdorfer2024analytical,
  author = {Lukas Kirchdorfer and Cathrin Elich and Simon Kutsche and Heiner Stuckenschmidt and Lukas Schott and Jan M. Köhler},
  title = {{Analytical Uncertainty-Based Loss Weighting in Multi-Task Learning}},
  year = {2024},
  eprint = {2408.07985},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2408.07985},
}
Figure