Last-Layer Linearization in Neural Networks
- Last-layer linearization is the process of freezing a network’s nonlinear feature extractor and using a linear output head to simplify inference and retraining.
- It underpins methods such as Bayesian GLMs, posterior-aware conformal regression, and closed-form head optimization, offering significant efficiency and effective uncertainty modeling.
- While effective for many applications, its limitations in capturing extractor uncertainty spur the development of multi-layer fusion techniques for enhanced robustness.
Last-layer linearization is the treatment of a deep network as a fixed nonlinear feature map followed by a linear output head, so that inference, optimization, or retraining is performed only with respect to that head. In a standard feed-forward regression model, the backbone produces a feature map from the last hidden layer and the predictor is ; more generally, linearizing a DNN around a selected parameter subset gives , and choosing to be the final layer yields the last-layer form (Kim et al., 1 Dec 2025, Wilson et al., 29 May 2026). Recent work uses this construction in several distinct but related ways: as a Bayesian generalized linear model for epistemic uncertainty quantification, as the basis of posterior-aware conformal regression, as a device for closed-form or proximal optimization of the head, and as a retraining mechanism for robustness to spurious correlations and worst-group failure modes (Fiedler et al., 2023, Galashov et al., 6 Oct 2025, Welfert et al., 2024).
1. Formalization and model classes
In the Bayesian GLM view, both full-network and last-layer approximations are obtained by linearizing a DNN around selected parameters and placing a Gaussian prior on those linearized parameters. If , the resulting linearized model is a Bayesian generalized linear model whose predictive distribution matches that of a Gaussian process with kernel . When the subset is all parameters, the induced kernel is the Neural Tangent Kernel ; when the subset is only the final layer parameters , 0 and the induced kernel is the Conjugate Kernel 1. The corresponding terminologies in the literature are DNN-GLM for full-network linearization and LL-GLM for last-layer linearization (Wilson et al., 29 May 2026).
A closely related formulation appears in Bayesian last-layer neural networks. There, the hidden layers are deterministic and define a learned feature vector 2, while the output layer is linear and probabilistic: 3, with Gaussian observation noise and a Gaussian prior on 4. In this setting, the model is exactly Bayesian linear regression on learned features, rather than a first-order approximation over all network weights (Fiedler et al., 2023).
This dual usage explains why the term “last-layer linearization” covers more than one research line. In some papers it means a first-order linearization with respect to final-layer parameters; in others it means freezing a representation and exploiting the exact linear structure of the output head. The common object is the same: a nonlinear backbone whose role is feature extraction, and a final affine map whose linearity is used analytically or algorithmically.
2. Bayesian last-layer models and uncertainty quantification
Several leading methods for uncertainty quantification linearize DNNs to form Bayesian GLMs, with the posterior predictive distribution as the key object for epistemic uncertainty. Under the Gaussian-process equivalence, the predictive posterior is Gaussian, and the posterior covariance quantifies uncertainty. In Bayesian last-layer models, this becomes especially explicit: the predictive distribution is 5, where 6 and 7, with posterior precision 8 (Fiedler et al., 2023).
A central comparison in this literature is whether one gains materially by linearizing the entire network rather than only the final layer. Using Bayes Free Energy, 9, as the comparison metric, random matrix theory in a double-asymptotic regime yields the conclusion that there is no meaningful theoretical advantage of full-network linearization over last-layer linearization in UQ; the only regime where NTK can outperform CK is when 0, and even there the paper suggests the advantage may be an initialization artifact. The same study reports that LL-GLM is comparable to, or sometimes better than, DNN-GLM on toy 1D regression, UCI regression benchmarks, image classification tasks from MNIST through ImageNet, and GPT-2 fine-tuned on IMDB sentiment classification. On GPT-2/IMDB, LL-GLM showed about 1 faster wall-time and about 2 lower memory use, while having no statistically meaningful difference in VARROC-ID (Wilson et al., 29 May 2026).
The Bayesian last-layer literature also studies how predictive covariance relates to extrapolation. One paper defines an affine cost 3 through a constrained optimization over the training features and proves that, when 4, 5. This identifies the Bayesian last-layer covariance with a scaled extrapolation cost in feature space and motivates tuning 6 after marginal-likelihood training. In the reported simulation study, the model with tuned 7 achieved the best test log-predictive density among the compared methods: 8 for NN with BLL, versus 9 for BLR with NN features and 0 for a BNN trained with variational inference (Fiedler et al., 2023).
Standard Gaussian BLL models have also been generalized. A flexible Bayesian last-layer model, DVI-IBLL, replaces the Gaussian prior with an implicit prior 1 and uses diffusion posterior sampling rather than Gaussian or mean-field posterior approximation. The method is presented as addressing non-Gaussian, outlier-rich, or high-dimensional settings while keeping the last-layer-only Bayesian structure. Reported runtime overhead remains modest relative to deterministic training, with 0.343 s/batch for DVI-IBLL versus 0.321 s/batch for the DNN baseline, and the paper reports CIFAR-10 accuracy 2, ECE 3, and NLL 4 (Xu et al., 2024).
3. Posterior-aware conformal regression
A recent development is the combination of last-layer Bayesianization with conformal prediction. CLAPS defines a conformal regression method that uses a Last-Layer Laplace Approximation together with split-conformal calibration. The backbone is kept fixed, and only the scalar linear head 5 is Bayesianized. With a Gaussian prior 6 and homoscedastic Gaussian observation noise 7, the last-layer MAP estimate is the ridge-regression solution
8
and the Laplace approximation gives
9
The induced posterior predictive is
0
with 1 and 2, decomposing into aleatoric and epistemic terms (Kim et al., 1 Dec 2025).
CLAPS uses the full posterior predictive CDF rather than a residual score. If 3 denotes the CDF of the Gaussian predictive, the conformity score is
4
For the Gaussian case, with 5, this becomes 6. Split conformal calibration is then applied with the standard rank/order-statistic rule, and because 7 is monotone in 8 under the Gaussian predictive, the prediction set is a central interval symmetric around 9. The finite-sample marginal coverage guarantee is unchanged: under exchangeability of calibration and test points conditional on the trained backbone/posterior, 0 (Kim et al., 1 Dec 2025).
The method is accompanied by a diagnostic suite. The predictive variance decomposition 1 motivates the epistemic share
2
together with 3 as a global posterior-uncertainty summary and the heteroscedasticity signal 4. The reported empirical pattern is that CLAPS is most effective when 5 is nontrivial and heteroscedasticity is weak. On Airfoil and kin8nm, it achieved nominal coverage around 6 with the narrowest intervals among the compared methods, with reported widths about 7 on Airfoil and 8 on kin8nm. On CASP it was competitive but not always the narrowest, and on YearPredictionMSD the advantage largely disappeared as posterior variance collapsed and Normalized-CP or CQR became tighter (Kim et al., 1 Dec 2025).
4. Exact last-layer optimization and stochastic training
Last-layer linear structure is also exploited for optimization under squared loss. For a model 9, with backbone feature map 0 and final linear layer 1, the regularized squared-loss objective
2
is a ridge-regression problem in 3 for fixed 4. The optimal final layer is available in closed form: 5 This induces a reduced objective 6 in which the last layer is treated as an implicit function of the backbone parameters (Galashov et al., 6 Oct 2025).
The key theorem is a gradient-equivalence result: for fixed 7, 8. Because 9 at the optimum, one does not need to backpropagate through the matrix inverse defining 0. Training can therefore alternate an exact solve for the head with an ordinary gradient step on the backbone: 1 A stochastic minibatch extension adds a proximal term 2, yielding a closed-form proximal update that regularizes the batch solve toward the previous iterate (Galashov et al., 6 Oct 2025).
The same work shows that the reduced loss is not convex and may have non-global critical points, but proves an NTK-regime convergence result: under sequential infinite-width limits, positive definite NTK and NGPK, and 3, gradient flow on the reduced objective converges almost surely to a global minimizer. Empirically, the proximal closed-form last-layer method improves over squared-loss SGD on 1D Burgers with a Fourier Neural Operator, improves minibatch training in deep feature instrumental variable regression, generally outperforms plain squared-loss SGD on CIFAR-10 and CIFAR-100 with ResNet-18, and improves over squared-loss SGD on ImageNet with NF-Nets, although cross-entropy still remains stronger at ImageNet scale (Galashov et al., 6 Oct 2025).
5. Retraining, spurious correlations, and worst-group accuracy
Another major use of last-layer linearization is last-layer retraining on frozen representations. In the group-robustness setting, the ambient input 4 is mapped to a latent representation 5, and only a linear classifier 6 is retrained. Under Gaussian group-conditional latent distributions 7, recent theory analyzes downsampling (DS), upweighting (UW), and intra-class domain mixup (MU). The paper proves that DS and UW are distribution-free equivalent for any loss, derives closed-form optimal linear classifiers for DS/UW, SRM/ERM, and MU under the Gaussian model, and shows that under the orthogonality condition 8 and 9,
0
The common optimal worst-group error for the balanced methods is 1. On CMNIST, CelebA, and Waterbirds, the reported worst-group error means 2 std over 10 runs support the theory, with DS, UW, and MU all substantially better than ERM (Welfert et al., 2024).
Data selection for last-layer retraining has also been automated. One framework uses OWL-ViT to score the presence of the target object, ranks images within each class by that detector score, and retrains only the final linear classifier head on class-balanced subsets such as top 3, mid 4, bot 5, and rnd 6. On ImageNet-1k with ResNet-50 and DeiT-small, the reported trends are that top 100 models perform better on low-ranked test examples, top 100 models are consistently more robust than bot 100 under foreground and background noise, and bot 7 models achieve higher accuracy on ImageNet-A (Azizmalayeri et al., 2023).
The same line of work also exposes a limitation of last-layer-only retraining. H2T-DFR combines DFR with Head2Toe feature selection from all layers, using group-lasso regularization on a balanced validation set to select useful features beyond the last layer. With a ResNet-50 backbone, the reported mean worst-group accuracy over 5 seeds improved from 8 for DFR to 9 for H2T-DFR on CelebA, and from 0 to 1 on HAM10000, while Waterbirds did not improve and remained close to DFR (Hameed et al., 2024).
6. Critiques of last-layer sufficiency and generalized last-layer heads
The assumption that the last layer is a sufficient representation is explicitly challenged in several domains. In sentence embedding, one study argues that sentence meaning is not concentrated only in the final transformer layer. It reports that on STS-B, BERT with 2 pooling can perform much better at an intermediate layer than at the last layer, with the 4th layer around 3 better than the last layer for STS-B. The proposed LayerAttPooler uses attention-based pooling over all layers, concatenates the last-layer 4 representation with the learned layer-pooled vector, and improves over last-layer baselines on STS and semantic search. For example, in an unsupervised BERT5 reimplementation, the average score increases from 6 with last-layer 7 to 8 with LayerAttPooler (Oh et al., 2022).
A similar critique appears in visual tokenization. DRoRAE argues that last-layer features are a lossy bottleneck for image tokenization because low-level visual details survive in the last layer only as attenuated residuals after semantic abstraction. The method fuses all encoder layers through energy-constrained routing and incremental correction rather than using only the last encoder layer. On ImageNet-256, the reported reconstruction rFID decreases from 9 for the RAE baseline to 00 for the full three-phase DRoRAE model, and generation FID improves from 01 to 02 with AutoGuidance. The same work reports a log-linear scaling law between fusion capacity and reconstruction quality, 03 with 04 (Zhu et al., 11 May 2026).
In neural operators, the “last layer” has also been generalized away from linear regression. The diffusion last layer (DLL) is explicitly described as not being classical last-layer linearization in the Bayesian-NN sense, yet it preserves the same decomposition into frozen backbone and lightweight probabilistic head. The backbone produces an input-dependent rank-05 basis 06, the output field is approximated as 07, and a conditional diffusion model is trained on the coefficient vector 08. The paper therefore characterizes DLL as a last-layer generative approximation or function-space probabilistic last layer rather than a parameter-space linearization (Park et al., 4 Feb 2026).
7. Geometry, recoverability, and recurring limitations
The linearity of the last layer has geometric consequences beyond training and uncertainty estimation. In a model-stealing setting where a transformer returns logits 09, the attainable logits lie in the linear subspace 10. With normalization before the last layer, the outputs satisfy linear constraints together with a quadratic equation 11, so the output set is an ellipsoid inside 12. Under a clean rank-13 spectral gap, a nondegenerate quadric, and local stability, the last layer can be recovered exactly up to an orthogonal gauge 14, 15. The same analysis shows an identifiability wall below the last layer: deeper hidden networks cannot be fully reverse engineered from final outputs alone (Khilar, 5 Jun 2026).
The literature is equally explicit about the limitations of last-layer linearization. In CLAPS, only the last linear layer is Bayesianized, so epistemic uncertainty from the feature extractor itself is not captured, and the method loses its advantage when the last-layer posterior contracts toward zero or when heteroscedasticity is strong (Kim et al., 1 Dec 2025). In the LL-GLM versus DNN-GLM comparison, the theory is for randomly initialized networks rather than trained DNNs on realistic datasets, the sampling framework models only epistemic uncertainty, and near-rank-deficiency in trained last-layer Jacobians can create finite-precision issues (Wilson et al., 29 May 2026). In robustness and representation learning, several papers argue that the penultimate representation may already have discarded useful robust, low-level, or task-relevant signals, motivating all-layer feature selection or multi-layer fusion instead of strict last-layer dependence (Hameed et al., 2024, Oh et al., 2022, Zhu et al., 11 May 2026).
A central interpretation emerging from these results is that last-layer linearization is most effective when the decisive uncertainty or task signal lies in how learned features are used, rather than in uncertainty about the feature extractor itself. When that condition holds, the approach offers analytic tractability, exact or approximate Gaussian posteriors, conformal calibration with standard validity, efficient closed-form optimization, and strong computational savings. When it does not hold, the literature increasingly replaces last-layer sufficiency with multi-layer or function-space constructions that preserve the computational advantages of a lightweight head while relaxing the representational bottleneck (Wilson et al., 29 May 2026, Park et al., 4 Feb 2026).