Secure Out-of-Distribution Task Generalization with Energy-Based Models
Authors: Shengzhuang Chen
Long-Kai Huang
Jonathan Richard Schwarz
Yilun Du
Ying Wei
Venue: NeurIPS 2023 poster (2023)
Keywords: meta-generalization
out-of-distribution tasks

Abstract: The success of meta-learning on out-of-distribution (OOD) tasks in the wild has proved to be hit-and-miss.
To safeguard the generalization capability of the meta-learned prior knowledge to OOD tasks, in particularly safety-critical applications, necessitates detection of an OOD task followed by adaptation of the task towards the prior. 
Nonetheless, the reliability of estimated uncertainty on OOD tasks by existing Bayesian meta-learning methods is restricted by incomplete coverage of the feature distribution shift and insufficient expressiveness of the meta-learned prior. 
Besides, they struggle to adapt an OOD task, running parallel to the line of cross-domain task adaptation solutions which are vulnerable to overfitting.
To this end, we build a single coherent framework that supports both detection and adaptation of OOD tasks, while remaining compatible with off-the-shelf meta-learning backbones. 
The proposed Energy-Based Meta-Learning (EBML) framework learns to characterize any arbitrary meta-training task distribution with the composition of two expressive neural-network-based energy functions. We deploy the sum of the two energy functions, being proportional to the joint distribution of a task, as a reliable score for detecting OOD tasks; during meta-testing, we adapt the OOD task to in-distribution tasks by energy minimization.
Experiments on four regression and classification datasets  demonstrate the effectiveness of our proposal.

Secure Out-of-Distribution Task Generalization with Energy-Based Models
Shengzhuang Chen'
Long-Kai Huang
Jonathan Richard Schwarz²
Yilun Du
Ying Wei
City University of Hong Kong
Teencett AT Lab UUniversity College London
A Massachusetts Institute of Technology *Nanyang Technological University
czchen9-camy cityu. edu. hk
fhlongkai, schwarzjn) com ying. wei@ntu. edu.
yilunduêmit..o
Abstract
The success of meta-lcarning on out-of-distribution (OOD) tasks in the wild has proved to be hit-and-miss. To safeguard the generalization capability of the meta- learned prior knowledge to OOD tasks, in particularly safety-critical applications, necessitates detection of OOD task followed by adaptation of the task towards the prior. Nonetheless, the reliability of estimated uncertainty on OOD tasks by existing Bayesian meta-learning methods is restricted by incomplete coverage of the feature distribution shift and insufficient expressiveness of the meta-learned prior. Besides, they struggle to adapt OOD task, running parallel to the line of cross-domain task adaptation solutions which are vulnerable to overfitting. To this end, we build single coherent framework that supports both detection and adaptation of OOD tasks, while remaining compatible with off-the off-the-shelf meta-lcarning backbones. The proposed Energy-Bon -ased Meta- Decan-ee (EBML) framework learns characterize any arbitrary meta-training task distribution with the composition of two expressive neural-network- neter---booor-- energy functions. We deploy the sum of the two energy functions, being proportional to the joint distribution of task, as reliable score for detecting OOD tasks; during meta-testing, we adapt the OOD task to in-distribution tasks by energy minimization. Experiments four regression and classification datasets demonstrate the effectiveness of our proposal.
Introduction
Meta-learning 48 that builds general-purposs learners with limited data has been under constant investigation, recently demonstrating its potential to even advance few-shot learning of large lan- guage models [36]]]]]] 44 Analogous to the notorious domain shift (23 that degrades the performance of deep learning, meta-testing tasks that are out of the distribution of meta-training tasks (a.k.a. out-of-distribution (OOD) tasks) put the meta-learned prior knowledge at high risk losing effective- ness [46]. In real-world applications, though, out-of-distributte picking for a robot that has never been meta-trained on environments involving bins (55), MRI-based pancreas segmentation given host of meta- -tatt-rriiing tasks with pathology images [35], and etc. Thus, it is imperative to secure the generalization ability of the meta-learned prior (i.e., meta- mnttaaeeneallizttoon) OOD tasks, especially in safety-critical applications such medical image analysis.
tasks are highly prevalent, e.g., bin
The first step securing meta-generalizztion
task is to develop awareness of whether the task is OOD not, i.e., OOD task detection, Existing solutions in literature have pursued variety of Bayesian meta-learning methods 77 54
that balance between flexibility and tractability of
"ooresponddecce to Ying Wei
37th Conference on Neural Information Processing Systems (NcurIPS 2023).

---

Groun--ruth
1..0
W
-25 06
30
-25 C4
15
-50 -25
10000
(a) Incomplete OOD Coverage. EBML-CNPs (mid- dle, ours) successfully identifies OOD input with low likelihood, whereas CNPs (right) trained by
(b) Limited Expressiveness. The meta-training task distribution learned by EBML-CNPs (middle, ours)
outperforms F-PACOH-GP 4 whose prior distri-
p(yla, 6x) makes overconfidently wrong prediction.
bution is built GP.
Figure 1: Comparison of EBML and Bayesian meta-learning baselines for OOD detection.
solving the hierarchical probabilistic model p( Y (X,) = pf (Y,, (0)p()))((()))) do,d0, where T; = (X,, } represents the i-th task. 0 and Φ denote parameters of the meta-model and task- specific model, respectively. Unfortunately, these methods present some limitations in their practical usage. (1) Incomplete OOD coverage: given that the Bayesian uncertainty is trained via maximizing the posterior p(Y (X)) above, it is not necessarily high when encountering the predictive function p ,Y,; with some meta-training tasks but differs substantially in feature distributions p( X)). We verify this in Figure and Appendix D (2) Limited expressivenes:: for tractability purpose, the meta-learned prior p (2 0) predicates on simple known distributions, e.g..
OOD task that shares
Maximum A Posterior (MAP) estimation (6 [33 and Gaussian 41 43], which may struggle to
align with the complex probabilistic structure of the meta-training task distribution (see Figure lb).
This misalignment inevitably leads unreliable estimation of OOD tasks.
Upon detection of an OOD task, secondly adaptation the meta-learned prior promotes its gen- eralization this OOD task. We dub this strategy during meta-testing OOD task adaptation, which is closely related to cross-domain meta-leariing [4 [2] 34 49). The core philosophy behind cross- cross-domain meta-learning is the introduction of task-specific parameters which are inferred via either gradient descent 228 29 or feed-forward amortized encoder [42 g on the support set of each
OOD task. Learning task-specific parameters, however, is prone overfitting given the usually very limited size of support set (e.g., 5 examples only in 5-way 1-shot classification).
The limitations are further complicated by the detachment of the existing solution to OOD task detection from that to OOD task adaptation. An explicit prior model is absent in existing Bayesian meta-learning methods for OOD task detection, so that adapting the prior during meta-testing to accommodate an OOD task is ambitious to achieve. On the other hand, cross-domain meta-learning approaches by design do not offer uncertainty estimation, thereby being risky OOD task detector. Pursuing a coherent framework that supports both detection and adaptation of OOD tasks remains an open question, which motivates our proposal of novel probabilistic meta-learning framework.
By virtue of the flexibility and expressiveness of energy-based models 24 in modelling complex data distributions, we propose the Energy-Basse Meta-Learring (EBML) framework that overcomes the above-mentioned limitations. Specifically, we derive an energy-basee model to explicitly model any meta-training task distribution, resulting in the composition of an explicit prior energy function and a complexity energy function. The sum of the two energy functions, trained directly to meet the joint distribution p(X,, Y,) and parameterized with neural networks, has completeness and expressiveness advantages that give an edge in detection OOD tasks. During meta- vestantssting, we iteratively update the parameter for task that has been identified as OOD by gradient descent of energy minimization, which eventually adapts the prior towards in-distribution tasks and maximally leverages the meta-learned prior for alleviating overfitting
The key contributions of this research are outlined below. (1) Coherence and generality: we provide a coherent probabilistic model that allows both detection and adaptation of OOD tasks. Also, EBML is agnostic to meta-learning backbones, being general to secure metaa-geneallizttion for arbitrary off-the- shelf meta-learning approaches against OOD tasks. (2) Practical efficacy: we conduct experiments on three regression and one classification datasets, on which EBML outperforms SOTA Bayesian meta-learning methods for OOD task detection with an improvement of up 7% on AUROC and cross-domain meta-learning approaches for OOD task adaption with up to 1.5% improvement.
2 Related Work
Bayesian Meta-learning There has been line of literature on Bayesian meta-learning algorithms with predictive uncertainty estimation for safeguarding safety-critical and few-shot applications. Grant

---

et al. first recast gradient- gradient-based meta- meta-learning as a tractable hierarchical Bayesian inference problem. Much of the subsequent research attempts to solve the problem with various approximations. Assuming a sufficient number of meta-training tasks, almost all works use a point estimate for the initialization [1 inference and require significant computation for an ensemble of task-specific weights. Several studies that estimate the uncertainty in task-specific parameters after inner-loop adaptation have explored MAP estimates [e.g. 47), sampling from neural network [10 53 42), and variational
However, estimates of exceptions including [54] rely on SVGD [32] for
inference 7 43 The uncertainties considered in these methods are often modelled using isotropic Gaussians which suffer from limited expressiveness.
Meta-learning towards OOD Generalization Recent cross doos-d meta-learning methods [e.g. deal with distribution shift between meta-training and meta-testing tasks, by typically parameterizing deep networks with a large set of task-agnostic and a small set of task-specific weights that encode shared representations and task-specific representations for the training domains, respectively. The works of 42 34 augment a shared pre-trained backbone with task-specific FiLM 40) layers whose parameters are estimated through an encoder network conditioned on the task's s support set. TSA [28] and URL 22 propose to attach task-specific adaptors in matrix form to the pre-trained backbone at test time, inferring their parameters by gradient descent on the support set for each task from scratch. On the other hand, SUR 4 and URT [31] pre-train multiple backbones each for an ID training domain, and meta-learn an attention mechanism to selectively combine the pre-trained representations into tusk-specifir ones for ID and OOD classification. While these methods generally have improved performance in the OOD domains of tasks, they nevertheless are not designed with any explicit mechanism for detecting OOD tasks, i.e., lacking OOD awareness.
25 4
49 B.
EBMs for OOD Detection Recently, there has been increasing interest in leveraging EBMs for detecting testing samples that are OOD w.r.t. the training data distribution. Liu et al. (33] directly use the energy score for OOD input detection, while Grathwohl et al. in JEM [1] use gradient norm of the energy function as an alternative OOD score; both yield more superior OOD detection
performance than traditional density-based detection methods. There are also number of works
that investigate the OOD detection capability of hybird and latent variable EBMs [8 14 [3], and more advanced training techniques for improving the density modelling hence OOD detection performance of EBMs (5) 27 3) While all aforementioned works focus on the standard supervised and unsupervised learning scenarios, Willette et al. in [52) study OOD detection in meta-learning. However, their work differs from EBML in that (a) EBML aims to detect a meta-testing task that is OOD of the meta-training tasks whereas (52) focuses on detecting query sample that is OOD of the support samples in meta-testing task, and (b) EBML explicitly meta-learns the distribution of meta-training tasks via the two proposed EBMs and develops the Energy Sum to flag those high- energy tasks as OOD tasks; while (52) resorts to post-hoc OOD detection via energy scaling (akin to temperature scaling in softmax output) without learning any EBM. Moreover, we offer EBML as a generic and flexible probabilistic meta- meta-learning framework that supports both detection and adaptation of OOD tasks.
3 Preliminaries: Energy-based Models
An energy-based model (EBM) 24 expresses a probability density p(x) for x E RPP as
po (x()) exp(-FEg (x))
(1)
2(0)
where (x) is the energy function parametrized by 0 that maps each point x in the input space to scalar value known as the energy. Z(0) fxx exp(-Eis (x)()))s())dd (x) is the partition function that is a constant w.r.t. the variable x. Training po (x) to fit some data distribution (x(x) requires maximizing the log-likelihool L()) = (x)) llog [x)] w.r.t. 0. Though an intractable integral in Zo is
involved in this objective, it is not concern when computing the gradient K 12
VoL Ex [x))) Ex-pp [x))
(2)
Intuitively, Eqn. 2 encourages Eg to assign low energy to the samples from the real data distribution
PD while assigning high energy to those from the model distribution pg- Computing Eqn. 2 thus, requires drawing samples from pe, which is challenging. Recent approaches [12 on training EBMs
resort to stochastic gradient Langevin dynamics (SGLD) (51) which generates samples following
n72 (x*)
x ~ (x)),
x
+ 172
(3)
2
ox
3

---

The K -tstep sampling starts from an (typically uniform) initial distribution Po (x). z² ~N E a perturbation, and ry E RR controls the step size and noise magnitude. Denote the distribution qo by Eqn. (3), which signifies x' =xx <oo- When 7 -+ 0 and K -> 0o, then qo - under some regularity
conditions [51] Consequently, the gradient of Eqn. (2)
is approximated in practice A by
VoL Poy'-tto_gradllee [V Flg (x')) Rx (Vo Flg (x)],
(4)
where the gradient does not back-propagate into SGLD sampling.
4 Energy-Based Meta-learning
For clarity, we use the notation PID to denote the unknown meta- meta-training ID task distribution where the i-th training task is T. We let X, Y; to denote sets of samples {xij. Biy} in Tú, and Tü T to denote support and query sets, respectively. The size of T. T; T is denoted by N;, Nj, No. respectively. The subscript denotes the task index, and j denotes the sample index.
4.1 Energy-based Modelling of Task Distribution
As illustrated in Introduction, existing probabilistic meta-learning methods maximizing the predic- tive likelihood x) suffer from incomplete OOD coverage. To this end, we model the meta- training task distribution by (1) formulating the joint distribution pl (X;, Y.) of each task T. and (2) maximizing the likeliild of all meta- meta-training tasks. Concretely, by Kolmogorov's exten- sion and de Finncti's s theorems [22), we have the expected log-likelihood of the meta-training tasks as Ep [logp(7) [T)) - Ep (log [logp(X, YJ) = Ep, [log Jo, 11 p(xaj, Vis ())((())).))) Each p(T,) is written in factorized form over N, conditional independent distributions with Φ; being the task-specific latent variable. Due to the intractable integral over Φ; in high dimension, we resort to and learn with a lower-bound instead. This gives the ELBO
amortized inference [8] [1]
N₂ EPio ((.)) E ES ge (117)) log II p(x,,, wiy ..) -KL 1n(
I....)) (5)
Following the conventional wisdom training to align the inference procedure, i.c., Φ qu ( T?), for meta- meta-training and meta-testing. remains now to parameterize the three distributions in Eqn. (5) including (a) the task-specific data distribution p(x,j. B.)) (b) the prior latent distribution p(d,). and (c) the posterior latent distribution g. (Ø T Prior works parameterize these distributions in simple known forms, c.g., MAP estimation 6 53 which may be insufficient match the complex probabilistic structure of the meta-training task distribution. To increase the expressiveness, we turn to EBMs for parameterizing the two distributions of p(Xij- Biy (,)) and p(O,)- For one reason, EBMs are known to be sufficiently flexible and expressive for characterizing complex arbitrary density functions (3) not limiting to only uni-modal distributions like isotropic Gaussians and MAP estimation; for another, the energy function of an EBM is directly proportional to the negative big-likelhhood, paving the way for OOD detection in Section 4.2
6), qv is conditioned on the support set only during meta-
Gaussians 41
(a) Task-specific data EBM We model p(X.j, Yiy (b)) by an energy function parameterized with w,
p(xag, Mkyk. Myyl (.) pa (X:,, Mey (.)) exp( - Fx Uhi x.)))
(6)
Z(w, o.)
where En denotes the task-specific data energy function conditioned on the latent &. and Z(w, oi)) is the corresponding partition function. Note that the parameter w of this EBM is shared by all tasks.
(b) Latent prior EBM Inspired by [39]. model the prior latent distribution p(O,) ditional EBM parameterized by X; training such a EBM offers expressiveness benefits over a fixed non-informative prior distribution, e.g., isotropic Gaussian distribution. Specifically,
uncon-
p( = (x = exp( Ex (x.))) Vi.
(7)
Z())
(c) Latent posterior As many meta-learning algorithms have already carefully designated the poste- rior latent distribution go (0, T.). we simply follow the same implementation of q6 in the chosen base meta-learning algorithm, e.g., MAP estimation [8 42 [3) This design favorably empowers
EBML to be generic and flexible framework compatible with tff-the-shelf meta-learning algorithms.

---

Grounded on the above parameterization, we are now ready to derive our EBML meta-training objective as below by plugging the two EBMs defined in Eqn. (6) and Eqn. 7 into Eqn. 5 The derivation shares the spirit with Eqn. 4. and more details can be found in Appendix A.
arg max PNDD w,00A
E ge (T,1T)
(xij Ukjs Φ.) px of (/ E (X Vky, Φ,)11
(0, (T: [x(())) + (pg) [Ex( + H(qg
(8)
Solving the above meta- vretanta objective involves sampling of x', . from Pa and o' from px. in order compute the expectations (x',w"' and (pp())) as Monte Carlo averages. We follow the similar SGLD sampling procedure in Eqn. (3). Besides, since the majority of state-of-the-art 1 [33 adopt the MAP estimation of the latent posterior by which deterministic, the last entropy term of H. essentially becomes zero and the expectations in the first and second terms are trivial to solve. For this reason, we focus on base meta-learning algorithms with MAP approximation in the following sections, which not only simplifies computation but also maintains the state-of-the-art performance. We left a discussion on EBML with distributional qu in Appendix C
meta-learning algorithms [ 42
The complete pseudo codes for eeta-training of EBML are available in Appendix E
4.2 EBML for OOD Detection
Detecting an OOD task w.r.t. the meta-training dis- tribution constitutes an essential first step to guard successful meta-generalization. A straightfor- ward solution is bensity-based OOD detection, for which the OOD score task following the Bayesian principle boils down to its log-likelihood log p(X;. Y;) = llo Epp (
0.6
(P= [P=((X (X;, Y;) Moan Data sneagy
Prior Energy
0.2
0.6 Variaace
Euclidean
Despite the meta-learned latent prior EBM (λ,)) that is readily available, estimating this log- likelihood still presents daunting challenges. First, when the latent prior is expressed in the form of a distribution over model parameters in very high di- mension, MCMC sampling from px (x,, is almost computationally infeasible. Second, especially when the latent prior exhibits multi-modalin ing a considerable number of samples to achieve low-variance MC estimation of the integral is prohibitively costly.
The roles of E and Ex in En- ergy Sum in detecting OOD tasks. Each dot de- notes a task. Left: We perturb each sup- port sample of task T; by 7ij (O o;) where we sample from [0, uni- formly. The y-axis shows the average energy Exy, Mi,-Ti.m m., [Ew yf 6;)] and the axis plots the variance o²- Right: We first com- pute the mean of the overall ID task latent prior as ΦID = Eg, ( The y-axis shows the energy Ex(0ID + 77) where n, ~O 1) for the i-th task and the r-axis plots the Euclidean distance of the perturbed latent from ΦID-
Figure 2:
draw-
On this account, we define the OOD score of task to be faithful to our proposed ELBO approximation of its log- likelihihhood in Eqn. (5). which gives
NO
Eo, (b. TD I>
Ens (x,, Vi Φ.) + Ex(r.)
We dub this OOD score tailored to EBML Energy Sum, whose full derivation is deferred to Appendix A.2 This energy sum enjoys not only the theoretical advantage, i.c., being provably proportional to the negative log- ligllioel of a task, but also simple computation benefits. During meta-testing, evaluating the score of Eqn. (9) for each task requires only a single forward pass of the support set samples through the two energy functions.
More remarkably, the energy sum intuitively appealing in the sense that it characterizes (1) how far a task is from the overall ID meta-training task distribution via the latent prior energy score Ex and (2) how difficult it is to predict the observed support set conditioned on Φ; via the task-specific data energy score F.g. First, the terms in the last line of Eqn. (8) for learning the latent prior EBM altogether correspond to maximizing the likelihood E ( flo px( which enforces the latent prior energy score Ey to capture the overall ID meta-trainin training distribution. As illustrated in
5

---

Figure 2 (right), the further away a task is from the overall ID meta-trainin meta-training distribution measured in Euclidean distance, the larger the energy score E as expected. Second, conditioned on even the ID latent prior Φ; those tasks with support samples as scattered as possible are especially difficult to predict. These tasks are considered to be OOD, as evidenced in higher values of F. Figure 2 (left).
4.3 EBML for OOD Generalization
The Energy Sum proposed in Section d.2 OOD awareness of a meta-testing task, based on which we differentiate our meta-testing procedures for effective sentraeenraaiiiiion..
Meta-testing for ID tasks Given the support set T of meta-testing task, prediction of the label for its query x3 amounts to maximizing our approximated log- oogllikelhood (see Eqn. (5) of the task, i.e.,
v arg min E (p- T*) E (x) v, + Ex(+)]
(10)
Provided that the task has already been identified within the ID region, the second energy (x) is negligibly small. Consequently, we reduce the above optimization problem consider only the first term E (x), y, Φ), and solve it via gradient descent. We provide the pseudo codes in Appendix E
Meta-testing for OOD tasks For an OOD task, its meta-learned prior & ~ go (x) T*) is located out of the ID meta-training task distribution and likely loses its effectiveness. We seek solution that adapts this inadequate meta-learned prior back to the ID region, so as to make the most of the ID latent priors with guaranteed metaagenerallzattin. This shares the idea with classifier editing in (45), where the editing parameters are trained to map an OOD image to an ID one for improving generalization. Therefore, we introduce task-specific parameters Ç which are optimized via the following,
N
arg min EE Bo cc0) T*)
Σ
E (x), V/, + max max m, O)],
(11)
where m is a hyper- parameter. We find that setting m as the empirical average of the latent prior energy over all ID training tasks works well in practice, i.c., m Epro p (s (0..1 (T)) (xx)))
As result of optimizing the second term in Eqn. (1I. the task-specific parameters enable qouç T to accommodate for OOD tasks by mapping the meta-learned prior back ID meta- training tasks; while optimizing the first term preserves the data-level predictive ability of the model. We highlight that the task energy mini- mization approximates the minimization of a KL divergence between the task-specific posterior and the meta-learned prior. thereby inducing meta- regularization effect during adaptation. See Ap- pendix A.3 for details. Eventually, we use the adapted task task-specific parameters for final predic- tion on query samples as in Eqn. (TOp. Pseudo code for the EBML adaptation and inference al algorithms described above can be found Appendix F
655
(2)
Enwry
CO0 Aciegaationnnnn Slep
Figure 3: Illustaaioon of the OOD task adap- tation process OOD domains of the meta- dataset [49] where each dot in (a) represents an OOD task in latent space Φ. Minimizing Eqn. (II) leads to (a) the latent &i of the OOD task moving to the ID region (contour plot), (b) the Euclidean distance between class prototypes enlarging, and consequently (c), the classifica- tion accuracy on query samples increasing.
In Figure we visualize the adaptation process when optimizing Eqn. (T)) for OOD few-shot clas- sification tasks in Meta-dataset [4).. As the prior energy of these OOD tasks decreases, their Φ; gradually shift towards the ID region as desired. Within this region, minimizing the first term in Eqn. (TI) continuously improves generalization. In contrast, given only a few support samples, existing SOTA methods that solely rely on ford-forward inference [ and gradient-basee optimization (28) for OOD task adaptation without prior are both prone to overfitting. We provide more empirical evidence on this Appendix C On the other hand, meta-learning a BNN, which imposes a prior distribution on the parameter space during adaptation may be computationally cumbersome and often lead to sub-optimal performance in comparison to their non non-Bayesian counterparts.

---

5 Experiments
In the experiments, we test EBML on both few-shot regression and image classification tasks in search for answers to the following key questions: RQI: Whether the improved expressiveness of EBML over traditional Bayesian meta-learning methods can lead to a more accurate model of the meta-training ID task distribution, hence a more reliable OOD task detector. RQ2: Whether Energy Sum can be an effective score for detection of OOD meta-testing tasks. RQ3: Whether EBML instantiated with SOTA algorithms can exploit the meta-learned EBM prior in OOD task adaptation to achieve better prediction performance on OOD tasks.
5.1 Implementation Details
We now discuss two instantiations of the EBML framework with SOTA meta-learning algorithms for regression and classification. We illustrate our approach in Figure 4 below and defer more detailed description for our models to Appendix B
Data Energy
Prodiction
Fu eatitlyy PapDiiing
Aky
Cardinll
Fastus Extrantor
>
Faym tww.
Dechion boundory Foy
Classter
Averium
Task Energy
Appés)
Latest
Prior
ID Task
Enengy
OCO Task
Figure 4: Overview of the EBML framework. The task latent variable Φ is inferred from the support set T following the implementation of the base algorithm. The data and task energy scores evaluated by the data and prior EBMs F.,, and Ex, respectively; while the query labels are predicted by the classifier Pag of the base algorithm.
Regression. Take CNPs 8 as an example base model. CNPs implements (Ø, TT;) as neural network encoder that outputs a function embedding finite vector form, i.e., Φ; E D from given support set, Tİ That said, we let the prior EBM to model the empirical distribution over such finteeddimension function embedding, i.e., Ex (o))) RD. R.
Classification Many cross-domain few-shot classification algorithms 28
rely on a metric- 42
based classifier for prediction, which assigns query sample to the class with nearest prototype to the query representation based on some distance measure. In these cases, it is natural to specify the task-specific latent Φ; as the set of class prototypes in each ID training task. Since &; set of variables, we build the prior EBM model as permutation-invariinn neural network function. Suitable choices include DeepSets [66] and set transformer 26
To align with the state-of the-ah art prediction performance, we follow the practice in 50 37 to train another decoder w2 with the loss function (e.g.. cross entropy) in the base meta-learning model, which We use this decoder for prediction.
serves as a surrogate for F. (1'. y, Φ) in Eqn. (10) and Eqn. [T]
Baseline Models For regression, we compare against: MAML 66 which is deterministic meta- learning method, and 2) Bayesian meta-learning methods that use Gaussians for prediction or prior, including ABML [41. MetaFun [53], CNPs [8] and F-PACOH-GP [43) For classification, we con- sider Simple-CNAPP I and TSA [28 which respectively resort to amortized variational inference and gradient-based optimization for estimating the task-specific parameters from the support set. Both are SOTA cross-domain few-shot classification approach on the Meta-dataset A benchmark. For more experimental details, hyper-parameter configurations, and additional experimetal results,
please refer to Appendix B and
7

---

5.2 Datasets and Evaluation Metrics
Sinusoids Few-shot Regression We consider 1D sinusoids regression tasks in the form yf(x)) Asin B(x+C)) For ID meta-training we consider frequency B = 1, while sample amplitude A and phase C uniffrrlyy from a set equally-spaced points [1,1.1, 1.2,............ .... 4} and {0, 0.1, ..., 0.5T); respectively. Each training task consists of 2 to 5 support and 10 query points with uniformly sampled from X E [-5.0, 5.0]. During testing, we evaluate the models on 500 ID and OOD tasks each with 512 ciual-distant query points in X. For ID testing,
expand the range of the tasks by uniformly sampling A E [1, 4] and C E [0, (..m. For OOD tasks, we randomly change either the phase distribution to C' E [0.6T, 0.75T], amplitude to A e [0.1, 0.8] U [4.2, 5.0j or frequency to B E [1.1, 1.25]. Details for the multi-sinusoids regression experiment can be found in C.1 We use MSE and negative log-likelihood on query samples to evaluate the regression performance.
Drug Activity Prediction Few-shot Regression In each task, we aim to predict the drug-target binding affinity of query molecular compounds given 10 to 50 labelled examples from the same domain defined by molecular size. We use the (bap-general-ic50--
ID/OOD task split in the DrugOOD 21 benchmark, which divides the molecules into 222/145, /14//23 domains by molecular size for Train / ID Test / OOD Test, respectively. The regression performance is evaluated by the square of Pearson coefficient (R?) between predictions and the ground-true trrnh values. We report the mean and median R2 on 500 tasks sampled from ID and OOD testing domains.
5-way 1-shot Classification This experiment considers image classification problems on Meta-dataser [49 Each task contains up to 10 query images per class from the same domain. Following the current state-of-the-an art practice [28] I. we use Aircraft, dtd, cub, rgg-flower, fungi, quickdraw and omniglot as the ID datasets for meta-training and meta-testing, while traffic, mscoco, cifar cifar100 and mnist are treated as OOD datasets for meta-testing only.
Meta-dataset 49
OOD Task Detection Evaluation We compare the OOD task detection performance of Energy OOD detection baselines. Concretely, for classification, we compare against max-softmax score [16,, ODIN (30). MAH (27). and max-logits score [15); for regression, we consider Averaged Bayesian prediction uncertainty in standard deviation (Std) on support samples, and Averaged Support samples Negative Log-Likelihood (SNLL) under model's task-specific predictive probability, i.e., E (o. (l,loogP.. (v.y Imig Φ:]1] for baselines and
Sum against several
Es, "0,( IT?) [Ew (vīy, m Φb)]] for EBML. Following common practice [I7 [6], we report
AUROC, AUPR and FPR95 for OOD detection performance. Details for these metrics can be found in Appendix B.I
5.3 OOD Detection Results
Energy sum performs best in OOD task detection. Table 1 and The proposed energy sum further improves our SNLL-only results in all three OOD detection metrics with 15.2% and 11.8% significant reduction in FPR95, outperforming the best baseline methods by 20.0% and 39.1 19,1% in single and multi-sinusoids situations respectively. In Table for OOD classification task detection, Energy Sum consistently results in superior OOD detection performance, outperforming the best baselines by large margins of 36.84% and 20. 19% in FPR95 for Simple- CNNPs and TSA, respectively.
Table 1: OOD task detection performance on single-sine and DrugOOD 21 few-shot regression tasks.
Sinusoids
DrugOOD
OOD Scores
Models
AUROCT
AUPR
FPR95
AUROC
AUPR
FPR95,
ABML 41
50.14
$4.80
97.20)
57.82
50.31
74.80
F-PACOH-GP
43
49.52
$1.30
94,20
81.74
71.99
32.00
Std
CNPs
22.72
35.34
99.60
93.56
89.58
13.00
Metafun 5
76.57
80.33
82,40
85.68
80.55
58.18
ABML 41
82.48
81.31
61.00
80.99
79.12
47.60
E-ACCOH-GP
91.78
93.23
52.40
37.73
45.01
85.21
SNLL
CNPs 8
95.63
96.46
34.22
17.25
34.07
91.40
Metafun 53:
96.25
97.11
32.00
83.54
85.54
65.17
EBML- CNPPs (Ours)
96.46
97.41
99.71
99.71
2.20
Energy Sum
EBMI (Ours)
97.74
14.20
99.79
99.78
1.40
8

---

Modelling the joint distribution improves OOD detection under Domain-shift. In Table [ DrugOOD regression tasks, using either our SNLL or Energy Sum as OOD scores can achieve better detection performance than baselines. In particular, our method outperforms the best OOD detection results obtained using Gaussian SNIL and Std by 43.84% and 11.6% in FPR95, respectively.
Qualitative Illustration. In Figure 5 we visualize the predictive distribution p(yig Xajo Φ;) learned us- ing an EBM decoder and a Gaussian decoder on a sampled ID multi-sinusoide task. The EBM clearly shows two prediction modes at all non-overla positions, whereas the Gaussian decoder is unable to model the multi modii-modality, resulting in blurry prediction.
Task
Figure 5: Predictive distribution of Middle an data EBM Right a Gaussian for an ID task.
Computational Complexity Analysis. We conduct a computational complexity analysis for EBML by comparing its wall-clock training time and convergence baselines in LigureBbbeloe EBML- CNPs eventually achieves better OOD detection performance than baseline CNPs meanwhile match- ing its regression performance all training epochs. In Table T3 Appendix C.4 show EBML- CNPs is computationally cheaper and faster than traditional Bayesian methods, namely, F-PACOH- which requires matrix inversion for inference with Gaussian processes prior, and ABML which imposes a Gaussian prior over the entire parameter space of the model.
GP 4
41
AAAUROCH+ AURI- 1PR05
EBML-CNPS
0.5
3.21
611
3.53
seconds
Figure 6: Left: Wall-clock convergence in seconds, and Right: performance vs number of training epochs, for EBML-CNPs vs CNPs in single-sinosoid few-shot regression tasks. The plots show the regression (MSE 4) and combined OOD tasks detection (1 (I-AUROC)(11- (1-AU(())))PRRRR))) performance on single sine few-shot regression tasks during training. Curves are moving averages with window size 3. EBML-CNPs achieves better final performance than CNPs.
Energy sum achieves better OOD detection results with EMB prior than Gaussian. In Table and we investigate the contribution the prior EBM in improving the modelling of meta- meta-training task distribution. We train CNPs and ABML using diagonal Gaussian distribution as the prior in ELBO, and compute OOD scores as (a) SNLL,, and (b) the sum between SNLL and the NLL of task-specific latent evaluated under the learned Gaussian prior (indicated by +Gauss Prior). The results show that energy sum using an EBM prior outperforms all ablated models. The OOD detection performance of our model benefits from adding the prior EBM energy to the data EBM energy (SNLL), resulting in the most reduction in FPR95 on both single and multi-sinusoids tasks (15.2% and 11.8%, respectively). This suggests the improved expressive of EBM over simple distributions can indeed lead to learning a more accurate model of the meta meta-training training ID task distribution.
Energy sum achieves better OOD detection results when learning the joint distribution In Table 16, we compare EBML-joint, which exactly our proposed training procedure in the paper,
Table 2: OOD task detection performance on Meta-dataset 5-way 1-shot classification tasks.
Table 3: Ablation study on Energy Sum for OOD detection on single-sinusoids.
Simpplo-CAAPs
25
Medele
Sinuselds
AUROCT
AUPRI
IPR955
ALBOCT
FPR95
AUROC
ALPRR
FPRM5.
ABML 31
SNLL
+Dama Price
$6.95
$2.48
$1.31
50.04
61.00
52.20
10
71.18
43.57
90.52
92.02
94.54
23.83
CNPs
SNLL
+iann Price
90.61
94.81
96.10
96.34
34.00
38.40
53.17
n/
n/a
BBML Energy Sum
97.01
94.92
6.74
99.10
95.45
3.64
PRIe
97.74

---

Table Few-shot regression performance on single-sinusoids and DrugOOD 21 tasks.
Sinusoids
DrugOOD
Models
ID MSE
ID Mcan 1?2
ID Median 1t2
OOD Mean 1
0OD Median lt*
E-PACOH-GP 43
0.068
0.492
0.454
0.055
0.027
Metafun
0.009
0.537
0.541
0.054
0.027
CNPs g
0.009.0.002
0,540
0.549
0.066
0.046
ABML [4]
0,.2710.013
0.452
0,443
0.051
0.029
MAML
6
0.119
0.462
0.475
0.055
0.024
EBML CCPss EBML-CNPs
a.009
0.533
0.553
0.071
0.043
X) and EBMLL-condtiioall, which follows the same training with EBML-joint but models p( Y instead of p(X, Y). With all other factors being the same, EBML-joint significantly outperform EBMLL-conditionll in OOD detection on DrugOOD regression tasks with domain shift in X. This supports our motivation for using the joint distribution instead of the conditional distribution for training a potentially better OOD detector. Detail of this ablation study can be found in Appendix
5.4 OOD Generalization Results
EBML achieves SOTA regression performance. In Table 4 for single-sinusoids, EBML is able to match the MSE of the best-performing baseline methods; while on multi-sinusoids in Table 7 EBML obtains the lowest ID NLL, specifically 0.58 lower than the best baseline, thanks our onergy-based decoder which is sufficiently expressive for modelling the multi- modality at each input.
Table 5: Classification performance on 5-way 1-shot tasks for both II) and OOD domains in Meta-dataset.
TSA 28
EBML-TTA
Datusets
(Ours)
Omniglot Textures
98. 63 a6
98.67 20.67
51,93=s0
52.35
Task adaption using Eqn. improves few-shot classifica- tion performance. In Table 5 report the average classifi- cation accuracy computed over 600 test tasks per ID and OOD domains. In meta-testing, EBML-TSA by running gradient descent on the objective in Eqn. (T) to optimize the task-specific modules in TSA from scratch. With this addition of prior energy in the OOD adap- tion objective, EBML-TSA further improves TSA results in 5/7 ID domains and all 5 OOD domains. Additional OOD classification results in Table [T Appendix further confirm the superiority of our proposed OOD task adaptation strategy Eqn. (T] over prior baselines.
Aircraft
78.91
78.4720.80
Birds
75.00 75.02:0.00 00
75.52:t0.90
VGG Flower
80.37
80.30.20.3
Fungi
70.89=00. as
72.29 0..94
obtain classification results for
Quickdraw
79.02 79.02:00.4 84
80.27 0.886
MSCOCO
52.28
53.03
Traffic Sign
57.40::0.a 94
58.85
CIFARIO CIFAR100 MNIST
19.16=0.55
50.04::0.90
62.25=11
62.77=1.00
74.72:0.8s
76.08 0.998
Avg
76.40
76.84
Avg OOD
59.16
60.15
Avg All
69.22
69.89
Conclusion and Limitation
This paper proposes
energy- baaee meta-learnigg (EBML) framework for the first time, which directly characterizes any arbitrary meta-training task distribution using two data and prior energy functions. EBML is compatible with many existing SOTA meta-learning algorithms and allows both detection and adaption of OOD tasks. The sum the two learned energy functions gives an unnormalized probability distribution proportional to the underlying task likelihood, deployable as OOD scores. The experiment results show the superiority of Energy Sum over traditional methods in detecting both OOD regression and classification tasks, and the possibility of achieving improved OOD adaptation performance with EBML through minimizing the task energy. One limitation of EBML is that our current OOD task adaptation strategy does not consider the effect of negative transfer, as some OOD tasks may benefit from adaptating from scratch without ID energy prior regularization. Thus, future works, we are interested in designing task -peeifi adaptation strategies for EBML that can selectively adapt OOD tasks for better performance.
10

---

References
[1] Peyman Bateni, Raghav Goyal, Vaden Masrani, Frank Wood, and Leonid Sigal. Improved few-shot visual classification. In Proceedings of the IEEE/CVE Conference on Computer Vision and Pattern Recognition (CVPR), June 2020.
[2] Yilun Du, Shuang Li, Joshua Tenenbaum, and Igor Mordatch. Improved Contrastive Divergence Training of Energy-Based Models. In Proceedings of the 38th International Conference on Machine Learning, pages 2837-2848. PMLR, July 2021. ISSN: 2640-3498.
[3] Yilun Du and Igor Mordatch. Implicit Generation and Modeling with Energy Based Models. In Advances Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019.
[4] Nikita Dvomikk Cordelia Schmid, and Julien Mairal. Selecting relevant features from multi- domain representation for few-shot classification. In European Conference on Computer Vision, 2020.
[5] Sven Elflein, Bertrand Charpentier, Daniel Zügner, and Stephan Günnemann. On Out-of- distribution Detection with Energy-based Models. page 13.
[6] Chelsea Finn, Pieter Abbeel, and Sergey Levine. Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networks. In Proceedings of the 34th International Conference on Machine Learning, pages 1126-1135. PMLR, July 2017. ISSN: 2640-3498.
[7] Chelsea Finn, Kelvin Xu, and Sergey Levine. Probabilistic model-agnostic meta-learning. In Proceedings of the 32nd International Conference on Neural Information Processing Systems, NIPS'18 18, page 9537-9548, Red Hook, NY, USA, 2018. Curran Associates Inc.
[8] Marta Garnelo, Dan Rosenbaum, Christopher Maddison, Tiago Ramalho, David Saxton, Murray Shanahan, Yee Whye Teh, Danilo Rezende, and S. M. Ali Eslami. Conditional neural processes. In Jennifer Dy and Andreas Krause, editors, Proceedings of the 35th International Conference on Machine Learning, volume 80 of Proceedings of Machine Learning Research, pages 1704-1713. PMLR, 10-15 Jul 2018.
[9] Marta Garnelo, Jonathan Schwarz, Dan Rosenbaum, Fabio Viola, Danilo J. Rezende, S. M. Ali Eslami, and Yee Whye Teh. Neural Processes. Technical Report arXiv: 180.001222 arXiv, July 2018. 1XXiv1187.001222 [cs, stat] type: article.
[10] Jonathan Gordon, John Bronskill, Matthias Bauer, Sebastian Nowozin, and Richard Turner. Meta-learning probabilistic inference for prediction. In International Conference Learning Representations, 2019.
[11] Erin Grant, Chelsea Finn, Sergey Levine, Trevor Darrell, and Thomas Griffiths. Recasting gradient-based meta-lcarning as hierarchical bayes. In International Conference on Learning Representations, 2018.
[12] Will Grathwohl, Kuan-Chich Wang, Joem--Herrik Jacobsen, David Duvenaud, Mohammad Norouzi, and Kevin Swersky. Your classifier is secretly an energy based model and you should treat it like one. In International Conference on Learning Representations, 2020.
[13] Will Sussman Grathwohl, Jacob Jin Kelly, Milad Hashemi, Mohammad Norouzi, Kevin Swersky, and David Duvenaud. No [memc] for me: Amortized sampling for fast and stable training of energy- based models. In International Conference on Learning Representations, 2021.
[14] Tian Han, Erik Nijkamp, Linqi Zhou, Bo Pang, Song-Chun Zhu, and Ying Nian Wu. Joint Training of Variational Auto Encoder and Latent Energy- -aasdd Model. In 2020 IEEE/CVF Conference Computer Vision and Pattern Recognition (CVPR), pages 7975-7984, Seattle, WA, USS, 2020. IEFE.
[15] Dan Hendrycks, Steven Basart, Mantas Mazeika, Mohammadreza Mostajabi, Jacob Steinhardt, and Dawn Xiaodong Song. Scaling outto--distiibttion detection for real-world settings. In International Conference on Machine Learning, 2022.

---

[16] Dan Hendrycks and Kevin Gimpel. A baseline for detecting misclassified and out-of dissrribbution examples in neural networks. Proceedings of International Conference on Learning Represen- lations, 2017.
[17] Dan Hendrycks, Mantas Mazeika, and Thomas Dietterich. Deep anomaly detection with outlier exposure. In International Conference on Learning Representations, 2019.
[18] Shion Honda, Shoi Shi, and Hiroki R. Ueda. Smiles transformer: Pre-trained molecular fingerprint for low data drug discovery. 2019.
[19] Ekaterina lakovleva, Jakob Verbeek, and Karteek Alahari. Meta-learning with shared amortized variational inference. In ICML, pages
PMLR, 2020.
[20] Sergey Ioffe and Christian Szegedy. Batch normalization:
Accelerating deep network training by reducing internal covariate shift. In Francis Bach and David Blei, editors, Proceedings of the 32nd International Conference on Machine Learning. volume 37 of Proceedings of Machine Learning Research, pages 448-456, Lille, France, 07-09 Jul 2015. PMLR.
[21] Yuanfeng Ji, Lu Zhang, Jiaxiang Wu, Bingzhe Wu, Long- Kai Huang, Tingyang Xu, Yu Rong. Langing Li, Jie Ren, Ding Xue, Houtim Lai, Shaoyong Xu, Jing Feng, Wei Liu, Ping Luo, Shuigeng Zhou, Junzhou Huang, Peilin Zhao, and Yatao Bian. DrugOOD: (OOD) Dataset Curator and Benchmark for Al-aided Drug Discovery A Focus on Affinity Prediction Problems with Noise Annotations. arXiv:2201.0966 09633 [cs, q-bio], January 2022. arXiv: 2201.09637.
[22] Achim Klenke. Probahility theory: comprehensive course. Springer Science Business Media, 2013.
[23] Pang Wei Koh, Shiori Sagawa, Henrik Marklund, Sang Michael Xie, Marvin Zhang, Akshay Balsubramani, Weihua Hu, Michihiro Yasumaga, Richard Lanas Phillips, Irena Gao, et al. Wilds: A benchmark of wn-the-wild distribution shifts. International Conference on Machine Learning, pages 5637-5664. PMLR, 2021.
[24] Yann LeCun, Sumit Chopra, Raia Hadsell, Mare' Aurelio Ranzato, and Fu Jie Huang. Tutorial on Energy-Based Learning. page 59, 2006.
[25] Hae Beom Lee, Hayeon Lee, Donghyun Na, Saehoon Kim, Minseop Park, Eunho Yang, and Sung Ju Hwang. Learning to balance: Bayesian meta-learning for imbalanced and out-of- distribution tasks. In International Conference on Learning Representations, 2020.
[26] Juho Lee, Yoonho Lee, Jungtaek Kim, Adam Kosiorek, Seungjin Choi, and Yee Whye Teh. Set transformer: A framework for attention- permutation-invariat neural networks. In Proceedings of the 36th International Conference on Machine Learning, pages 3744-3753, 2019.
[27] Kimin Lee, Kibok Lee, Honglak Lee, and Jinwoo Shin. A Simple Unified Framework for Detect- ing Out-of-Distributtion Samples and Adversarial Attacks. Advances in Neural Information Processing Systems, volume 31. Curran Associates, Inc., 2018.
[28] Wei-Hong Li, Xialei Liu, and Hakan Bilen. Cross-domain few-shot learning with task-specific adapters. 2022 IEEF/CVE Conference on Computer Vision and Puttern Recognition (CVPR), pages 7151-7160, 2021.
[29] Wei-Hong Li, Xialei Liu, and Hakan Bilen. Universal representation learning from multiple domains for few-shot classification. 2021 IEEE/CVF International Conference on Computer Vision (ICCV), pages 9506-9515, 2021.
[30] Shiyu Liang, Yixuan Li, and R. Srikant. Enhancing the reliability of out-of-distribution image detection in neural networks. In International Conference Learning Representations, 2018.
[31] Lu Liu, William Hamilton, Guodong Long, Jing Jiang, and H. Larochelle. A universal represen- tation transformer layer for few-shot image classification. ArXiv, abs/2006. 11702, 2020.
12

---

[32] Qiang Liu and Dilin Wang. Stein Variational Gradient Descent: A General Purpose Bayesian Inference Algorithm. In Advances Neural Information Processing Systems, volume 29. Curran Associates, Inc., 2016.
[33] Weitang Liu, Xiaoyun Wang, John Owens, and Yixuan Li. Energy-based Out-of-distribution Detection. In Advances in Neural Information Processing Systems, volume 33, pages 21464 2 21475. Curran Associates, Inc., 2020.
[34] Yanbin Liu, Juho Lee, Linchao Zhu, Ling Chen, Humphrey Shi, and Yi Yang. A Multi- Mode Modulator for Multi-Domain Few-Shot Classification. In 202/ IEEE/CVF International Conference on Computer Vision (ICCV), pages 8433-8888 043-8442, Montreal, QC, Canada, October
2021. IEEE.
[35] Shuai Luo, Yujie Li, Pengxiang Gao, Yichuan Wang, and Seiichi Serikawa. Meta-seg: A survey of meta-learning for image segmentation. Putlern Recognition, page 108586, 2022.
[36] Sewon Min, Mike Lewis, Luke Zettlemoyer, and Hannaneh Hajishirzi. Metaicl: Learning to learn in context. In Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, pages 2791-2809, 2022.
[37] Yifei Ming. Ying Fan, and Yixuan Li. Poem: Out-of-distribution detection with posterior sampling. In International Conference on Machine Learning. PMLR, 2022.
[38] Bo Pang, Tian Han, Erik Nijkamp, Song-Chun Zhu, and Ying Nian Wu. Learning Latent Space Energy-Based Based Prior Model. In Advances in Neural Information Processing Systems, volume 33, Curran Associates, Inc., 2020.
pages 21994-22008.
[39] Bo Pang, Tian Han, Erik Nijkamp. Long-Chun Zhu, and Ying Nian Wu. Learning Latent Space Energy-Based Prior Model. In Advances in Neural Information Processing Systems, volume 33, Curran Associates, Inc., 2020.
pages 21994 22008.
[40] Ethan Perez, Florian Strub, Harm de Vries, Vincent Dumoulin, and Aaron C. Courville. Film: Visual reasoning with a general conditioning layer. In AAAI, 2018.
[41] Sachin Ravi and Alex Beatson. Amortized bayesian meta-learning. International Conference on Learning Representations, 2019.
[42] James Requeima, Jonathan Gordon, John Bronskill, Sebastian Nowozin, and Richard E Turner. Fast and flexible multi-task classification using conditional neural adaptive processes. In H. Wallach, H. Larochelle, A. Beygelzimer, F. dÁlché-Buc, E. Fox, and R. Garnett, editors, Advances in Neural Information Processing Systems 32, pages 7957-7968. Curran Associates, Inc., 2019.
[43] Jonas Rothfuss, Dominique Heyn, Jinfan Chen, and Andreas Krause. Meta-learning reliable priors in the function space. In Advances in Neural Information Processing Systems, volume 34, 2021.
[44] Victor Sanh, Albert Webson, Colin Raffel, Stephen Bach, Lintang Sutawika, Zaid Alyafeai, Antoine Chaffin, Arnaud Stiegler, Arun Raja, Manan Dey. et al. Multitask prompted training enables zero-shot task generalization. In International Conference on Learning Representations, 2022.
[45] Shibani Santurkar, Dimitris Tsipras, Mahalaxmi Elango, David Bau, Antonio Torralba, and Aleksander Madry. Editing a classifier by rewriting its prediction rules. Advances in Neural Information Processing Systems, 34:23359-2333 2021.
[46] Amrith Setlur, Oscar Li, and Virginia Smith. Two sides of meta-learning evaluation: In vs. out of distribution. In A. Beygelzimer, Y. Dauphin, P. Liang, and J. Wortman Vaughan, editors, Advances in Neural Information Processing Systems, 2021.
[47] Zhuo Sun, Jijie Wu, Xiaoxu Li, Wenming Yang, and Jing-Hao Xue. Amortized bayesian proto- type meta-learning: A new probabilistic meta-learning approach to few-shot image classification. In International Conference on Artificial Intelligence and Statistics, pages 1414-1422. PMLR,
2.21.
13

---

[48] Sebastian Thrun and Lorien Pratt. Learning to learn. Springer Science & Business Media, 2012.
[49] Eleni Triantafillou, Tyler Zhu, Vincent Dumoulin, Pascal Lamblin, Utku Evci, Kelvin Xu, Ross Goroshin, Carles Gelada, Kevin Swersky, Pierre-Antoine Manzagol, and Hugo Larochelle. Meta-dataset: A dataset of datasets for learning to learn from few examples. In International Conference Learning Representations, 2020.
[50] Haotao Wang, Aston Zhang, Yi Zhu, Shuai Zheng, Mu Li, Alex Smola, and Zhangyang Wang. Partial and asymmetric contrastive learning for ont-of-ddsstibution detection in long-tailed recognition. In International Conference on Machine Leurning, pages 23446-23458, 2022.
[51] Max Welling and Yee Whye Teh. Bayesian learning via stochastic gradient langevin dynamics. In Proceedings of the 28th International Conference on International Conference on Machine Learning, ICML'11, 11, page 681-688, Madison, WI, USA, 2011. Omnipress.
[52] Jeffrey Ryan Willette, Hae Beom Lee, Juho Lee, and Sung Ju Hwang. Meta learning low rank covariance factors for energy based deterministic uncertainty. In International Conference Learning Representations, 2022.
[53] Jin Xu, Gean-Francois Ton, Hyunjik Kim, Adam Kosiorek, and Yee Whye Teh. Metafun: Meta-leaming with iterative functional updates. In International Conference on Machine Learning (ICML), 2020.
[54] Jaesik Yoon, Taesup Kim, Ousmane Dia, Sungwoong Kim, Yoshua Bengio, and Sungjin Ahn. Bayesian Monsl-Agnostic Meta-Leamning. In S. Bengio. H. Wallach, H. Larochelle, K. Grauman, N. Cesa- Desa-Bianchh, and R. Garnett, editors, Advances in Neural Information Processing Systems, volume 31. Curran Associates, Inc., 2018
[55] Tianhe Yu, Deirdre Quillen, Zhanpeng He, Ryan Julian, Karol Hausman, Chelsea Finn, and Sergey Levine. Meta-world: A benchmark and evaluation for multi-task and meta reinforcement learning. In CoRI, pages 1094-1100, 2020.
[56] Manzil Zaheer, Satwik Kottur, Siamak Ravanbakhsh, Barnabas Poczos, Russ R Salakhutdinov, and Alexander Smola. Deep Sets. In I. Guyon, U. Von Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, Advances Neural Information Processing Systems, volume 30. Curran Associates, Inc., 2017.
[57] Yang Zhao, Jianwen Xie, and Ping Li. Learning Energy-Based Generative Models via Coarse- to fo-Fine Expanding and Sampling. February 2022.
14


Reviews:
[{"review_id": "C5bjBUrIjH", "reviewer": "Reviewer_Ghnn", "summary": "This paper addresses the problem of meta-learning on out-of-distribution (OOD) tasks and proposes a solution to improve the generalization capability of meta-learned prior knowledge in safety-critical applications. The paper introduces an energy-based coherent probabilistic model that enables both detection and adaptation of OOD tasks. The proposed Energy-Based Meta-Learning (EBML) framework outperforms state-of-the-art Bayesian meta-learning methods in OOD task detection and cross-domain meta-learning approaches in OOD task adaptation.", "questions": "Please refer to the weakness", "limitations": "The paper discussed about the limitation.", "rating": 5, "confidence": 3, "soundness": 3, "presentation": 3, "contribution": 2, "strengths": "1. **Coherence and Generality**: The EBML framework offers a coherent model that supports both the detection and adaptation of OOD tasks, providing a general solution against OOD tasks for any off-the-shelf meta-learning approach.\n2. **Experimental Support:** The paper showcases empirical validation of the EBML framework, demonstrating its superior performance over other methods on multiple regression and classification datasets.", "weaknesses": "While the paper presents an innovative application of energy-based models for out-of-distribution (OOD) task generalization and detection in meta-learning, it could benefit from a more detailed exploration of its unique contributions. Energy-based models are widely used in areas such as OOD generalization and detection. Therefore, distinguishing the specific merits of the Energy-Based Meta-Learning (EBML) framework would help elucidate its contribution to the field. The authors could potentially solidify their work's significance by providing an in-depth comparison with other techniques, or illustrating how their approach uniquely addresses challenges inherent to OOD tasks in meta-learning. This could illuminate the distinct importance of their work in this vibrant field.\n[1] Energy-based Out-of-distribution Detection, NeurIPS\n[2] Active Learning for Domain Adaptation: An Energy-based Approach, AAAI", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "We sincerely appreciate your constructive comments to improve our paper. We detail our response below point by point. Please kindly let us know if our response addresses the questions you had for this paper.\n\n##### On how EBML uniquely addresses the challenges inherent to OOD tasks in meta-learning.\n\n> - In conventional sample-level OOD detection, measuring the OODness boils down to **(1)** modelling of the ID distribution and **(2)** evaluation of the likelihood that the to-detect sample belongs to the ID distribution. EBM has shown its superiority in **(1)** flexibly modelling the ID distribution and **(2)** deducing the energy score as a principled but simple OOD measure. \n> \n> - Disparate from OOD detection of samples that are **in fixed dimension**, detection of an OOD task **as a variable set of samples** poses the following **two inherent challenges**.\n>   \n>   - **(1)** Modelling the ID distribution over sets requires both flexibility in handling sets in varying cardinalities and expressiveness in capturing the set-level property of a set. Thus, a direct application of EBM via naive aggregation of samples within a task, ignoring the sample variance and failing to fully meet the second requirement, is inadequate. \n>   \n>   - **(2)** The likelihood of a task belonging to the ID task distribution involves comparison between a set and a set distribution and reduces to calculating the set distance which is widely accepted more complicated than sample distance.\n> \n> - To address the above two challenges, EBML uniquely\n>   \n>   - **(1)** derives two novel EBMs to jointly model the ID task distribution, including a latent prior EBM and a task-specific data EBM.\n>     \n>     - Latent prior EBM is an energy function of the prior, which describes a task in the **fixed latent representation space regardless of the cardinality** and correlates with **the distance of a task from the ID distribution** (see Fig. 2 right). \n>     \n>     - Task-specific data EBM is an energy function of the observed support set conditioned on its prior, correlated with **the variance of samples in a task** (see Fig. 2 left). \n>   \n>   - **(2)** introduces the Energy Sum as an effective OOD task detection score, which \n>     \n>     - has been proved exactly **proportional to the likelihood of a task** (see Appendix A.2),\n>     \n>     - evaluates the above two aspects, i.e., distance and variance, and\n>     \n>     - enjoys empirical **superiority over the scores for OOD sample detection** (adapted by averaging scores of the samples in a task, see Table 2).\n> \n> - Furthermore, EBML is more than just an OOD task detector in meta-learning; it improves generalization to OOD tasks in meta-learning via the proposed adaptation strategy in Eqn. (11).\n\n##### Comparison between EBML and [1,2]\n\n> - Both [1] (i.e., [35] in our main text) and [2] investigate the application of EBMs in **either** OOD sample detection **or** active domain adaptation, so that they do not face the aforementioned two challenges **inherent to OOD tasks in meta-learning**. \n> \n> - We will definitely follow the reviewer's great suggestion to improve the paragraph of \"EBMs for OOD Detection\" in Section 2, by \n>   \n>   - detailing the abovementioned unique contributions of EBML in detecting OOD tasks,\n>   \n>   - including [2] which first queries unlabeled target samples by the difference between the minimum and the second minimum energies and then aligns the free energies of selected target samples with those of source ones. Thus, the EBM in [2] still models the distribution over **samples** for sampling, instead of over **sets** in our work.\n> \n> [1] Energy-based Out-of-distribution Detection, NeurIPS 2020\n> [2] Active Learning for Domain Adaptation: An Energy-based Approach, AAAI 2022\n"}, {"review_id": "YmOGuGqNXP", "reviewer": "Reviewer_u8ca", "summary": "The paper deals with the problem of detecting and adaptation of out-of-distribution (OOD) tasks in the meta-learning algorithms. Recent solutions adapt Bayesian meta-learning methods which have certain limitations in terms of complete coverage of OOD tasks and based on known probability distribution that may not express complex probabilistic structure of the meta-training task distribution. Moreover, cross-domain meta-learning algorithms may adapt the OOD tasks but they are not a good estimator for OOD tasks detector. Given these limitations, the authors propose an Energy-Based Meta-Learning (EBML) coherent framework that covers both the OOD task detection and the adaptation of OOD tasks during the meta-testing. The approach is agnostic to the meta-learning backbones and can be fit with any approach to make them generalizable against OOD tasks. Experiments on the regression and classification datasets show the efficacy of the approach over the Bayesian meta-learning methods and cross-domain meta-learning approaches for OOD task detection and adaptation respectively.", "questions": "Please see questions in the weakness section", "limitations": "The authors have adequately addressed the limitations of the paper.", "rating": 7, "confidence": 3, "soundness": 4, "presentation": 4, "contribution": 4, "strengths": "-\tThe paper proposes a coherent energy based meta-learning framework that covers both OOD tasks detection and adaptation to alleviate the limitations of Bayesian meta-learning algorithms and cross-domain meta-learning algorithms\n-\tProposes task-specific data EBM and latent prior EBM leveraging from [1]\n\n[1] Learning Latent Space Energy-Based Prior Model, NeurIPS 2022\n\n-\tTheoretical derivation of EBML meta-learning objective with both task specific $E_{\\omega}$ and latent prior $E_{\\lambda}$ EBM. The author leverages both these EBMs $E_{\\omega}$ and $E_{\\lambda}$ to define energy score for OOD tasks detection.\n-\tExtensive experimental and ablation study including EBM prior v/s Gaussian for energy sum to achieve better OOD detection, more baselines for OOD adaptation, reliability of current cross-domain meta-learning algorithms under insufficient support set datapoints.\n-\tEBML outperforms Bayesian meta-learning approaches for OOD task detection with an improvement of up to 7% on AUROC. Compared to cross-domain meta-learning algorithms for OOD tasks adaptations on Meta-dataset, it performs on-par with the SOTA approaches.\n", "weaknesses": "- Can the authors please shed light on computation complexity of the method? It looks a good trade-off for a synthetic regression tasks, but for a real meta-dataset (classification task), it is more expensive than SimpleCNAP. Given that what approach would be have better trade-off given the performance and training time?\n\n\n- The approach performs better on dataset like MNIST in meta-dataset, but for the other datasets like VGG Flower, Oxford, and MSCOCO, the results are on par with TSA. Could the authors provide the performance of the approach by plugging it into other meta-learning algorithms of classification tasks? \n\n- Does the model handle the catastrophic forgetting about the in-distribution meta-training tasks?", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "We sincerely appreciate your positive feedback and comments to improve our paper. We detail our response below point by point. Please kindly let us know if our response addresses the issues you raised in this paper.\n##### Additional results for EBML on meta-datasets.\n> We will include URL [31] (which is currently the official second-best method on Meta-dataset; note that in our experiments we have already included TSA [30] which is the best) and EBML-URL as additional baselines and experimental results in Table 4.\n> - For URL we use the official code which is publicly available. To implement EBML-URL for task-specific adaptation, we optimize Eqn. (11) w.r.t. to the task-specific feature projection matrix in URL. \n> - We show the results of URL vs. EBML-URL, together with SimpleCNAPs vs EBML-SimpleCNAPs, **in Table r1 in the PDF file attached to our global response to reviewers**, from which we observe that EBML-URL outperforms URL on 4/5, and EBML-SimpleCNPAs outperforms SimpleCNAPs 5/5 OOD datasets and conclude with the efficacy of the proposed EBML.\n##### On performance vs computation complexity trade-off of EBML-SimpleCNAPs  for meta-dataset (classification task).\n> - Based on the OOD tasks detection results in Table 2 and additional OOD tasks adaptation results in Table r1 in our global response to reviewers, we believe that EBML-SimpleCNAPs also shows a reasonable performance vs complexity trade-off on meta-datasets:\n>   - In Table 2, EBML-SimpleCNAPs with energy sum improves the OOD detection performance of simpleCNAPs with conventional OOD detection methods by at least 7% in AUROC, 5% in AUPR and **a significant 36% reduction in FPR95**.\n>   - In Table r1, we optimize Eqn. (11) to adapt the task-encoder hence the task-specific FiLM parameters in SimpleCNAPs  for OOD meta-testing tasks in Meta-dataset. The resultant **EBML-SimpleCNAPs  outperforms SimpleCNAPs on all 5/5 OOD datasets**.\n>  - Given that we observe a noticeable gain in performance over the baseline method, we think that the computational overhead for EBML-simpelCNAPs in Appendix C.4. is therefore reasonable. \n##### On catastrophic forgetting on the in-distribution meta-training tasks.\n>- We think that catastrophic forgetting on the ID meta-training tasks may be less of a concern in the standard meta-training and meta-testing settings due to the reasons below. \n> - However, we are not so sure whether we have correctly interpreted the review's view on \"catastrophic forgetting on the ID meta-training tasks\" when answering this question. Therefore, we wish the the reviewer could kindly elaborate more on this question if our answer is not sufficient.\n>\n>   - Given a meta-testing task, meta-learning algorithms always perform task-specific adaptation (i.e., the inner-loop optimization w.r.t. the model) on the support set before making prediction on the query samples. \n>   - The task-specific model is always reset back to the original state i.e., the meta-learned model on IID meta-training tasks, at the start of meta-testing on each new test task. Thus the adaptation and testing for different **meta-testing tasks are treated as independent episodes**, i.e., the task-specific model for one task will not be carried on for adaptation and testing for another different task.\n>- Since, the **meta-learned model initialization for meta-testing is the optimal model returned from meta-training on IID tasks**, therefore, there should be no forgetting on the ID meta-training tasks when testing on ID meta-training tasks.\n\n"}, {"review_id": "ec0GFhihsb", "reviewer": "Reviewer_92KR", "summary": "This paper proposes EBML, an energy-based meta-learning which models the joint P(X,Y) with two energy functions - one for E(X,Y,phi) that models task-specific joint P(X_i,Y_i|phi) and E(phi) that models task-specific latents P(phi). The motivation is twofold: 1. completeness: energy-based models can naturally distinguish between in and out-of-distributions because it can easily model the joint P(X,Y), 2. expressiveness: energy function can provide more flexible distribution than conditionals with known forms, such as Gaussian. For negative samples, they used SGLD-based sampling, and the resultant ELBO approximation becomes tractable and efficient. They also propose a novel OOD detection metric which seems to be superior than the previous metrics. The experimental results support their claim.", "questions": "See the comments above.\nI'm willing to increase my score if the above major concerns (and hopefully minor comments as well) can be resolved.", "limitations": "Authors did properly addressed several limitations of their paper.", "rating": 7, "confidence": 5, "soundness": 3, "presentation": 3, "contribution": 3, "strengths": "- Motivation is clear: we need to model the joint P(X,Y) in order to detect and better adapt to OOD X's. Also, it's appealing that energy function can provide more expressivity than conditionals of known forms.\n- Writing is mostly clear: It's well structured and I enjoyed reading this paper\n- The resultant ELBO objective in (8) makes sense, and seems efficient to train.\n- Experiments are extensive and sufficient to show that EBML is competitive. \n- Figure 2 provides good insights as to what the role of the two energy terms is.", "weaknesses": "[Major comments]\n\n- I wonder whether the techinical contribution is sufficient. It seems to me that the proposed EBML is a replacement of conditional P(Y|X) with E(X,Y), and I feel that it would be a little bit straightforward. I'm not entirely sure if there exists similar papers doing similar things, and I found a seemingly-relevant paper [1]. Could you discuss the relationship between EBML and [1]?\n- In (10), I don't understand how argmin_y does make sense. The argmin completely throws away all the uncertainty informations by finding only a single local optimum. Thus I failed to understand how the uncertainty plots from the sinusoidal experiments could have been drawn. Maybe argmin makes more sense for classifications, but it's same that all the uncertainty information is discarded. Could you clarify this point?\n- It seems that this argmin operation is computationally more expensive than the usual direct modeling of P(y|x). The wall-clock time analysis should be properly compared agains the baselines.\n- I don't understand why (11) should be seen as \"adapting to ID\". To me, the goal of (11) is to adapt $q_\\psi$ to the OOD task given at the meta-test time, no?\n\n[Minor comments]\n- In (5), it would be good to explain why $q_\\psi$ can be only conditioned on $\\mathcal{T}^s_i$ rather than the entire $\\mathcal{T}_i$, based on ABML paper (for the readers who are not familiar with the context).\n- In section 4.1, it would be good to explicitly mention that the meta-parameters are collected into $\\theta = \\{\\psi, \\omega, \\lambda\\}$\n- I my personal experience, energy functions are not always easy to train. I wonder how much it is easy to train the energy functions you proposed with wall-clock convergence plots (compared to the usual directed models P(Y|X)).\n- In L179-183, I think the other methods can also use the ELBO approximation, and there will be no such limitations, no?\n- In L190, maybe \"only a single forward pass\" rather than \"only forward pass\"?\n\n[Reference]\n[1] Willette et al, Meta-Learning Low Rank Covariance Factors for Energy-Based Deterministic Uncertainty, ICLR 2022", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "We sincerely appreciate your comments on this paper. You may find our response below for your major and minor concerns. We would appreciate it if you could let us know if you have any further concerns.\n##### Technical contribution\n> - First, we respectfully point out the misunderstandings in the argument on that EBML is a straightforward replacement of conditional $P(\\bf Y|X)$ with $E(\\bf X,Y)$.\n>   - As in Line 134-135, the objective of EBML is to model $P(\\bf X,Y)$ instead of $P(\\bf Y|X)$, thereby **resolving the issue of incomplete OOD coverage**  (c.f. Line 32-39 and Fig. 1(a)). \n>   - This, **is not as straightforward as building $E(\\bf X,Y)$**, as $(\\bf X, Y)$ representing a task is **a variable set of samples**. Thus,\n>     - different from EBMs conventionally applied on samples **in fixed dimension**, the energy-based modelling for $P(\\bf X,Y)$ models **the distribution over sets**, which requires **(1)** flexibility in handling sets in varying cardinalities, and **(2)** expressiveness in capturing the set-level property of a task, including the function $p(y|x)$ and sample variance of a task. \n>     - the straightforward energy-based modelling strategies that meet the above first requirement unfortunately fail to meet the second, thereby being inadequate. E.g., building an EBM on all support samples of all tasks cannot even describe the function of each task; an EBM over the task representation via simple average of all samples in a task disregards sample variance. We show these simple alternatives significantly underperform EBML empirically in Table r2 (in global response PDF).\n>     - EBML directly derived from the task distribution $P(\\bf X,Y)$ (c.f. Eqn. (5)) resorts **two novel EBMs** to fulfill the above two requirements, respectively: **(1)** the latent prior EBM is an energy function of the **prior** that functionally characterizes a task in the **fixed latent representation space**, correlated with **the functional distance of a task from the ID distribution**; **(2)** the task-specific data EBM is an energy function of **the observed support set conditioned on its prior**, correlated with **the variance of samples in a task** (see Fig. 2 left).\n> - Second, our technical contributions include more than modelling $P(\\bf X,Y)$ with energy-based models only. Others include:\n>   - the **Energy Sum** as a principled (proportional to the likelihood of a task (c.f. Appendix A.2)) and effective OOD task detection score for EBML, \n>   - the **OOD task adaptation strategy in Eqn. (11)** to improve meta-generalization for EBML which makes it a coherent framework. \n> - Third, to our best knowledge, EBML is the first **coherent probabilistic model** that allows both detection and adaptation of OOD tasks and **general framework** being compatible with off-the-shelf meta-learning backbones. Still, we sincerely thank the reviewer for pointing out the related work of [1] and will definitely discuss the key differences between ours and [1] in the final version of the manuscript. **Please kindly refer to our global rebuttal for a detailed analysis between EBML and [1].**\n>\n> [1] Meta Learning Low Rank Covariance Factors for Energy Based Deterministic Uncertainty, ICLR 2022.\n##### Explanation of $\\text{argmin}_y$ in Eqn. (10) and the uncertainty plots for sinusoids\n> Given (1) the support set  $\\mathcal{T}^s$ and (2) a query input $\\mathbf{x}^q_j$ of a meta-testing task, our probabilistic model $\\mathbb{E}\\_{\\phi\\sim q_\\psi(\\phi|\\mathcal{T}^s)}[E_{\\omega}(y;\\mathbf{x}\\_{j}^q,\\phi)] \\propto -\\log p(y|\\mathcal{T}^s,\\mathbf{x}\\_{j}^q)$ allows for evaluation **at any value of $y$**. Therefore,\n> - The $\\text{argmin}\\_{y}$ is for finding **the most likely** prediction which is **the single desired output** in practice. This is also a common practice in making predictions by EBMs [r1].\n> - The $\\text{argmin}\\_{y}$ operation **does not alter the probabilistic nature** of our energy-based models, which suffices to estimate the uncertainty at $\\mathbb{E}\\_{\\phi \\sim q_\\psi(\\phi | \\mathcal{T}^s)}[E_{\\omega}(\\mathbf{x}\\_{j}^q, y, \\phi)]$ by specifying $y$ together with $\\mathcal{T}\\^s$ and $\\mathbf{x}\\^q_j$. Note that the way that EBM offers uncertainty, **requiring specification and input of a spectrum of $y$ values**, is different from conventional probabilistic models (e.g., with Gaussian priors) that take only $\\mathbf{x}$ as input and output the variance as uncertainty.\n> - That said, to draw the predictive distribution for a sinusoid task in Fig. 1 and 4 , we (1) infer $\\phi\\sim q_\\psi(\\phi|\\mathcal{T}^s)$ , (2) evaluate $E_{\\omega}(\\mathbf{x},y,\\phi)$ over a **2D grid of $x,y$**. Similar visualizations are also present in the literature (c.f. Fig. 2 in [r1]).\n> [r1] Energy-Based Models for Deep Probabilistic Regression, ECCV, 2020. \n##### In L179-183, I think the other methods can also use the ELBO approximation, and there will be no such limitations, no?\n> - We clarify that Line 179-183 address the limitations in using naïve Monte Carlo approximation for the intractable log-likelihood of a task as a density-based OOD score. These limitations motivate us to use the ELBO approximation which leads to the proposed Energy Sum.\n> - We have investigated the possibility of using the ELBO approximation as the OOD score in a similar fashion to Energy Sum for ABML and CNPs in our ablation studies in Table 3, i.e., \"SNLL + Gauss Prior\". \n> - Our proposed Energy Sum outperforms these alternatives which illustrates the advantages of the proposed EBML in overcoming the issue of **limited expressiveness** of traditional probabilistic methods.\n##### Due to the space limitation, **please kindly refer to our global rebuttal for response to the reviewer's comments** on (1) Why (11) should be seen as \"adapting to ID\"; the goal of (11) is to adapt $q_\\psi$ to the OOD task, (2) wall-clock convergence plots (3) other minor comments"}, {"review_id": "DrG0wkSVCF", "reviewer": "Reviewer_qEmy", "summary": "In this paper, the authors address the generalization problem of meta-learning methods on out-of-distribution tasks in the wild. However, existing Bayesian meta-learning methods suffer from incomplete convergence of the feature distribution shifts and insufficient expressiveness of meta-learning priors. The authors propose an energy-based meta-learning framework to represent task distributions.", "questions": "1. In lines 34-35,  \\theta and \\phi denote the parameters of the meta model and task-specific model. However, some meta-learning methods, such as MAML, use the same network architecture for both the meta-model and the task-specific model. In this paper, \\theta and \\phi are different networks?\n2. Why do meta-testing for ID and OOD tasks have different optimization functions? Can the authors explain the essential difference between Equations (10) and (11)?\n3. In Table 4, I tend to see more experimental results in meta-datasets with different baselines and methods.\n4. The author lacks some important related work, using energy methods to solve the problem of meta-learning and few-shot learning [1, 2, 3].\n\n[1] Meta-Learning Deep Energy-Based Memory Models.\n[2]  Energy-Efficient and Federated Meta-Learning via Projected Stochastic Gradient Ascent\n[3] Unsupervised Meta-Learning via Latent Space Energy-based Model of Symbol Vector Coupling ", "limitations": "see weaknesses and questions", "rating": 5, "confidence": 2, "soundness": 3, "presentation": 2, "contribution": 3, "strengths": "A plug-in and effective module EBML is proposed to improve the performance of existing meta-learning methods and achieve the new state of the art. Extensive experiments on four regression and classification datasets demonstrate the effectiveness of the method. ", "weaknesses": "Some parts of the paper are not very clear, and it takes a long time for the reviewer to understand. These symbols should be prior definited to help reader to fast find the usefull infromation.  ", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "Thank you a lot for the constructive comments. You may find our corresponding explanations below for your concerns. We would really appreciate it if you could let us know if you have any further concerns.\n##### Q1: On what $\\theta$ and $\\phi$ represent in EBML\n> Lines 33 in the Introduction is a hierarchical probabilistic model [8, 44] that subsumes almost all meta-learning algorithms, where we use $\\theta$ and $\\phi$ to denote the parameters of the meta-model and task-specific model. Depending on the meta-learning algorithms, $\\theta$ and $\\phi$ have different implementations.\n> - For gradient-based meta-learning algorithms including MAML, each task-specific-model $\\phi$ is obtained from $\\theta$ via gradient descent. Thus, $\\theta$ and $\\phi$ share the same network architecture but differ in parameters.\n> - For amortized meta-learning algorithms including CNPs that we experimented with EBML, $\\theta$ include both the parameters for the amortization network and those for the posterior predictive network (i.e., the decoder); $\\phi$ is rather an encoded representation of a task in the form of **a finite-dimensional vector** which is used to condition the posterior prediction.\n> - In EBML, we can collect all the meta-learned parameters that are shared by all tasks into $\\theta$, including $\\omega$ for the task-specific data EBM, $\\psi$ for the amortization network, and the latent prior EBM $\\lambda$. $\\phi\\sim q_\\psi(\\phi|\\mathcal{T}^s)$ following amortized meta-learning algorithms denotes a task-specific vector that conditions the task-specific data EBM $E_\\omega(\\mathbf{x},y,\\phi)$.\n##### Q2 : Why different optimization functions for ID and OOD tasks, i.e., the difference between Eqn. (10) and Eqn. (11)\n> - We first clarify that Eqn. (10) is used for making **predictions** whereas Eqn. (11) is employed for OOD **task adaptation**, thus the optimization is w.r.t. $y$ (the predicted label) in Eqn. (10) but $\\zeta$ (the task-specific parameters for adaptation) in Eqn. (11).\n> - Secondly, the meta-testing procedures are indeed different for ID and OOD tasks:\n>   - For ID tasks, we **solve Eqn. (10) directly** where we use the meta-learned amortization network parameters $\\psi$ shared by all tasks;\n>   - For OOD tasks, as we have detailed in Line 235-238, we **first solve Eqn. (11)** for adaptation of the amortization network parameters from $\\psi$  to $\\psi\\cup\\zeta$, and **then solve Eqn. (10)** where we use the adapted task-specific parameters $\\psi\\cup\\zeta$. \n> - Third, Line 219-223 illustrates **the reason why we have the above difference during meta-testing, i.e., an extra OOD task adaptation step for OOD tasks**. When given an OOD task, the meta-learned prior $\\phi\\sim q_\\psi(\\phi|\\mathcal{T}^s)$ is located out of the ID meta-training task distribution which is likely to lose its effectiveness. To alleviate this,  we introduce and optimize the task-specific parameters $\\zeta$ via minimizing the latent prior energy $E_{\\lambda}(\\phi)$, so that the adapted parameters $\\psi\\cup\\zeta$ consequently map this inadequate $\\phi$ back to the ID $\\phi$ region where the model enjoys guaranteed generalization through meta-training on ID tasks. \n> - Finally, Fig. 3 corroborates that such adaptation for OOD tasks indeed brings their $\\phi$ back to ID regions and thereby improves the classification accuracy.\n##### Q3 : More experiment results for Meta-dataset.\n> We will include URL [31] (which is currently the official second-best method on Meta-dataset; note that in our experiments we have already included TSA [30] which is the best) and EBML-URL as additional baselines and experimental results in Table 4.\n> - For URL we use the official code which is publicly available. To implement EBML-URL for task-specific adaptation, we optimize Eqn. (11) w.r.t. to the task-specific feature projection matrix in URL. \n> - We show the results of URL vs. EBML-URL, together with SimpleCNAPs vs EBML-SimpleCNAPs, **in Table r1 in the PDF file attached to our global response**, from which we observe that EBML-URL outperforms URL on 4/5, and EBML-SimpleCNPAs outperforms SimpleCNAPs 5/5 OOD datasets and conclude with the efficacy of the proposed EBML.\n##### Q4 : Related works on using energy methods to solve the problem of meta-learning and few-shot learning [1, 2, 3].\n> We very much appreciate the suggestion made by the reviewer to include [1,2,3] as related works. However, after some careful analysis, we think [1,2,3] are less relevant to EBML:\n> - In [1], the authors employed **EBMs as an associative memory model** - a system which is able to retrieve a remembered pattern based on its distorted or incomplete version. Based on this, the author proposed to accelerate the reading/writing to the associative memory-model via meta-learning.\n> - In [2], the authors proposed a federated meta-learning algorithm, whose primary objective is to learn a meta-model that can be fine-tuned to a new task both with a few number of samples in a distributed setting and **at low computation and communication energy consumption**. \n> - In [3], the authors studied **unsupervised meta-learning**, and **formulated a top-down generative model where a latent EBM is used to model the latent clusters within a task**. The EBM in [3], therefore, serves a different purpose to the two novel EBMs in EBML which are used for jointly characterizing the ID meta-training task distribution. \n> - In summary, despite meta-learning or (and) EBMs are studied in [1,2,3], **all of them bear very different goals from EBML**. The goal of EBML is to develop a coherent meta-learning framework that enables both OOD task detection and adaptation in meta-testing.\n>\n> [1] Meta-Learning Deep Energy-Based Memory Models, ICLR 2020\n> [2] Energy-Efficient and Federated Meta-Learning via Projected Stochastic Gradient Ascent, GLOBECOM 2021\n> [3] Unsupervised Meta-Learning via Latent Space Energy-based Model of Symbol Vector Coupling, NeurIPS MetaLearn Workshop 2021 "}, {"review_id": "1go1Lz8XaH", "reviewer": "Reviewer_aM9D", "summary": "This paper studies the intersection of OOD generalization and meta-learning, which is rather new. The main claim is that existing meta-learning algorithms may fail to generalize well in OOD settings since they are not specifically designed to solve OOD tasks. To this end, authors proposed a general framework to incorporate OOD into the Bayesian meta-learning framework and use the derived ELBO to solve the problem. Experiments on Sinusoids, DrugOOD, and meta-dataset show the effectiveness of this approach.", "questions": "See weakness", "limitations": "See weakness", "rating": 6, "confidence": 4, "soundness": 3, "presentation": 3, "contribution": 3, "strengths": "1. The problem formulation is new and interesting.\n2. The proposed framework is general and can solve both ID and OOD tasks.\n3. Experiments are supporting the algorithms.", "weaknesses": "1. A lack of theoretical analysis using the derived Beyesian framework. I assume a generalization bound can further help understand the superiority of the approach.\n2. There are no experiments related to efficiency, which is demonstrated in abstract section. Additionally, I wonder what is the performance and efficiency of the algorithm in larger datasets.\n3. ELBO is difficult to optimize. Are there any experiments on hyperparameter choices?", "quality": null, "clarity": null, "significance": null, "originality": null, "strengths_and_weaknesses": "", "was_revised": false, "final_justification": "", "rebuttal": "We sincerely appreciate your constructive comments to improve our paper. We detail our response below point by point. Please kindly let us know if our response addresses the questions you had for this paper.\n\n##### A lack of theoretical analysis using the derived Bayesian framework. I assume a generalization bound can further help understand the superiority of the approach.\n> - We will definitely include a rigorously derived generalization bound in the final version of our manuscript. For now we borrow the meta-generalization bound from Lampert et.al. [r1] for an intuitive explanation.\n>  - We would first recall Lampert's generalization bound for meta-learning, which consists of three parts: (1) the empirical error $\\hat{\\text{er}}(\\mathcal{Q})$, (2) the KL divergence between the hyper-posterior and the hyper-prior $\\text{KL}(\\mathcal{Q}||\\mathcal{P})$, and (3) the expected KL divergence between each task-specific posterior and priors sampled from the hyper-posterior $\\mathbb{E}_{P\\sim\\mathcal{Q}}[\\text{KL}(Q_i(S_i,P)||P)]$.\n> \n> - Our argument is that EBML with more flexibility learns a **better hyper-posterior distribution $\\mathcal{Q}$ that approximates the ID task distribution more accurately** than simple distributions like Gaussians. As a result, we expect a **lower KL divergence $\\mathbb{E}_{P\\sim\\mathcal{Q}}[\\text{KL}(Q_i(S_i,P)||P)]$** between samples of this hyper-posterior and any task-specific posteriors in the ID task distribution (i.e., the above part (3)).\n>\n> [r1] Pentina, A., & Lampert, C.H . A PAC-Bayesian bound for Lifelong Learning. ICML 2014\n\n##### There are no experiments related to efficiency, which is demonstrated in abstract section. Additionally, I wonder what is the performance and efficiency of the algorithm in larger datasets.\n> - In Line 18 Abstract, we claim **\"effectiveness of our approach\"** which we have empirically verified:\n> \n>   - In Table 1,2&3, the purposed energy sum consistently outperforms traditional OOD detection baselines in detecting both regression and classification OOD meta-testing tasks. \n>   - In Table 4 and Table r1 in our global response, our proposed OOD adaptation strategy outperforms the baseline method under few-shot classification settings on 5/5 , 4/5 and 5/5 OOD testing domains in the Meta-dataset benchmark for EBML-TSA,  EBML-URL and EBML-SimpleCNAPs, respectively.\n>   \n> - In terms of **efficiency on larger datasets**, we have conducted our experiment on the **Meta-dataset benchmark, which is the largest benchmark currently** and has been extensively studied in many meta-learning algorithms, e.g., TSA, SimpleCNAPs. \n>   - We think that EBML shows a reasonable performance vs computational complexity trade-off given that we have seen a noticeable gain in performance.\n> - Additional computational complexity analysis and wall-clock convergence plots can be found in section C.4 of the supplementary material as well as Fig. r1 in the PDF file attached to our global response to reviewers.\n\n##### Are there any experiments on hyperparameter choices?\n> - We follow the reviewer's suggestion and conduct a sensitivity analysis of EBML's prediction and OOD detection performance w.r.t. a number of important hyperparameters in Fig. r2 in the PDF file attached to our global response.\n>\n>  - For each plot, we vary one of the hyperparameters from its optimal value while keeping the rest unchanged.\n> -  Based on the results, we observe that EBML's performance is quite stable within the region near the optimal hyperparameter values."}]

Author rebuttal:
### Global Response to Reviewers 
#####  Why (11) should be seen as "adapting to ID"; the goal of (11) is to adapt $q_\psi$ to the OOD task
> As we explain below, our original description of Eqn. (11) in Line 221, i.e., "adapts this inadequate meta-learned prior back to the ID region" **is not conflicting with** reviewer 92kR's interpretation that Eqn. (11) is "adapting $q_\psi$ to the OOD task". Nevertheless, we thank the reviewer for pointing this out, and we will make sure to add more explanation on this in section 4.3 to avoid confusion in the final manuscript.
> - As shown in Eqn. (11), the **optimization procedure** is indeed with respect to the mapping $\zeta$ that adapt the parameters $\psi $ of $q_\psi$ to $\psi\cup\zeta$, so that $q_{\psi\cup\zeta}$ accommodates the OOD task. 
> - The **optimization result**, however, is that the resulting OOD prior $\phi\sim q_{\psi\cup\zeta}(\phi|\mathcal{T}^s)$ approaches the ID region where the meta-generalization is guaranteed due to meta-training on ID tasks. We illustrate the adaptation process in Fig. 3, where the OOD priors $\phi$ indeed shift towards the ID region as optimization proceeds. 
> - We provide an analogy with classifier editing [48] in Line 222, in which the classifier is edited/adapted to accommodate an OOD image (a car with wooden tire) so that the predicted class of the OOD image aligns with an ID one (a car with rubber tire).

##### We sincerely thank reviewer 92KR for pointing out the related work of [1] and will definitely include the following key differences between ours and [1] in the final version of the manuscript. 
>   - **Problem definition and objective:** EBML aims to detect a meta-testing task that is OOD of the meta-training tasks; however, [1] focuses on detecting a query sample that is OOD of the support samples in a meta-testing task. 
>   - **Method:** EBML falls into the category of **density-based** OOD detection methods, so that it **explicitly meta-learns the distribution of meta-training tasks via the two proposed EBMs** and develops the **Energy Sum to flag those high-energy tasks as OOD tasks**; however, [1] first meta-learns class covariance matrices as a parameterised function to alleviate the collapse of the covariance matrix due to limited samples in a few-shot meta-testing task and secondly resorts to **post-hoc** OOD detection via **energy scaling**. Note that "energy scaling" here refers to temperature scaling in softmax output, **without learning any EBM**.
>   - **Coherence and Generality**: EBML also improves meta-generalization, and works well in either regression/classification; however, [1] builds on only generative classifier-based meta-learning approaches solves only classification tasks and underperforms some very basic meta-learning algorithms e.g., MAML, ProtoNet, in classification accuracy (c.f. Tables 2,3,4,5 in the Appendix of [1])
>
>     | Method | ID                                     | OOD to evaluate     | OOD detection method | EBM explicitly learned | Coherency                                                  | Generality                                                 |
>     | ------ | -------------------------------------- | ------------------- |:-------------------- | ---------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- |
>     | EBML   | meta-training tasks                    | a meta-testing task | Density-based        | Yes                    | both OOD detection and adaptation                          | all meta-learning backbones, regression and classification |
>     | [1]    | support samples in a meta-testing task | a query sample      | Post-hoc scaling     | No                     | uncertainty calibration with a sacrifice in generalization | generative-classifier based backbones, classification      |
>
>     [1] Meta Learning Low Rank Covariance Factors for Energy Based Deterministic Uncertainty, ICLR 2022.

##### Wall-clock time analysis and convergence plots for EBML, and additional results for OOD tasks adaptation for Meta-datasets.
> - Please kindly refer to the additional plots and tables in the PDF file attached to this global response. 

##### Other minor comments related to writing
> - We sincerely thank the reviewers for their helpful suggestions that would further improve the clarity of the paper.  We will make sure to follow these comments when editing the final version of the manuscript

Meta-review: All reviewers unanimously support the acceptance of the paper. Please incorporate the feedback from the rebuttal in the camera ready. 

Congratulations!
Decision: Accept (poster)