Abstract
Recent studies on transfer learning have shown that selectively fine-tuning a subset of layers or customizing different learning rates for each layer can greatly improve robustness to out-of-distribution (OOD) data and retain generalization capability in the pre-trained models. However, most of these methods employ manually crafted heuristics or expensive hyper-parameter searches, which prevent them from scaling up to large datasets and neural networks. To solve this problem, we propose Trainable Projected Gradient Method (TPGM) to automatically learn the constraint imposed for each layer for a fine-grained fine-tuning regularization. This is motivated by formulating fine-tuning as a bi-level constrained optimization problem. Specifically, TPGM maintains a set of projection radii, i.e., distance constraints between the fine-tuned model and the pre-trained model, for each layer, and enforces them through weight projections. To learn the constraints, we propose a bi-level optimization to automatically learn the best set of projection radii in an end-to-end manner. Theoretically, we show that the bi-level optimization formulation could explain the regularization capability of TPGM. Empirically, with little hyper-parameter search cost, TPGM outperforms existing fine-tuning methods in OOD performance while matching the best in-distribution (ID) performance.
Introduction
The standard paradigm in modern computer vision involves fine-tuning a large-scale pre-trained model (e.g., CLIP) on a specific downstream task. While effective for achieving high in-distribution (ID) accuracy, standard unconstrained fine-tuning often leads to "catastrophic forgetting" of the robust, general-purpose features acquired during pre-training. Consequently, the resulting models frequently overfit to the target domain and exhibit poor performance on out-of-distribution (OOD) data, such as sketches or stylized versions of the training objects.
Existing mitigation strategies, such as freezing specific layers or manually tuning layer-wise learning rates, rely heavily on heuristics and do not scale well to complex architectures like Vision Transformers (ViT). The search space for these hyperparameters is often too large for manual exploration, necessitating a more automated approach.
Methodology: Trainable Projected Gradient Method
To address these limitations, we introduce the Trainable Projected Gradient Method (TPGM). TPGM reformulates fine-tuning as a bi-level constrained optimization problem, where the goal is to learn optimal layer-wise distance constraints automatically.
The Projection Framework
For each layer in the network, TPGM maintains a "projection radius" ($\gamma$). This radius defines a hypersphere around the original pre-trained weights $\theta_0$. During training, if the fine-tuned weights $\theta_t$ move beyond this distance, a projection operator pulls them back to the boundary of this "safety bubble."
Bi-level Optimization
The constraints are learned through a nested optimization process:
- Inner Loop: Model weights are updated via standard gradient descent on the training set.
- Outer Loop: The projection radii $\gamma$ are optimized via backpropagation on a separate validation set.
This approach allows the model to discover an optimal hierarchy of constraints. For instance, TPGM automatically learns that lower layers (capturing general features like edges) should have smaller radii, while higher layers (task-specific) require more flexibility. To ensure stability, we also incorporate Group-Based Total Variation (TV) smoothing, encouraging layers within the same functional block to share similar constraints.
Experimental Results
We evaluated TPGM across several benchmarks, including DomainNet and ImageNet-1K, using both ResNet and Vision Transformer backbones.
Robustness and Efficiency
TPGM demonstrates significant gains in OOD robustness. On DomainNet (CLIP ResNet50), TPGM achieved a 16.01% absolute improvement in average OOD accuracy over vanilla fine-tuning. The method is particularly effective in low-data regimes; with only 10% of the training data, TPGM showed a 59.27% relative improvement in OOD performance.
Comparison with State-of-the-Art
TPGM consistently outperforms or matches existing methods like WISE, L2-SP, and LP-FT. Notably, TPGM achieves a superior Pareto front for the ID-OOD performance trade-off, often matching or exceeding standard fine-tuning accuracy on the target task while providing much better generalization.
Conclusion
TPGM provides a scalable, automated framework for robust fine-tuning by learning layer-wise constraints. While it introduces a modest computational overhead (~17%) during training, it eliminates the need for expensive manual hyperparameter searches. Future work will explore global optimization strategies to further refine the learned constraints and reduce the reliance on validation set quality.
Summary updated