Abstract
While neural networks are typically trained end-to-end using stochastic gradient descent (SGD), the last linear layer under a squared loss actually has an exact, closed-form mathematical solution. This paper proposes a practical algorithm to continuously solve for the optimal last layer during mini-batch training—using a proximal regularization term to prevent batch overfitting—which accelerates training and improves performance, especially in complex regression tasks.
Introduction
In standard deep learning, every layer of a neural network is updated iteratively using gradient descent. However, when employing a squared loss—a common choice for regression and certain classification tasks—the final layer acts as a linear regression on top of the network's learned features. Linear regression possesses a well-known, closed-form optimal solution (Ridge Regression). Treating this last layer identically to the non-linear backbone ignores a significant mathematical shortcut.
Previous attempts to exploit this "two-timescale" regime, where the last layer is solved exactly while the backbone is trained with SGD, faced two primary challenges:
- Computational Overhead: Differentiating through a matrix inversion to update the backbone is computationally prohibitive.
- Mini-batch Instability: Solving the last layer exactly on small mini-batches leads to extreme overfitting, creating a "moving target" that destabilizes the backbone's learning process.
The Proximal Closed-Form SGD Algorithm
The authors introduce Proximal Closed-Form SGD, a method designed to overcome these hurdles through two key innovations.
Bypassing the Matrix Inverse
Using the Envelope Theorem, the authors prove that if the last layer is perfectly optimized for the current backbone features, the gradient of the loss with respect to the backbone parameters does not require backpropagation through the closed-form solver. One can simply compute the optimal last layer, freeze it, and perform a standard backward pass through the backbone. This turns a complex bilevel optimization problem into a computationally efficient standard pass.
Proximal Regularization for Stability
To mitigate the instability of mini-batch updates, the authors introduce a proximal loss term. This term penalizes the closed-form solution of the current batch for deviating too far from the weights of the previous step. Mathematically, this update is equivalent to running an approximate Kalman filter on the last layer weights, effectively smoothing the stochastic noise inherent in mini-batch training.
Empirical Results and Theoretical Insights
The method was evaluated across regression (Fourier Neural Operators for Burgers' equation), causal inference (Deep Feature Instrumental Variable regression), and classification (CIFAR and ImageNet).
Key Findings
- Accelerated Convergence: On the Burgers' equation task, the proximal method significantly outperformed standard l2 SGD, reaching lower Mean Squared Error (MSE) faster across all batch sizes.
- Classification Performance: On CIFAR-100, the proximal method surprisingly outperformed standard Cross-Entropy training. On ImageNet, while it beat l2 SGD, it still trailed behind Cross-Entropy, suggesting that the squared loss objective itself may be a limiting factor for high-dimensional classification.
- Correcting Layer-wise Bias: By instantly solving the last layer, the method provides the deepest layer with an effectively "infinite" learning rate, balancing the convergence speed between shallow and deep layers.
Theoretical Foundations
The authors analyze the loss landscape within the infinite-width Neural Tangent Kernel (NTK) regime. They demonstrate that despite the non-convexity of the landscape, gradient flow is guaranteed to converge almost surely to a global minimum.
Limitations and Future Outlook
The primary limitation is the reliance on squared loss, which is less effective than Cross-Entropy for some classification tasks. Additionally, the method currently shows poor compatibility with adaptive optimizers like Adam, likely due to conflicts between Adam's internal state and the proximal regularization parameter. Future research aims to adapt this closed-form strategy for Cross-Entropy loss and develop adaptive proximal schemes compatible with a wider range of optimizers.
Summary updated