A few-shot classifier learns a new category from one to five labelled examples. With so few examples, it memorizes accidental details such as backgrounds, poses, or phrasing, instead of what defines the class. That failure is usually measured only as lost accuracy. It also has a second symptom that almost nobody measures: the classifier becomes confident in a way unrelated to how often it is right. A linear classifier fitted to five well-separated support points will push its outputs toward probability one whether the episode is easy or hopelessly confusable. The papers that fix few-shot overfitting by "calibrating" feature distributions report top-1 accuracy only; none reports whether the resulting probabilities can be trusted. Meanwhile, work that trains networks to be calibrated has found that a calibration loss computed on training data drives training error to zero while test calibration stalls. On one to five examples per class, that problem cannot be avoided.
We propose to treat these as one problem and use the structure of few-shot learning to solve it. Every training episode already comes with a held-out query set, which is exactly the unbiased calibration signal that in-training calibration methods lack. We meta-train a small calibrator that reads statistics of the support set: how spread out the examples are, how separable the classes look under leave-one-out, and how close they sit to known base classes. From these it sets that episode's temperature and how strongly each novel class prototype is pulled toward base-class prototypes. The calibrator is trained with a differentiable calibration-error loss on the query sets. The central bet is that few-shot miscalibration varies from episode to episode, so no single temperature can fix it, while a support-conditioned one can.
Core Claim
Expected calibration error (ECE) measures the gap between stated confidence and actual accuracy, binned by confidence level. In few-shot classification, the dominant source of this error is episode-level: how confident the model is within a task barely tracks how accurate it is within that task. A global correction such as temperature scaling can drive pooled ECE down by matching average confidence to average accuracy across many episodes. It still leaves easy episodes underconfident and hard episodes overconfident. Correcting this requires a calibration signal the support set cannot provide, because the support set is fitted perfectly. The query sets of base-class episodes provide it. We therefore claim that a support-conditioned calibrator trained with a query-set differentiable ECE will reduce episode-level miscalibration substantially more than a global temperature, without losing accuracy relative to the strong frozen-embedding baseline.
We formalize the target quantity. For episode $e$ with query predictions, let $\bar{c}_e$ be the mean top-class confidence and $a_e$ the query accuracy. The episode-level calibration gap over $E$ test episodes is
$$ \text{EGAP} = \frac{1}{E}\sum_{e=1}^{E} \left| \bar{c}_e - a_e \right|. $$
A global temperature can make the pooled averages of $\bar{c}_e$ and $a_e$ agree, but it cannot make them agree episode by episode unless miscalibration is constant across episodes. EGAP is the measurement that separates our proposal from its simplest competitor.
Relation to Prior Work
Four papers supply the method we reuse. Meta-Calibration builds a differentiable surrogate for ECE (DECE), using soft bin assignment and an all-pairs ranking relaxation for bin accuracy. It uses the surrogate in a bilevel loop over a fixed train/validation split to learn a label-smoothing matrix. It also motivates us: it documents calibration overfitting, and it never evaluates episodic few-shot tasks. We take its surrogate, but we calibrate per episode rather than over one split, and we condition on the support set rather than learning dataset-wide smoothing. We also avoid its reported 2.5x to 3x training overhead, because our inner problem is a closed-form prototype head rather than full network training.
Learning Optimal Conformal Classifiers (ConfTr) contributes the pattern of simulating a post-hoc calibration step inside each mini-batch so it can be backpropagated through. Our episodic split into support and query plays the role of its calibration/prediction split. Unlike ConfTr, we do not halve a batch, because the episode split already exists.
Improving model calibration with accuracy versus uncertainty optimization (AvUC) shows in-training calibration outperforming temperature scaling under corruption on standard datasets. We use AvUC as an alternative loss in our ablations.
Two papers constrain the design. Rethinking Few-Shot Image Classification shows that cross-entropy pre-training plus a frozen backbone and a linear classifier beats episodic meta-learning on accuracy. So we keep that backbone and add only a light calibrator, rather than proposing a new meta-learner. KULeuven at LeQua 2022 found that a trainable, kernel-based in-training calibration lost to plain Platt scaling under severe prevalence shift. This is a direct warning that learned calibration can fail off-distribution, and it is why our cross-domain test is decisive rather than decorative.
The distribution-calibration line explains the prototype-shrinkage half of our calibrator. Free Lunch for Few-shot Learning borrows base-class means and covariances to sample synthetic features. Hierarchical Optimal Transport learns which base classes to borrow from. P3DC-Shot and TEEN nudge support points or prototypes toward base prototypes. All four fix a borrowing strength by hand or heuristic and never measure probability calibration. We learn the borrowing strength per episode against a calibration objective, and we report their ECE for the first time.
Two papers work at the same intersection but only at inference time and only for language models. Can Large Language Models Achieve Calibration with In-Context Learning? ensembles over prompt variations. Prototypical Calibration fits a Gaussian mixture to a frozen model's outputs on unlabeled data. Neither learns anything from held-out episodes.
Research Program
The backbone is a ResNet-12 trained with standard cross-entropy on base classes, as in the frozen-embedding recipe. The classifier on each episode is a cosine nearest-prototype head, which is differentiable in closed form. Each novel prototype is a convex mix of the support mean and a similarity-weighted average of base prototypes, and the logits are scaled by a temperature. The calibrator is a small multilayer network. Its inputs are cheap support-set statistics: the number of ways and shots, within-class spread, mean distance between prototypes, leave-one-out support accuracy (for two or more shots), and cosine similarity of each prototype to its nearest base prototypes. Its outputs are the episode temperature $\tau_e$ and per-class shrinkage weights $\alpha_{e,k}$.
Training draws meta-batches of episodes and minimizes
$$ \mathcal{L} = \sum_{e \in \text{batch}} \mathcal{L}_{\text{CE}}(Q_e) \;+\; \lambda \, \text{DECE}\Big(\textstyle\bigcup_{e} Q_e\Big), $$
where $Q_e$ is the query set of episode $e$, $\mathcal{L}_{\text{CE}}$ is query cross-entropy, and DECE is pooled across the meta-batch. Pooling is necessary because 75 queries are too few to populate confidence bins, and it sidesteps the batch-size problem ConfTr faces. A variant adds the EGAP term directly.
The main design issue is leakage. Episodes built from classes the backbone was trained on are unrealistically easy, so a calibrator trained on them would learn the wrong confidence scale. We therefore cross-fit. Base classes are split into folds; a backbone is trained on all but one fold, and calibrator episodes are drawn from the held-out fold. The final calibrator is trained on the union of these held-out-fold episodes and paired with the full backbone.
A second variant unfreezes the backbone's last block under the same loss. This tests the in-training hypothesis that calibration pressure also reshapes features, beyond rescaling outputs. The analysis program then asks which support statistics the calibrator actually uses, and whether its predicted temperature tracks true episode difficulty.
Baselines
The naive reference point is the frozen-embedding recipe of Rethinking Few-Shot Image Classification with logistic regression and no calibration. It reports 82.14% 5-way 5-shot accuracy on miniImageNet with ResNet-12 and self-distillation. We will reproduce it on our backbone and report its ECE and EGAP, for which no reported result was found on Lacuna.
The strongest simple competitor is a single global temperature fitted by negative log-likelihood on validation-class episodes with matching way and shot. It uses the same backbone, the same episodes, and the same held-out classes as our calibrator, so it isolates conditioning as the only difference. Beating it means a clearly lower EGAP and a pooled ECE no worse, at equal accuracy.
The strongest existing accuracy methods are Free Lunch, which reports 68.57% 5-way 1-shot on miniImageNet, and H-OT, which reports 69.04%. We will run each on our backbone with its published hyperparameters, both as-is and followed by the global temperature. For these we must match accuracy within noise while lowering ECE; no calibration numbers exist for them on Lacuna.
Calibrated pre-training uses the same backbone trained with label smoothing, focal loss, or AvUC, followed by the plain linear head. Each loss gets the same tuning budget of roughly twenty configurations, selected on validation-episode ECE.
The ablations use our calibrator with temperature only, with shrinkage only, with inputs randomized (which separates capacity from conditioning), and with cross-entropy but no DECE term. The last one tests whether the calibration loss or the extra parameters do the work.
Why not just…?
Why not just fit one temperature on validation episodes? This is the real threat. In-domain, it may already remove most pooled ECE, and the claim in Beyond Post-Hoc Temperature Scaling that temperatures fail to transfer across domains says little about same-domain episodes. Our proposal survives only if miscalibration varies substantially across episodes. So the first experiment computes EGAP for the globally scaled baseline, and regresses per-episode miscalibration on support statistics. If those statistics explain little of the variance, we drop the conditioning claim and report the negative result.
Why not just pre-train with a calibration loss and keep the linear head? Calibration of base-class softmax outputs does not obviously transfer to a new linear head fitted on five points. That head's confidence is set by how cleanly its few support points separate, not by the backbone's softmax. The calibrated pre-training baselines above test this directly. If AvUC pre-training matches our EGAP, the contribution reduces to the known fact that calibrated features transfer, and we would say so.
Why not just use distribution calibration, since synthetic features already regularize the head? Borrowing base statistics may well soften overconfidence, but its strength is fixed by a heuristic. Under domain gap, the base priors it borrows are unreliable, as the H-OT and TEEN papers themselves note. Measuring the ECE of Free Lunch and H-OT settles how much they already achieve. The cross-domain test settles whether learned, episode-specific borrowing strength helps where fixed borrowing breaks.
Proposed Experiments
The in-domain benchmarks are miniImageNet and tieredImageNet at 5-way 1-shot and 5-shot, averaged over 2,000 test episodes with 95% confidence intervals. We report accuracy, pooled 15-bin ECE, EGAP, negative log-likelihood, and Brier score. The cross-domain test trains on miniImageNet and evaluates on CUB-200-2011. Here the LeQua result predicts learned calibration may collapse, while AvUC's corruption results predict it may hold. We report which happens, and we compare against a global temperature refitted on CUB validation episodes as an oracle-leaning reference.
The decisive checks are three. The first is whether EGAP falls meaningfully below the global-temperature baseline in-domain at matched accuracy. The second is whether the randomized-input ablation erases that gain, which would show conditioning rather than capacity is doing the work. The third is whether the advantage survives or reverses on miniImageNet→CUB. As a further diagnostic, we will plot predicted temperature against true episode accuracy on held-out episodes. A flat relationship would falsify the mechanism even if the aggregate numbers look good.
References
- Meta-Calibration: Learning of Model Calibration Using Differentiable Expected Calibration Error
- Learning Optimal Conformal Classifiers
- Improving model calibration with accuracy versus uncertainty optimization
- Rethinking Few-Shot Image Classification: A Good Embedding is All You Need?
- KULeuven at LeQua 2022: Model Calibration in Quantification Learning
- Free Lunch for Few-shot Learning: Distribution Calibration
- Adaptive Distribution Calibration for Few-Shot Learning with Hierarchical Optimal Transport
- P3DC-shot: Prior-driven discrete data calibration for nearest-neighbor few-shot classification
- Few-Shot Class-Incremental Learning via Training-Free Prototype Calibration
- Can Large Language Models Achieve Calibration with In-Context Learning?
- Prototypical Calibration for Few-shot Learning of Language Models
- Beyond Post-Hoc Temperature Scaling: Bilevel Optimization for LLM Calibration