ADAVI: A UTOMATIC D UAL A MORTIZED V ARIATIONAL I NFERENCE
A PPLIED T O P YRAMIDAL B AYESIAN M ODELS
Anonymous authors
Paper under double-blind review
A BSTRACT
Frequently, population studies feature pyramidally-organized data represented using Hierarchical Bayesian Models (HBM) enriched with plates.
These models can become prohibitively large in settings such as neuroimaging, where a sample is composed of a functional MRI signal measured on 300 brain locations, acrossmeasurement sessions, and 30 subjects, resulting in around 1 million latent parameters. Such high dimensionality hampers the usage of modern, expressive ﬂowbased techniques.
To infer parameter posterior distributions in this challenging class of problems, we designed a novel methodology that automatically produces a variational family dual to a target HBM.
This variational family, represented as a neural network, consists in the combination of an attention-based hierarchical encoder feeding summary statistics to a set of normalizing ﬂows.
Our automaticallyderived neural network exploits exchangeability in the plate-enriched HBM and factorizes its parameter space.
The resulting architecture reduces by orders of magnitude its parameterization with respect to that of a typical ﬂow-based representation, while maintaining expressivity.
Our method performs inference on the speciﬁed HBM in an amortized setup: once trained, it can readily be applied to a new data sample to compute the parameters’ full posterior.
We demonstrate the capability and scalability of our method on simulated data, as well as a challenging high-dimensional brain parcellation experiment.
We also open up several questions that lie at the intersection between normalizing ﬂows, SBI, structured Variational Inference, and inference amortization.
I NTRODUCTION
Inference aims at obtaining the posterior distribution p ( θ | X ) of latent model parameters θ given the observed data X .
In the context of Hierarchical Bayesian Models (HBM), p ( θ | X ) usually has no known analytical form, and can be of a complex shape -different from the prior’s (Gelman et al., 2004).
Modern normalizing-ﬂows based techniques -universal density estimators- can overcome this difﬁculty (Papamakarios et al., 2019a; Ambrogioni et al., 2021).
Yet, in setups such as neuroimaging, featuring HBMs representing large population studies (Kong et al., 2018;
Bonkhoff et al., 2021), the dimensionality of θ can go over the million.
This high dimensionality hinders the usage of normalizing ﬂows, since their parameterization usually scales quadratically with the size of the parameter space (e.g. Dinh et al., 2017; Papamakarios et al., 2018; Grathwohl et al., 2018).
Population studies with large dimensional features are therefore inaccessible to off-the-shelf ﬂow-based techniques and their superior expressivity.
This can in turn lead to complex, problem-speciﬁc derivations: for instance Kong et al.
(2018) rely on a manually-derived Expectation Maximization (EM) technique.
Such an analytical complexity constitutes a strong barrier to entry, and limits the wide and fruitful usage of Bayesian modelling in ﬁelds such as neuroimaging.
Our main aim is to meet that experimental need: how can we derive a technique both automatic and efﬁcient in the context of very large, hierarchically-organised data?
Approximate inference features a large corpus of methods including Monte Carlo methods (Koller &
Friedman, 2009) and Variational Auto Encoders (Zhang et al., 2019). We take particular inspiration from the ﬁeld of Variational Inference (VI) (Blei et al., 2017), deemed to be most adapted to large parameter spaces.
In VI, the experimenter posits a variational family Q so as to approximate q ( θ ) ≈
[Figure]
ADAVI working principle p
( θ | X ) .
In practice, deriving an expressive, yet computationally attractive variational family can be challenging (Blei et al., 2017).
This triggered a trend towards the derivation of automatic VI techniques (Kucukelbir et al., 2016; Ranganath et al., 2013; Ambrogioni et al., 2021).
We follow that logic and present a methodology that automatically derives a variational family Q .
In Fig. 1, from the HBM on the left we derive automatically a neural network architecture on the right.
We aim at deriving our variational family Q in the context of amortized inference (Rezende & Mohamed, 2016; Cranmer et al., 2020).
Amortization is usually obtained at the cost of an amortization gap from the true posterior, that accumulates on top of a approximation gap dependent on the expressivity of the variational family Q (Cremer et al., 2018).
However, once an initial training overhead has been “paid for”, amortization means that our technique can be applied to a any number of data points to perform inference in a few seconds.
Due to the very large parameter spaces presented above, our target applications aren’t amenable to the generic ﬂow-based techniques described in Cranmer et al.
(2020) or Ambrogioni et al.
We therefore differentiate ourselves in exploiting the invariance of the problem not only through the design of an adapted encoder, but down to the very architecture of our density estimator.
Speciﬁcally, we focus on the inference problem for Hierarchical Bayesian Models (HBMs) (Gelman et al., 2004;
Rodrigues et al., 2021).
The idea to condition the architecture of a density estimator by an analysis of the dependency structure of an HBM has been studied in (Wehenkel & Louppe, 2020; Weilbach et al.), in the form of the masking of a single normalizing ﬂow.
With Ambrogioni et al.
(2021), we instead share the idea to combine multiple separate ﬂows.
More generally, our static analysis of a generative model can be associated with structured VI (Hoffman & Blei, 2014; Ambrogioni et al.; 2021).
Yet our working principles are rather orthogonal: structured VI usually aims at exploiting model structure to augment the expressivity of a variational family, whereas we aim at reducing its parameterization.
Our objective is therefore to derive an automatic methodology that takes as input a generative HBM and generates a dual variational family able to perform amortized parameter inference.
This variational family exploits the exchangeability in the HBM to reduce its parameterization by orders of magnitude compared to generic methods (Papamakarios et al., 2019b; Greenberg et al., 2019; Am- brogioni et al., 2021).
Consequently, our method can be applied in the context of large, pyramidallystructured data, a challenging setup inaccessible to existing ﬂow-based methods and their superior expressivity.
We apply our method to such a large pyramidal setup in the context of neuroimaging (section 3.5), but demonstrate the beneﬁt of our method beyond that scope.
Our general scheme is visible in Fig. 1, a ﬁgure that we will explain throughout the course of the next section.
M ETHODS 2. P YRAMIDAL B AYESIAN M ODELS
We are interested in experimental setups modelled using plate-enriched Hierarchical Bayesian Models (HBMs) (Kong et al., 2018;
Bonkhoff et al., 2021).
These models feature independent sampling from a common conditional distribution at multiple levels, translating the graphical notion of plates (Gilks et al., 1994).
This nested structure, combined with large measurements -such as the ones in fMRI- can result in massive latent parameter spaces.
For instance the population study in Kong et al.
(2018) features multiple subjects, with multiple measures per subject, and multiple brain vertices per measure, for a latent space of around 0 .
4 million parameters.
Our method aims at performing inference in the context of those large plate-enriched HBMs.
Such HBMs can be represented with Directed Acyclic Graphs (DAG) templates (Koller & Friedman, 2009) with vertices -corresponding to RVs- { θ i } i =0 ...
L and plates {P p } p =0 ...P .
We denote as Card( P ) the -ﬁxed- cardinality of the plate P , i.e. the number of independent draws from a common conditional distribution it corresponds to.
In a template DAG, a given RV θ can belong to multiple plates P h , . . . P P .
When grounding the template DAG into a ground graph -instantiating the repeated structure symbolized by the plates P - θ would correspond to multiple RVs of similar parametric form { θ i h ,...,i P } , with i h = 1 . . . Card( P h ) , . . , i P = 1 . . . Card( P P ) .
This equivalence visible on the left on Fig. 1, where the template RV Γ corresponds to the ground RVs [ γ 1 , γ 2 ] .
We wish to exploit this plate-induced exchangeability.
We deﬁne the sub-class of models we specialize upon as pyramidal models, which are plate-enriched
DAG templates with the 2 following differentiating properties.
First, we consider a single stack of the plates P 0 , . .
, P P .
This means that any RV θ belonging to plate P p also belongs to plates {P q } q>p .
We thus don’t treat in this work the case of colliding plates (Koller & Friedman, 2009).
Second, we consider a single observed RV θ 0 , with observed value X , belonging to the plate P(with no other -latent- RV belonging to P 0 ).
The obtained graph follows a typical pyramidal structure, with the observed RV at the basis of the pyramid, as seen in Fig.
This ﬁgure features 2 plates P 0 and P 1 , the observed RV is X , at the basis of the pyramid, and latent RVs are Γ , λ and κ at upper levels of the pyramid.
Pyramidal HBMs delineate models that typically arise as part of population studies -for instance in neuroimaging- featuring a nested group structure and data observed at the subject level only (Kong et al., 2018; Bonkhoff et al., 2021).
The fact that we consider a single pyramid of plates allows us to deﬁne the hierarchy of an RV θ i denoted Hier( θ i ) .
An RV’s hierarchy is the level of the pyramid it is placed at.
Due to our pyramidal structure, the observed RV will systematically be at hierarchy 0 and latent RVs at hierarchies > 0 .
For instance, in the example in Fig. 1 the observed RV X is at hierarchy 0, Γ is at hierarchy 1 and both λ and κ are at hierarchy 2.
Our methodology is designed to process generative models whose dependency structure follows a pyramidal graph, and to scale favorably when the plate cardinality in such models augments.
Given the observed data X , we wish to obtain the posterior density for latent parameters θ 1 , . . .
, θ L , exploiting the exchangeability induced by the plates P 0 , . .
. , P P .
2. A UTOMATIC DERIVATION OF A DUAL AMORTIZED VARIATIONAL FAMILY
In this section, we derive our main methodological contribution.
We aim at obtaining posterior distributions for a generative model of pyramidal structure.
For this purpose, we construct a family of variational distributions Q dual to the model.
This architecture consists in the combination ofitems.
First, a Hierarchical Encoder ( HE ) that aggregates summary statistics from the data.
Second, a set of conditional density estimators.
Tensor functions
We ﬁrst introduce the notations for tensor functions which we deﬁne in the spirit of Magnus & Neudecker (1999).
We leverage tensor functions throughout our entire architecture to reduce its parameterization.
Consider a function f : F → G , and a tensor T F ∈ F B of shape B .
We denote the tensor T G ∈ G B resulting from the element-wise application of f over T F as T G = −→ f ( B ) ( T F ) (in reference to the programming notion of vectorization in Harris et al.
In Fig. 1, −→ ST ( B 1 )and −−−−→ l γ ◦ F γ ( B 1 ) are examples of tensor functions.
At multiple points in our architecture, we will translate the repeated structure in the HBM induced by plates into the repeated usage of functions across plates.
Hierarchical Encoder
For our encoder, our goal is to learn a function HE that takes as input the observed data X and successively exploits the permutation invariance across plates P 0 , . .
. , P P .
In doing so, HE produces encodings E at different hierarchy levels.
Through those encodings, our goal is to learn summary statistics from the observed data, that will condition our amortized inference.
For instance in Fig. 1, the application of HE over X produces the encodings E 1 and E 2 .
To build HE , we need at multiple hierarchies to collect summary statistics across i.i.d samples from a common distribution.
To this end we leverage SetTransformers (Lee et al., 2019): an attention-based, permutation-invariant architecture.
We use SetTransformers to derive encodings across a given plate, repeating their usage for all larger-rank plates.
We cast the observed data X as the encoding E 0 .
Then, recursively for every hierarchy h = 1 . . .
P + 1 , we deﬁne the encoding E h as the application to the encoding E
h − 1 of the tensor function corresponding to the set transformer ST h − 1 .
HE( X ) then corresponds to the set of encodings { E 1 , . . .
, E P +1 } obtained from the successive application of { ST h } h =0 ,...,P .
If we denote the batch shape B h
= Card( P h ) × . . .
× Card( P P ) :
[Equation]
In collecting summary statistics across the i.i.d. samples in plate P h − 1 , we decrease the order of the encoding tensor E h − 1 .
We repeat this operation in parallel on every plate of larger rank than the rank of the contracted plate.
We consequently produce an encoding tensor E h with the batch shape B h , which is the batch shape of every RV of hierarchy h .
In that line, successively summarizing plates
P 0 , , . .
P P , of increasing rank results in encoding tensors E 1 , . .
, E P +1 of decreasing order. In
Fig. 1, there are 2 plates P 0 and P 1 , hence 2 encodings E
1 = −→ ST ( B 1 )( X ) and E 2 = ST 1 ( E 1 ) .
Eis an order 2 tensor: it has a batch shape of B 1 = Card( P 1 ) -similar to Γ - whereas E 2 is an ordertensor.
We can decompose E 1 =
[ e 11 , e 21 ] =
[ST 0 ([ X 1 , 1 , X 1 , 2 ]) , ST 0 ([ X 2 , 1 , X 2 , 2 ])] .
Conditional density estimators We now will use the encodings E , gathering hierarchical summary statistics on the data X , to condition the inference on the parameters θ .
The encodings { E h } h =1 ...
P +1 will respectively condition the density estimators for the posterior distribution of parameters sharing their hierarchy {{ θ i : Hier( θ i )
= h }} h =1 ...P +1 .
Consider a latent RV θ i of hierarchy h
i =
Hier( θ i ) .
Due to the plate structure of the graph, θ i can be decomposed in a batch of shape B h i =
Card( P h i ) × . . .
× Card( P P ) of multiple similar, conditionally independent RVs of individual size S θ i .
This decomposition is akin to the grounding of the considered graph template (Koller & Friedman, 2009).
A conditional density estimator is a 2-step diffeomorphism from a latent space onto the event space in which the RV θ i lives.
We initially parameterize every variational density as a standard normal distribution in the latent space R S θi .
First, this latent distribution is reparameterized by a conditional normalizing ﬂow F i (Rezende & Mohamed, 2016; Papamakarios et al., 2019a) into a distribution of more complex density in the space R S θi . The ﬂow F i is a diffeomorphism in the space R S θi conditioned by the encoding E h i .
Second, the obtained latent distribution is projected onto the event space in which θ i lives by the application of a link function diffeomorphism l i .
For instance, if θ i is a variance parameter, the link function would map R onto R + ∗ ( l i =
Exp as an example).
The usage of F i and the link function l i is repeated on plates of larger rank than the hierarchy h
i of θ i .
The resulting conditional density estimator q i for the posterior distribution p ( θ i | X ) is given by:
[Equation]
In Fig. 1 Γ =
[ γ 1 , γ 2 ] is associated to the diffeomorphism −−−−→ l γ ◦ F γ ( B 1 ) .
This diffeomorphism is conditioned by the encoding E 1 .
Both Γ and E 1 share the batch shape B 1 = Card( P 1 ) .
Decomposing the encoding E 1 = [ e 11 , e 21 ] , e 11 is used to condition the inference on γ 1 , and e 21 for γ 2 .
λ is associated to the diffeomorphism
l λ ◦ F λ , and κ to l κ ◦ F κ , both conditioned by E 2 .
[Figure] [Figure] Parsimonious parameterization Our approach produces a parameterization effectively independent from plate cardinalities.
Consider the latent RVs θ 1 , . .
, θ L .
Normalizing ﬂow-based density estimators have a parameterization quadratic with respect to the size of the space they are applied to (e g. Papamakarios et al., 2018).
Applying a single normalizing ﬂow to the total event space of θ 1 , . .
, θ L would thus result in O ([ (cid:80) Li
=1 S θ i (cid:81)
Pp = h
i Card( P p )] 2 ) weights.
But since we instead apply multiple ﬂows on the spaces of size S θ i and repeat their usage across all plates P h i , . .
P P , we effectively reduce this parameterization to:
[Equation]
As a consequence, our method can be applied to HBMs featuring large plate cardinalities without scaling up its parameterization to impractical ranges, preventing a computer memory blow-up.
2. V ARIATIONAL DISTRIBUTION AND TRAINING
Given the encodings E p provided by HE , and the conditioned density estimators q i , we deﬁne our parametric amortized variational distribution as a mean ﬁeld approximation (Blei et al., 2017):
[Equation]
In Fig. 1, we factorize q ( Γ , κ, λ | X ) =
q γ ( Γ ; E 1 ) × q λ ( λ ; E 2 )
× q κ ( κ ; E 2 ) .
Grouping parameters as Ψ =
( χ, Φ) , our objective is to have q Ψ ( θ | X )
≈ p ( θ | X ) .
Our loss is an amortized version of the classical ELBO expression (Blei et al., 2017; Rezende & Mohamed, 2016):
[Equation]
Where we denote z ∼ p ( z ) the sampling of z according to the distribution p(z).
We jointly train
HE and q i , i = 1 . . .
L to minimize the amortized ELBO.
The resulting architecture performs amortized inference on latent parameters.
Furthermore, since our parameterization is invariant to plate cardinalities, our architecture is suited for population studies with large-dimensional feature space.
E XPERIMENTS
In the following experiments, we consider a variety of inference problems on pyramidal HBMs.
We ﬁrst illustrate the notion of amortization (section 3.1).
We then test the expressivity (section 3.2, 3.4), scalability (section 3.3) of our architecture, as well as its practicality on a challenging neuroimaging experiment (section 3.5).
Baseline choice In our experiments we use as baselines: Mean Field VI (MF-VI) (Blei et al., 2017) is a common-practice method; (Sequential) Neural Posterior Estimation (NPE-C, SNPE-C) (Greenberg et al., 2019) is a structure-unaware, likelihood-free method: SNPE-C results from the sequential -and no longer amortized- usage of NPE-C; Total Latent Space Flow (TLSF) (Rezende & Mohamed, 2016) is a reverse-KL counterpoint to SNPE-C: both ﬁt a single normalizing ﬂow to the entirety of the latent parameter space but SNPE-C uses a forward KL loss while TLSF uses a reverse KL loss;
Cascading Flows (CF) (Ambrogioni et al., 2021) is a structure-aware, prior-aware method: CF-A is our main point of comparison in this section. For relevant methods, the sufﬁx -(N)A designates the (non) amortized implementation.
More details related to the choice and implementation of those baselines can be found in our supplemental material.
3. I NFERENCE AMORTIZATION
In this experiment we illustrate the trade-off between amortized versus non-amortized techniques (Cranmer et al., 2020).
For this, we deﬁne the following Gaussian random effects HBM (Gelman et al., 2004)
(see Fig. 2b-GRE):
[Equation]
[Equation] In Fig. 2a we compare the cumulative time to perform inference upon a batch of examples drawn from this generative HBM.
For a single example, a non-amortized technique can be faster -and deliver a posterior closer to the ground truth- than an amortized technique.
This is because the nonamortized technique ﬁts a solution for this speciﬁc example, and can tune it extensively. In terms of
ELBO, on top of an approximation gap an amortized technique will addition an approximation gap (Cremer et al., 2018). On the other hand, when presented with a new example, the amortized technique can infer directly whereas the optimization of the non-amortized technique has to be repeated.
As the number of examples rises, an amortized technique becomes more and more attractive.
This result puts in perspective the quantitative comparison later on performed between amortized and non-amortized techniques, that are qualitatively distinct.
3. E XPRESSIVITY IN A NON - CONJUGATE CASE
In this experiment, we underline the superior expressivity gained from using normalizing ﬂowsused by ADAVI or CF- instead of distributions of ﬁxed parametric form -used by MF-VI.
For this we consider the following HBM (see Fig. 2b-NC):
[Equation]
This example is voluntarily non-canonical: we place ourselves in a setup where the posterior distribution of a given an observed value from B has no known parametric form, and in particular is not of the same parametric form as the prior.
Such an example is called non-conjugate in Gelman et al.
Results are visible in table 1-NC: MF-VI is limited in its ability to approximate the correct distribution as it attempts to ﬁt to the posterior a distribution of the same parametric form as the prior.
As a consequence, contrary to the experiments in section 3.3 and section 3.4 -where MF-VI stands as a strong baseline- here both ADAVI and CF-A are able to surpass its performance.
Proxy to the ground truth posterior MF-VI plays the role of an ELBO upper bound in our experiments GRE (section 3.3), GM (section 3.4) and MS-HBM (section 3.5).
We crafted those examples to be conjugate: MF-VI thus doesn’t feature any approximation gap, meaning KL( q ( θ ) || p ( θ | X ))
(cid:39) 0 .
As such, its ELBO ( q ) = log p ( X ) − KL( q ( θ ) || p ( θ | X )) is approximately equal to the evidence of the observed data. As a consequence, any inference method with the same ELBO value -calculated over the same examples- as MF-VI would yield an approximate posterior with low KL divergence to the true posterior.
Our main focus in this work are ﬂow-based methods, whose performance would be maintained in non-conjugate cases, contrary to MF-VI (Papamakarios et al., 2019a).
We further focus on amortized methods, providing faster inference for a multiplicity of problem instances, see e.g. section 3.1.
MF-VI is therefore not to be taken as part of a benchmark but as a proxy to the unknown ground truth posterior.
[Table]
3. P ERFORMANCE SCALING WITH RESPECT TO PLATE CARDINALITY
In this experiment
[Table]
we illustrate our plate cardinality independent parameterization deﬁned in section 2.2.
We consider 3 instances of the Gaussian random effects model presented in eq.
(6), increasing the number of groups from G = 3 to G = 30 and G = 300 .
In doing so, we augment the total size of the latent parametric space from 8 to 62 to 602 parameters, and the observed data size from 300 to 3 , 000 to 30 , 000 values.
Results for this experiment are visible in Fig.
3 (see also table 2).
On this example we note that amortized techniques only feature a small amortization gap (Cremer et al., 2018), reaching the performance of non-amortized techniques -as measured by the ELBO, using MF-VI as an upper bound- at the cost of large amortization times.
We note that the performance of (S)NPE-C quickly degrades as the plate dimensionality augments, while TLSF’s performance is maintained, hinting towards the advantages of using the likelihood function when available.
As the HBM’s plate cardinality augments, we match the performance and amortization time of state-of-the-art methods, but we do so maintaining a constant parameterization.
3. E XPRESSIVITY IN A CHALLENGING SETUP
In this experiment, we test our architecture on a challenging setup in inference: a mixture model.
Mixture models notably suffer from the label switching issue and from a loss landscape with multiple strong local minima (Jasra et al., 2005).
We consider the following mixture HBM (see Fig. 2b-GM): [Equation]
[Equation]
x g [Equation] n | π g , [ µ g 1 , . . . , µ gL ] ∼ Mix(
[Equation]
g [Equation] [Equation] Where Mix( π, [ p 1 , . .
. , p N ]) denotes the ﬁnite mixture of the densities [ p 1 , . .
, p N ] with π the mixture weights.
The results are visible in table 1-GM.
In this complex example, similar to TLSF-A we obtain signiﬁcantly higher ELBO than CF-A, but we do feature an amortization gap, not reaching the ELBO level of non-amortized techniques.
We also note that despite our efforts (S)NPE-C failed to [Figure] reach the ELBO level of other techniques.
We interpret this result as the consequence of a forwardKL-based training taking the full blunt of the label switching problem, as seen in appendix D.2.
Fig. D.3 shows how our higher ELBO translates into results of greater experimental value
. 3. N EUROIMAGING : MODELLING MULTI - SCALE VARIABILITY IN B ROCA ’ S AREA FUNCTIONAL PARCELLATION
To show the practicality of our method in a high-dimensional context, we consider the model proposed by Kong et al.
We apply this HBM to parcel the human brain’s Inferior Frontal Gyrus in 2 functional MRI (fMRI)-based connectivity networks.
Data is extracted from the Human Connectome Project dataset (Van Essen et al., 2012).
The HBM models a population study withsubjects and 4 large fMRI measures per subject, as seen in Fig.
2b-MSHBM: this nested structure creates a large latent space of (cid:39) 0 . 4 million parameters and an even larger observed data size of (cid:39)million values.
Due to our parsimonious parameterization, described in eq.
(4), we can nonetheless tackle this parameter range without a memory blow-up, contrary to all other presented ﬂow-based methods -CF, TLSF, NPE-C. Resulting population connectivity proﬁles can be seen in Fig.
We are in addition interested in the stability of the recovered population connectivity considering subsets of the population. For this we are to sample without replacement hundreds of sub-populations of 5 subjects from our population.
[-L − 1 ( µ gl ) ∼ N ( (cid:126) 
 D − 1 , Σ g ) M L = [ µ gl ] l =1 ... L-]On GPU, the inference wall time for MF-VI is 160 seconds per sub-population, for a mean log( − ELBO ) of 28 . 6( ± 0 . 2) (across 20 examples, 5 seeds per example).
MF-VI can again be considered as an ELBO upper bound.
Indeed the MSHBM can be considered as a 3-level (subject, session, vertex) Gaussian mixture with random effects, and therefore features conjugacy.
For multiple sub-populations, the total inference time for MF-VI reaches several hours. On the contrary, ADAVI is an amortized technique, and as such features an amortization time ofseconds, after which it can infer on any number of sub-populations in a few seconds. The posterior quality is similar: a {+mean log( − ELBO ) of 29 . 
+}
( ± 0 . 01) . As shown in our supplemental material -as a more meaningful comparison- the resulting difference in the downstream parcellation task is marginal (Fig. E.7).
We therefore bring the expressivity of ﬂow-based methods and the speed of amortized techniques to parameter ranges previously unreachable.
This is due to our plate cardinality-independent parameterization. What’s more, our automatic method only necessitates a practitioner to declare the generative HBM, therefore reducing the analytical barrier to entry there exists in ﬁelds such as neu- roimaging for large-scale Bayesian analysis.
Details about this experiment, along with subject-level results, can be found in our supplemental material.  D ISCUSSION
Exploiting structure in inference In the SBI and VAE setups, data structure can be exploited through learnable data embedders (Zhang et al., 2019; Radev et al., 2020).
We go one step beyond and also use the problem structure to shape our density estimator: we factorize the parameter space of a problem into smaller components, and share network parameterization across tasks we know to be equivalent (see section 2.2 and 3.3).
In essence, we construct our architecture not based on a ground HBM graph, but onto its template, a principle that could be generalized to other types of templates, such as temporal models (Koller & Friedman, 2009).
Contrary to the notion of black box, we argue that experimenters oftentimes can identify properties such as exchangeability in their experiments (Gelman et al., 2004).
As our experiments illustrate (section 3.4, section 3.3), there is much value in exploiting this structure.
Beyond the sole notion of plates, a static analysis of a forward model could automatically identify other desirable properties that could be then leveraged for efﬁcient inference.
This concept points towards fruitful connections to be made with the ﬁeld of lifted inference (Broeck et al., 2021;
Chen et al., 2020).
Mean-Field approximation A limitation in our work is that our posterior distribution is akin to a mean ﬁeld approximation (Blei et al., 2017): with the current design, no statistical dependencies can be modelled between the RV blocks over which we ﬁt normalizing ﬂows (see section 2.3).
Regrouping RV templates , we could model more dependencies at a given hierarchy.
On the contrary, our method prevents the direct modelling of dependencies between ground RVs corresponding to repeated instances of the same template.
Those dependencies can arise as part of inference (Webb et al., 2018).
We made the choice of the Mean Field approximation to streamline our contribution, and allow for a clear delineation of the advantages of our methods, not tying them up to a method augmenting a variational family with statistical dependencies, an open research subject (Ambrogioni et al., 2021; Weilbach et al.).
Though computationally attractive, the mean ﬁeld approximation nonetheless limits the expressivity of our variational family (Ranganath et al., 2016; Hoffman & Blei, 2014). We ponder the possibility to leverage VI architectures such as the one derived by Ranganath et al.
; Ambrogioni et al.
(2021) and their augmented variational objectives for structured populations of normalizing ﬂows such as ours.
Conclusion For the delineated yet expressive class of pyramidal Bayesian models, we have introduced a potent, automatically derived architecture able to perform amortized parameter inference.
Through a Hierarchical Encoder, our method conditions a network of normalizing ﬂows that stands as a variational family dual to the forward HBM.
To demonstrate the expressivity and scalability of our method, we successfully applied it to a challenging neuroimaging setup.
Our work stands as an original attempt to leverage exchangeability in a generative model.
All experiments were performed on a computational cluster with 16 Intel(R)
Xeon(R) CPU E5v2 @ 2.20GHz (256Mb RAM), 16 AMD EPYC 7742 64-Core Processor (512Mb RAM) CPUs and 1 NVIDIA Quadro RTX 6000 (22Gb), 1 Tesla V100 (32Gb) GPUs.
All methods were implemented in Python.
We implemented most methods using Tensorﬂow Probability (Dillon et al., 2017), and SBI methods using the SBI Python library (Tejero-Cantero et al., 2020).
As part of our submission we release the code associated to our experiments.
Our supplemental material furthermore contains an entire section dedicated to the implementation details of the baseline methods presented as part of our experiments.
For our neuromimaging experiment, we also provide a section dedicated to our pre-processing and post-processing steps
S UPPLEMENTAL MATERIAL
This supplemental material complements our main work both with theoretical points and experiments:
A complements to our methods section 2.
We present the HBM descriptors needed for the automatic derivation of our dual architecture; B complements to our discussion section 3.
We elaborate on various points including amortization; C complements to the Gaussian random effects experiment described in eq.
We present results mostly related to hyperparameter analysis; D complements to the Gaussian mixture with random effects experiment (section 3.4).
We explore the complexity of the example at hand; E complements to the MS-HBM experiments (section 3.5).
We present some context for the experiment, a toy dimensions experiment and implementation details.
F justiﬁcation and implementation details for the baseline architectures used in our experiments;
A C OMPLEMENTS TO THE METHODS : MODEL DESCRIPTORS FOR AUTOMATIC VARIATIONAL FAMILY DERIVATION
This section is a complement to section 2.
We formalize explicitly the descriptors of the generative
HBM needed for our method to derive its dual architecture.
This information is of experimental value, since those descriptors need to be available in any API designed to implement our method.
If we denote plates( θ ) the plates the RV θ belongs to, then the following HBM descriptors are the needed input to derive automatically our ADAVI dual architecture:
[Equation]
Hier = { θ
[Equation]
h
[Equation]
= min
[Equation]
{ p : P p ∈ plates( θ i ) }}
[Equation]
=0 ...
L
Shape =
{ θ i (cid:55)→ S event θ i } i =0 ...
L
Link =
{ θ i (cid:55)→
[Equation] [Equation]
..L (A.1)
Where:
• V lists the RVs in the HBM (vertices in the HBM’s corresponding graph template); • P lists the plates in the HBM’s graph template; • Card maps a plate P to its cardinality , that is to say the number of independent draws from a common conditional density it corresponds to; • Hier maps a RV θ to its hierarchy , that is to say the level of the pyramid it is placed at, or equivalently the smallest rank for the plates it belongs to; • Shape maps a RV to its event shape S event θ i .
Consider the plate-enriched graph template representing the HBM.
A single graph template RV belonging to plates corresponds to multiple similar RVs when grounding this graph template.
S event
θ i is the potentially highorder shape for any of those multiple ground RVs.
• Link maps a RV θ to its link function l .
The Link function projects the latent space for the RV θ onto the event space in which θ lives.
For instance, if θ is a variance parameter, the link function would map R onto R + ∗ ( l =
Exp as an example).
Note that the latent space of shape S θ is necessary an order 1 unbounded real space.
l therefore potentially implies a reshaping to the high-order shape S event θ i .
Those descriptors can be readily obtained from a static analysis of a generative model, especially when the latter is expressed in a modern probabilistic programming framework (Dillon et al., 2017;
Bingham et al., 2019).
B C OMPLEMENTS TO OUR DISCUSSION B. A MORTIZATION
Contrary to traditional VI, we aim at deriving a variational family Q in the context of amortized inference (Rezende & Mohamed, 2016; Cranmer et al., 2020).
This means that, once an initial training overhead has been “paid for”, our technique can readily be applied to a new data point.
Amortized inference is an active area of research in the context of Variational Auto Encoders (VAE) (Kingma & Welling, 2014; Wu et al., 2019; Shu et al.
; Iakovleva et al.).
It is also a the original setup of normalizing ﬂows (NF)
(Rezende & Mohamed, 2016; Radev et al., 2020), our technology of choice.
From this amortized starting point, Cranmer et al.
; Papamakarios et al.
(2019b)
; Thomas et al.
(2020); Greenberg et al.
have notably developed sequential techniques, reﬁning a posterior -and losing amortization- across several rounds of simulation.
To streamline our contribution, we chose not build upon that research, and rather focus on the amortized implementation of normalizing ﬂows.
But we argue that our contribution is actually rather orthogonal to those: similar to Ambrogioni et al.
we propose a principled and automated way to combine several density estimators in a hierarchical structure.
As such, our methods could be applied to a different class of estimators such as VAEs (Kingma & Welling, 2014).
We could leverage the SBI techniques and extend our work into a sequential version through the reparameterization of our conditional estimators
q
i (see section 2.2).
Ultimately, our method is not meant as an alternative to SBI, but a complement to it for the pyramidal class of problems described in section 2.1.
We choose to posit ourselves as an amortized technique.
Yet, in our target experiment from Kong et al.
(see section 3.5), the inference is performed on a speciﬁc data point.
An amortized method could therefore appear as a more natural option.
What’s more, it is generally admitted that amortized inference implies an amortization gap from the true posterior, which accumulates on top of the approximation gap that depends on the expressivity of the considered variational family.
This amortization gap further reduces the quality of the approximate posterior for a given data point.
Our experimental experience on the example in section 3.4 however makes us put forth the value that can be obtained from sharing learning across multiple examples, as amortization entitles (Cranmer et al., 2020).
Speciﬁcally, we encountered less issues related to local minima of the loss, a canonical issue for MF-VI (Blei et al., 2017) that is for instance illustrated in our supplemental material.
We would therefore argue against the intuition that a (locally) amortized technique is necessarily wasteful in the context of a single data point.
However, as the results in table 2 and table 1 underline, there is much work to be done for amortized technique to reach the performance consistency and training time of amortized techniques, especially in high dimension, where exponentially more training examples can be necessary to estimate densities properly (Donoho).
Specializing for a local parameter regime -as sequential method entitles (Cranmer et al.
, 2020)- could therefore make us beneﬁt from amortization without too steep an upfront training cost.
B. E XTENSION TO A BROADER CLASS OF SIMULATORS
The presence of exchangeability in a problem’s data structure is not tied to the explicit modelling of a problem as a HBM: Zaheer et al.
(2018) rather describe this property as an permutation invariance present in the studied data.
As a consequence, though our derivation is based on HBMs, we believe that the working principle of our method could be applied to a broader class of simulators featuring exchangeability.
Our reliance on HBMs is in fact only tied to our usage of the reverse KL loss (see section 2.3), a readily modiﬁable implementation detail.
In this work, we restrict ourselves to the pyramidal class of Bayesian networks (see section 2.1).
Going further, this class of models could be extended to cover more and more use-cases.
This bottom-up approach stands at opposite ends from the generic approach of SBI techniques (Cranmer et al., 2020).
But, as our target experiment in 3.5 demonstrates, we argue that in the long run this bottom-up approach could result in more scalable and efﬁcient architectures, applicable to challenging setups such as neuroimaging.
B. R ELEVANCE OF LIKELIHOOD - FREE METHODS IN THE PRESENCE OF A LIKELIHOOD
As part of our benchmark, we made the choice to include likelihood-free methods (NPE-C and SNPE-C), based on a forward KL loss. In our supplemental material (appendix C.4) we also study the implementation of our method using a forward KL loss.
There is a general belief in the research community that likelihood-free methods are not intended to be as competitive as likelihood-based methods in the presence of a likelihood (Cranmer et al., 2020).
In this manuscript, we tried to provide quantitative results to nourish this debate.
We would argue that likelihood-free methods generally scaled poorly to high dimensions (section 3.3).
The result of the Gaussian Mixture experiment also shows poorer performance in a multi-modal case, but we would argue that the performance drop of likelihood-free methods is actually largely due to the label switching problem (see appendix D.2).
On the other hand, likelihood-free methods are dramatically faster to train and can perform on par with likelihood-based methods in examples such as the Gaussian Random Effects for G = 3 (see table 2).
Depending on the problem at hand, it is therefore not straightforward to systematically disregard likelihood-free methods.
As an opening, there maybe is more at the intersection between likelihood-free and likelihood-based methods than meets the eye.
The symmetric loss introduced by Weilbach et al. stands as a fruitful example of that connection.
B. I NFERENCE OVER A SUBSET OF THE LATENT PARAMETERS
Depending on the downstream tasks, out of all the parameters θ , an experimenter could only be interested in the inference of a subset Θ 1 .
Decomposing θ =
Θ 1 ∪ Θ 2 , the goal would be to derive a variational distribution q 1 (Θ 1 ) instead of the distribution q (Θ 1 , Θ 2 ) .
Reverse KL setup
We ﬁrst consider the reverse KL setup.
The original ELBO maximized as part of inference is equal to:
[Equation]
To keep working with normalized distributions, we get a similar expression for the inference of Θonly via:
[Equation]
In this expression, p ( X, Θ 1 ) is unknown: it results from the marginalization of Θ 2 in p , which is non-trivial to obtain, even via a Monte Carlo scheme.
As a consequence, working with the reverse
KL does not allow for the inference over a subset of latent parameters.
Forward KL setup Contrary to reverse KL, in the forward KL setup the evaluation of p is not required.
Instead, the variational family is trained using samples ( θ, X ) from the joint distribution p .
In this setup, inference can be directly restricted over the parameter subset Θ 1 .
Effectively, one wouldn’t have to construct density estimators for the parameters Θ 2 , and the latter would be marginalized in the obtained variational distribution q (Θ 1 ) .
However, as our experiments point out (section 3.3, section 3.4), likelihood-free training can be less competitive in large data regimes or complex inference problems.
As a consequence, even if this permits inference over only the parameters of interest, switching to a forward KL loss can be inconvenient.
B. E MBEDDING SIZE FOR THE H IERARCHICAL E NCODER
An important hyper-parameter in our architecture is the embedding size for the Set Transformer ( ST ) architecture (Lee et al., 2019).
The impact of the embedding size for a single ST has already been studied in Lee et al.
(2019), as a consequence we didn’t devote any experiments to the study of the impact of this hyper-parameter.
However, our architecture stacks multiple ST networks, and the evolution of the embedding size with the hierarchy could be an interesting subject:
• it is our understanding that the embedding size for the encoding E
h should be increasing with: – the number of latent RVs θ whose inference depends on E h , i.e. the latent RVs of hierarchy h – the dimensionality of the latent RVs θ of hierarchy h – the complexity of the inference problem at hand, for instance how many statistical moments need to be computed from i.i.d data points • experimentally, we kept the embedding size constant across hierarchies, and ﬁxed this constant value based on the aforementioned criteria (see appendix F.2).
This approach is probably conservative and drives up the number of weights in HE • higher-hierarchy encodings are constructed from sets of lower-hierarchy encodings.
Should the embedding size vary, it would be important not to ”bottleneck” the information collected at low hierarchies, even if the aforementioned criteria would argue for a low embedding size.
There would be probably experimental interest in deriving algorithms estimating the optimal embedding size at different hierarchies.
We leave this to future work.
C C OMPLEMENTS TO THE G AUSSIAN R ANDOM E FFECTS EXPERIMENT : HYPERPARAMETER ANALYSIS
This section features additional results on the experiment described in eq.
(6) with G = 3 groups.
We present results of practical value, mostly related to hyperparameters.
C. D ESCRIPTORS , INPUTS TO ADAVI
We can analyse the model described in eq.
(6) using the descriptors deﬁned in eq.
(A.1).
Those descriptors constitute the inputs our methodology needs to automatically derive the dual architecture from the generative HBM:
[Equation]
C. T ABULAR RESULTS FOR THE SCALING EXPERIMENT
A tabular representation of the results presented in Fig. 3 can be seen in table 2. [Table]
C. D ERIVATION OF AN ANALYTIC POSTERIOR
To have a ground truth to which we can compare our methods results, we derive the following analytic posterior distributions.
Assuming we know σ µ , σ g , σ x : [Equation] C.5a) [Equation]
C.5b)
[Equation]
C.
[Equation]
[Equation] C. [Equation] Where in equation C.5b we neglect the inﬂuence of the prior (against the evidence) on the posterior in light of the large number of points drawn from the distribution.
We note that this analytical posterior is conjugate , as argued in section 3.2.
C. T RAINING LOSSES FULL DERIVATION AND COMPARISON
Full formal derivation Following the nomenclature introduced in Papamakarios et al. (2019a)
[Equation]
there are 2 different ways in which we could train our variational distribution:
• using a forward KL divergence, beneﬁting from the fact that we can sample from our generative model to produce a dataset {
[Equation]
This is the loss used in most of the SBI literature (Cranmer et al ), as those are based around the possibility to be likelihood-free [Equation]
and have a target density p only implicitly deﬁned by a simulator:
[Equation]
where θ m ∼ p
( θ ) , X m ∼ p ( X | θ )
[Equation]
• using a reverse KL divergence, beneﬁting from the access to a target joint density p ( X, θ ) .
The reverse KL loss is an amortized version of the classical ELBO expression (Blei et al., 2017).
For training, one only needs to have access to a dataset { X m } m =
1 ...M , X m ∼ p
( X ) of points drawn from the generative HBM of interest.
Indeed, the θ m points are sampled from the variational distribution:
[Equation]
where X m ∼ p ( X ) , θ m ∼ q Ψ ( θ | X )
[Equation]
As it more uniquely ﬁts our setup and provided better results experimentally, we chose to focus on the usage of the reverse KL divergence.
During our experiments, we also tested the usage of the unregularized ELBO loss: [Equation]
[Equation]
) where X m ∼ p ( X ) , θ m ∼ q Ψ ( θ | X ) (C.8)
Mean of analytical KL divergences
[Table]
This formula differs from the one of the reverse KL loss by the absence of the term q Ψ
( θ m | X m ) , and is a converse formula to the one of the forward KL (in the sense that it permutes the roles of q and p ).
Intuitively, it posits our architecture as a pure sampling distribution that aims at producing points θ m in regions of high joint density p .
In that sense, it acts as a ﬁrst moment approximation for the target posterior distribution (akin to MAP parameter regression).
Experimentally, the usage of the unregularized ELBO loss provided fast convergence to a mode of the posterior distribution, with very low variance for the variational approximation.
We argue the possibility to use the unregularized ELBO loss as a warm-up before switching to the reverse KL loss, with the latter considered here as a regularization of the former.
We introduce this training strategy as an example of the modularity of our approach, where one could transfer the rapid learning from one task (amortized mode ﬁnding) to another task (amortized posterior estimation).
Graphical comparison In Figure C.1 we analyse the inﬂuence of these 3 different losses on the training of our posterior distribution, compared to the analytical ground truth.
This example is typical of the relative behaviors induced on the variational distributions by each loss:
• The forward KL provides very erratic training, and results after several dozen epochs (several minutes) with a careful early stopping in posteriors with too large variance.
• The unregularized ELBO loss converges in less then 3 epochs (a couple dozen seconds), and provides posteriors with very low variance, concentrated on the MAP estimates of their respective parameters.
• The reverse KL converges in less 10 epochs (less than 3 minutes) and provides relevant variance.
Losses convergence speed We analyse the relative convergence speed of our variational posterior to the analytical one (derived in eq.
(C.5a))
when using the 3 aforementioned losses for training.
To measure the convergence, we compute analytically the KL divergence between the variational posterior and the analytical one (every distribution being a Gaussian), summed for every distribution, and averaged over a validation dataset of size 2000.
We use a training dataset of size 2000, and for each loss repeated the training 20 times (batch size 10, 10 θ m samples per X m ) for 10 epochs, resulting in 200 optimizer calls.
This voluntary low number allows us to asses how close is the variational posterior to the analytical posterior after only a brief training.
Results are visible in appendix C.4, showing a faster convergence for the unregularized
ELBO .
After 800 more optimizer calls, the tendency gets inverted and the reverse KL loss appears as the superior loss (though we still notice a larger variance).
The large variance in the results may point towards the need for adapted training strategies involving
Learning rate decay and/or scheduling (Kucukelbir et al., 2016), an extension that we leave for future work. [Figure]
C. M ONTE C ARLO APPROXIMATION FOR THE GRADIENTS AND COMPUTATIONAL BUDGET COMPARISON
In section 2.3, for the reverse KL loss, we approximate expectations using Monte Carlo integration.
We further train our architecture using minibatch gradient descent, as opposed to stochastic gradient descent as proposed by Kucukelbir et al.
An interesting hyper-parametrization of our system resides in the effective batch size of our training, that depends upon:
• the size of the mini batches, determining the number of X m points considered in parallel • the number of θ m draws per X m point, that we use to approximate the gradient in the ELBO
More formally, we deﬁne a computational budget as the relative allocation of a constant effective batch size batch size × θ draws per X between batch size and θ draws per X .
To analyse the effect of the computational budget on training, we use a dataset of size 1000, and run experiment 20 times over the same number of optimizer calls with the same effective batch size per call.
Results can be seen in Fig. C.2.
From this experiment we can draw the following conclusions:
• we didn’t witness massive difference in the global convergence speed across computational budgets • the bigger the budget we allocate to the sampling of multiple θ m per point X m (effectively going towards a stochastic training in terms of the points X m ), the more erratic is the loss evolution • the bigger the budget we allocate to the X m batch size, the more stable is the loss evolution, but our interpretation is that the resulting reduced number of θ m draws per X m augments the risk of an instability resulting in a NaN run
Experimentally, we obtained the best results by evenly allocating our budget to the X m batch size and the number of θ m draws per X m point (typically, 32 and 32 respectively for an effective batch size of 1024).
Overall, in the amortized setup, our experiment stand as a counterpoint to those of
Kucukelbir et al.
(2016) who pointed towards the case of a single θ m draw per point X m as their preferred hyper-parametrization.
D C OMPLEMENTS TO THE G AUSSIAN MIXTURE WITH RANDOM EFFECTS
EXPERIMENT : FURTHER POSTERIOR ANALYSIS
This section is a complement to the experiment described in section 3.4, we thus consider the model described in eq.
(8a).
We explore the complexity of the theoretical posterior for this experiment.
D. D ESCRIPTORS , INPUTS TO ADAVI
We can analyse the model described in eq.
(8a) using the descriptors deﬁned in eq.
(A.1).
Those descriptors constitute the inputs our methodology needs to automatically derive the dual architecture [Figure] from the generative HBM: [Equation]
[Equation]
For the deﬁnition of the SoftmaxCentered link function, see Dillon et al.
D. T HEORETICAL POSTERIOR RECOVERY IN THE G AUSSIAN MIXTURE RANDOM EFFECTS MODEL
We further analyse the complexity of model described in section 3.4.
Due to the label switching problem (Jasra et al., 2005), the relative position of the L mixture components in the D space is arbitrary.
Consider a non-degenerate example like the one in Fig. D.3, where the data points are well separated in 3 blobs (likely corresponding to the L = 3 mixture components).
Since there is no deterministic way to assign component l = 1 unequivocally to a blob of points, the marginalized posterior distribution for the position of the component l = 1 should be multi-modal, with -roughly- a mode placed at each one of the 3 blobs of points.
This posterior would be the same for the components l = 2 and l = 3 .
In truth, the posterior is even more complex than this 3-mode simpliﬁcation, especially when the mixture components are closer to each other in 2D (and the grouping of points into draws from a common component is less evident).
In Fig. D.3, we note that our technique doesn’t recover this multi-modality in its posterior, and instead assigns different posterior components to different blobs of points.
Indeed, when plotting only the posterior samples for the ﬁrst recovered component l = 1 , all points are concentrated around the bottom-most blob, and not around each blob like the theoretical posterior would entail (see Fig. D.3 second row).
This behavior most likely represents a local minimum in the reverse KL loss that is common to many inference techniques (for instance consider multiple non-mixing chains for MCMC in Jasra et al., 2005).
We note that training in forward KL wouldn’t provide such a ﬂexibility in that setup, as it would enforce the multi-modality of the posterior, even at the cost of an overall worst result (as it is the case for NPE-C and SNPE-C in table 1.
Indeed, let’s imagine that our training dataset features
M (cid:48) draws similar to the one in Fig. D.3.
Out of randomness, the labelling l of the 3 blobs of points would be permuted across those M (cid:48) examples.
A forward-KL-trained density estimator would then most likely attempt to model a multi-modal posterior.
Though it is not similar to the theoretical result, we argue that our result is of experimental value, and close to the intuition one forms of the problem: using our results one can readily estimate [-Data   
 MF-VI   
 CF-A   
-]the original components for the mixture.
[-ADAVI   2       2       
-]
Indeed, for argument’s sake, say we would recover the theoretical, roughly trimodal posterior.
To recover the original mixture components, one would need to split the 3 modes of the posterior and arbitrarily assign a label l to each one of the modes.
In that sense, our posterior naturally features this splitting, and can be used directly to estimate
the
L = 3 mixture components.
E C OMPLEMENTS TO THE NEUROIMAGING EXPERIMENT
This section is a complement to the experiment described in section 3.5, we thus consider the model described in eq.
(E.10a) and eq. (E.10b).
We present a toy dimension version of our experiment, use- [Figure] [Figure] [Figure]
MF
{+[Figure] VI   
 CF-A   
 [Figure]+}
[Figure]
[Figure]
[Figure]
[Figure]
ful to build an intuition of the problem.
We also present implementation details for our experiment, and additional neuroimaging results.
E. N EUROIMAGING CONTEXT
The main goal of Kong et al.
(2018) is to address the classical problem in neuroscience of estimating population commonalities along with individual characteristics.
In our experiment, we are interested in parcelling the region of left inferior frontal gyrus (IFG).
Anatomically, the IFG is decomposed in 2 parts: pars opercularis and triangularis.
Our aim is to reproduce this binary split from a functional connectivity point of view, an open problem in neuroscience (see e.g. Heim et al., 2009).
As Kong et al.
(2018), we consider a population of S=30 subjects, each with T = 4 acquisition sessions, from the Human Connectome Project dataset (Van Essen et al., 2012).
The fMRI connectivity between a cortical point and the rest of the brain, split in D = 1 , 483 regions, is represented as a vector of length D with each component quantifying the temporal correlation of blood-oxygenation between the point and a region.
A main hypothesis of Kong et al.
(2018), and the fMRI ﬁeld, is that the fMRI connectivity of points belonging to the same parcel share a similar connectivity pattern or correlation vector.
Following Kong et al.
(2018), we represent D-dimensional correlation vectors as RVs on the positive quadrant of the D -dimensional unit-sphere.
We do this efﬁciently assuming they have a L -normal distribution, or Gaussian under the transformation of the link function
L ( x ) =
(cid:112) SoftmaxCentered( x ) (Dillon et al., 2017):
[Equation] Our aim is therefore to identify L = 2 functional networks that would produce a functional parcellation of the studied IFG section.
In this setting, the parameters θ of interest are the networks µ .
Instead of the complex EM computation derived in Kong et al.
(2018), we perform full-posterior inference for those parameters using our automatically derived architecture.
E. D ESCRIPTORS , INPUTS TO ADAVI
We can analyse the model described in eq.
(E.10a) and eq.
(E.10b) using the descriptors deﬁned in eq.
(A.1).
Those descriptors constitute the inputs our methodology needs to automatically derive the dual
V =
[Equation]
, E
[Equation]
[Equation]
[Equation]
[Equation]
, κ,
[Equation]
, X }
P = {P 0 , P 1 , P 2 }
Card =
{P 0 (cid:55)→ N, P 1 (cid:55)→ T, P 2 (cid:55)→ S }
Hier = { M L (cid:55)→ 3 , E L (cid:55)→ 3 , M L,S (cid:55)→ 2 , Σ L (cid:55)→ 3 , M L,S,T (cid:55)→ 1 , κ (cid:55)→ 3 , Π
(cid:55)→ 3 , X (cid:55)→ 0 }
Shape = {
M L (cid:55)→ ( L, D ) ,
E L (cid:55)→ ( L, ) ,
M L,S (cid:55)→ ( L, D ) , Σ L (cid:55)→ ( L, ) ,
M L,S,T (cid:55)→ ( L, D ) , κ (cid:55)→ (1 , ) , Π (cid:55)→ ( L, ) ,
X (cid:55)→ ( D, ) }
Link = {
M L (cid:55)→ L ◦ Reshape(( LD, ) → ( L, D )) ,
E L (cid:55)→ Exp ,
M L,S (cid:55)→ L ◦ Reshape(( LD, )
→ ( L, D )) , Σ L (cid:55)→ Exp ,
M L,S,T (cid:55)→ L ◦ Reshape(( LD, )
→ ( L, D )) , κ (cid:55)→ Exp , Π (cid:55)→ SoftmaxCentered
(( L − 1 , )
→ ( L, )) ,
X (cid:55)→ L } (E.11)
E. E XPERIMENT ON MS-HBM MODEL ON TOY DIMENSIONS
To get an intuition of the behavior of our architecture on the MS-HBM model, we consider the following toy dimensions reproduction of the model:
[Equation]
Example
Data and posterior sample
Example0.
Example
The results can be visualized on Fig. E.4.
This experiment shows the expressivity we gain from the usage of link functions.
E. I MPLEMENTATION DETAILS FOR THE NEUROIMAGING MS-HBM EXAMPLE
Main implementation differences with the original MS-HBM model Our implementation of the MS-HBM (eq. (E.10a) and eq. (E.10b)) contains several notable differences with the original one from Kong et al.
• we model µ distributions as Gaussians linked to the positive quadrant of the unit sphere via the function L .
In the orignal model, RVs are modelled using Von Mises Fisher distributions.
Our choice allows us to express the entirety of the connectivity vectors (that only lie on a portion of the unit sphere).
However, we also acknowledge that the densities incurred by the 2 distributions on the positive quadrant of the unit sphere are different.
• we forgo any spatial regularization, and also the assumption that the parcellation of a given subject s should be constant across sessions t .
This is to streamline our implementation.
Adding components to the loss optimized at training could inject those constraints back into the model, but this was not the subject of our experiment, so we left those for future work.
Data pre-processing and dimensionality reduction Our model was able to run on the full dimensionality of the connectivity, D 0 = 1483 .
However, we obtained better results experimentally when further pre-processing the used data down to the dimension D 1 = 141 .
The displayed results in Fig. 4 are the ones resulting from this dimensionality reduction:
we projected the ( S, T, N, D 0 )
X connectome (lying on the D 0 unit sphere) to the unbounded R D 0 − 1 space using the function L 2.
in this R D 0 − 1 space, we performed a Principal Component Analysis (PCA) to bring us down to D 1 − 1 = 140 dimensions responsible for 80% of the explained data variance 3.
in the resulting R D 1 − 1 space, we calculated the mean of all the connectivity points, and their standard deviation, and used both to whiten the data 4.
from the whitened data, we calculated the Ledoit-Wolf regularised covariance (Ledoit & Wolf, 2004), that we used to construct the Σ g matrix used in eq.
(E.10a) 5.
ﬁnally, we projected the whitened data onto the unit sphere in D 1 = 141 dimensions via the function L
To project our results back to the original D 0 space, we simply ran back all the aforementioned steps.
Our prior for µ g has been carefully designed so has to sample connectivity points in the vicinity of the data point of interest.
Our implementation is therefore in spirit close to SBI (Cranmer et al., 2020;
Papamakarios et al., 2019b; Greenberg et al., 2019; Thomas et al., 2020) that aims at obtaining an amortized posterior only in the relevant data regime.
Mutli-step training strategy In appendix F.2 we describe our conditional density estimators as the stacking of a MAF (Papamakarios et al., 2018) on top of a diagonal-scale afﬁne block.
To accelerate the training of our architecture and minimize numerical instability (resulting in NaN evaluations of the loss) we used the following 3-step training strategy:
we only trained the shift part of our afﬁne block into a Maximum A Posteriori regression setup.
This can be viewed as the amortized ﬁtting of the ﬁrst moment of our posterior distribution 2.
we trained both the shift and scale of our afﬁne block using an unregularized ELBO loss.
This is to rapidly bring the variance of our posterior to relevant values 3.
we then trained our full posterior ( shift and scale of our afﬁne block, in addition to our MAF block) using the reverse KL loss.
This training strategy shows the modularity of our approach and the transfer learning capabilities already introduced in appendix C.4.
Loss evolution can be seen in Fig.
E.
[Figure]
Soft labelling In eq.
(E.10a) and eq.
(E.10b) we deﬁne µ variables as following Gaussian distributions in the latent space R D 1 − 1 .
This means that, considering a vertex X s,tn and a session network µ s,tk , the squared Euclidean distance between L − 1 ( X s,tn ) and L − 1 ( µ s,tk ) in the latent space R D 1 −is proportional to the log-likelihood of the point L − 1 ( X s,tn ) for the mixture component k :
[Equation]
Note that κ is the same for both networks.
Additionally, considering Bayes theorem:
[Equation]
E
[Equation]
Where log p ( X s,tn | l = k ) can be obtained through eq.
(E.13) and log p ( l = k ) via draws from the posterior of Π (see eq.
(E.10a)).
To integrate those equations, we used a Monte Carlo procedure.
E. A DDITIONAL NEUROIMAGING RESULTS E.5. S UBJECT - LEVEL PARCELLATION
As pointed out in section 3.5, the MS-HBM model aims at representing the functional connectivity of the brain at different levels, allowing for estimates of population characteristics and individual variability (Kong et al., 2018).
It is of experimental value to compare the parcellation for a given subject, that is to say the soft label we give to a vertex X s,tn , and how this subject parcellation can deviate from the population parcellation.
Those differences underline how an individual brain can have a unique local organization.
Similarly, we can obtain the subject networks µ s and observe how those can deviate from the population networks µ g .
Those results underline how a given subject can have his own connectivity, or, very roughly, his own ”wiring” between different areas of the brain.
Results can be seen in Fig. E.6.
E.5. C OMPARISON OF LABELLING WITH THE MF-VI RESULTS
We can compare the subject-level parcellation resulting from the latent networks recovered using the ADAVI vs the MF-VI method.
The result, for the same subjects as the previous section, can be seen in Fig.
E.7, where the difference in ELBO presented in our main text translates into marginal differences for our downstream task of interest.
F B ASELINES FOR EXPERIMENTS F. B ASELINE CHOICE
In this section we justify further the choice of architectures presented as baselines in the our experiments:
• Mean Field VI (MF-VI) (Blei et al., 2017).
This methods stands as a common-practice nonamortized baseline, is fast to compute, and due to our choice of conjugate examples (see section 3.2) can be considered as a proxy to the ground truth posterior.
We implemented MF-VI in its usual setup, ﬁtting to the posterior a distribution of the prior’s parametric form; • (Sequential) Neural Posterior Estimation (SNPE-C) architecture (Greenberg et al., 2019).
NPE-C is an typical example from the SBI literature (Cranmer et al., 2020), and functions as a likelihood-free , black box method.
Indeed, NPE-C is trained using forward KL (samples from the latent parameters), and is not made ”aware” of any structure in the problem.
NPEC ﬁts a single normalizing ﬂow over the entirety of the latent parameter space, and its number of weights scales quadratically with the parameter space size.
When ran over several simulation rounds, the method becomes sequential (SNPE-C), specializing for a certain parameter regime to improve performance, but loosing amortization in the process; • Total Latent Space Flow (TLSF) architecture (Rezende & Mohamed, 2016).
Following the original normalizing ﬂow implementation from Rezende & Mohamed (2016), we posit TLSF as a counterpoint to SNPE-C. Like SNPE-C, TLSF ﬁts a single normalizing ﬂow over the entirety of the latent parameter space, and is not made ”aware” of the structure of the model.
But contrary to SNPE-C, TLSF is trained using reverse KL and beneﬁts from the presence of a likelihood function.
We can use TLSF in a non-amortized setup (TLSFNA), or in an amortized setup (TLSF-A) trough an observed data encoder conditioning the single normalizing ﬂow; • Cascading Flows (CF) (Ambrogioni et al., 2021).
CF is an example of a structure-aware, prior-aware VI method, trained using reverse KL.
By design, its number of weights scales linearly with the plate’s cardinalities.
CF can be ran both in a non-amortized (CF-NA) and amortized (CF-A) setup, with the introduction of amortization through observed data encoders in the auxiliary graph.
As a structure-aware amortized architecture, CF-A is our main point of comparison in this section;
F. I MPLEMENTATION DETAILS
In this section, we describe with precision and per experiment the implementation details for the architectures described in appendix F.1.
We implemented algorithms in Python, using the Tensorﬂow probability (TFP, Dillon et al., 2017) and Simulation Based Inference (SBI, Tejero-Cantero et al., 2020) libraries.
For all experiments in TFP, we used the Adam optimizer (Kingma & Ba, 2015).
For normalizing ﬂows, we leveraged Masked Autoregressive Flow (MAF, Papamakarios & Murray, 2018).
For all experiments:
• Mean Field VI (MF-VI) (Blei et al., 2017).
We implemented MF-VI in TFP.
The precise form of the variational family is described below for each experiment.
• Sequential Neural Posterior Estimation (SNPE-C) architecture (Greenberg et al., 2019).
We implemented SNPE-C with the SBI library, using the default parameters proposed by the API.
Simulations were ran over 5 rounds, to ensure maximal performance.
We acknowledge that this choice probably results in an overestimate of the runtime for the algorithm.
To condition the density estimation based on the observed data, we designed an encoder that is a variation of our Hierarchical Encoder (see section 2.2).
Its architecture is the same as HE -the hierarchical stacking of 2 Set Transformers (Lee et al., 2019)- but the encoder’s output is the concatenation of the G per-group encodings with the population encodings.
This encoder is therefore parsimoniously parametrized, and adapted to the structure of the problem.
• Neural Posterior Estimation (NPE-C).
Though we acknowledge that NPE-C can be implemented easily using the SBI library, we preferred to use our own implementation, notably to have more control over the runtime of the algorithm.
We implemented the algorithm using TFP.
We used the same encoder architecture as for SNPE-C. • Total Latent Space Flow (TLSF).
We implemented TLSF using TFP.
Our API is actually the same as for NPE-C, since TLSF-A and NPE-C only differ by their training loss.
• Cascading Flows (CF) (Ambrogioni et al., 2021).
We implemented our own version of Cascading Flows, using TFP, and having consulted with the authors.
An important implementation detail that is not speciﬁed explicitly in Ambrogioni et al.
(2021) (whose notations we follow here) is the implementation of the target distribution over the auxiliary variables r , notably in the amortized setup.
Following the authors speciﬁcations during our discussion, we implemented r as the Mean Field distribution r = (cid:81)
j p j ( (cid:15) j ) .
• ADAVI (ours).
We implemented ADAVI using TFP.
Regarding the training data:
• All amortized methods were trained over a dataset of 20 , 000 samples • All non-amortized methods except SNPE-C were trained on a single data point (separately for 20 different data points) • SNPE-C was trained over 5 rounds of simulations, with 1000 samples per round, for an effective dataset size of
For the non conjugate experiment (see section 3.2):
• MF-VI: variational distribution is q =
Gamma ( a ; concentration= V ( D, ) , rate= Softplus( V (1 , ) ))
We used the Adam optimizer with a learning rate of 10 − 2 .
The optimization was ran for 20 , 000 steps, with a sample size of 32 . • CF: auxiliary size 8, observed data encoders with 8 hidden units.
Minibatch size 32,theta draws per X point (see appendix C.5), Adam ( 10 − 2 ), 40 epochs using a reverse KL loss.
• ADAVI: NF with 1 Afﬁne block with triangular scale, followed by 1 MAF with [32 , 32 , 32] units.
HE with embedding size 8 , 2 modules with 2 ISABs ( 2 heads, 8 inducing points),PMA (seed size 1 ), 1 SAB and 1 linear unit each.
Minibatch size 32, 32 theta draws per X point (see appendix C.5), Adam ( 10 − 3 ), 40 epochs using a reverse KL loss.
For the Gaussian random effects experiment (see section 3.3):
• MF-VI: variational distribution is
[Equation]
We used the Adam optimizer with a learning rate of 10 − 2 .
The optimization was ran for 10 , 000 steps, with a sample size of 32 . • SNPE-C: 5 MAF blocks with 50 units each.
Encoder with embedding size 8 , 2 modules with 2 SABs ( 4 heads) and 1 PMA (seed size 1 ) each, and 1 linear unit.
See SBI for optimization details.
• NPE-C: 1 MAF with [32 , 32 , 32] units.
Encoder with embedding size 8 , 2 modules withISABs ( 2 heads, 8 inducing points), 1 PMA (seed size 1 ), 1 SAB and 1 linear unit each.
Minibatch size 32, 15 epochs with Adam ( 10 − 3 ) using a forward KL loss.
• TLSF: same architecture as NPE-C. TLSF-A: minibatch size 32, 32 theta draws per X point (see appendix C.5), 15 epochs with Adam ( 10 − 3 ) using a reverse KL loss.
TLSFNA: minibatch size 1, 32 theta draws per X point (see appendix C.5), 1500 epochs with Adam ( 10 − 3 ) using a reverse KL loss.
• CF: auxiliary size 16, observed data encoders with 16 hidden units.
CF-A: minibatch size 32, 32 theta draws per X point (see appendix C.5), Adam ( 10 − 3 ), 40 epochs using a reverse KL loss.
CF-NA: minibatch size 1, 32 theta draws per X point (see appendix C.5), Adam ( 10 − 2 ), 1500 epochs using a reverse KL loss.
• ADAVI: NF with 1 Afﬁne block with triangular scale, followed by 1 MAF with [32 , 32 , 32] units.
HE with embedding size 8 , 2 modules with 2 ISABs ( 2 heads, 8 inducing points),PMA (seed size 1 ), 1 SAB and 1 linear unit each.
Minibatch size 32, 32 theta draws per X point (see appendix C.5), Adam ( 10 − 3 ), 10 epochs using an unregularized ELBO loss, followed by 10 epochs using a reverse KL loss.
For the Gaussian mixture with random effects experiment (see section 3.4):
• MF-VI: variational distribution is
[Equation]
G
[Equation]
We used the Adam optimizer with a learning rate of 10 − 2 . The optimization was ran for
, 000 steps, with a sample size of 32 .
• SNPE-C: 5 MAF blocks with 50 units each.
Encoder with embedding size 8 , 2 modules with 2 SABs ( 4 heads) and 1 PMA (seed size 1 ) each, and 1 linear unit.
See SBI for optimization details.
• NPE-C: 1 MAF with [32 , 32 , 32] units.
Encoder with embedding size 8 , 2 modules withISABs ( 2 heads, 8 inducing points), 1 PMA (seed size 1 ), 1 SAB and 1 linear unit each.
Minibatch size 32, 20 epochs with Adam ( 10 − 3 ) using a forward KL loss.
• TLSF-A: same architecture as NPE-C, minibatch size 32, 32 theta draws per X point (see appendix C.5), 250 epochs with Adam ( 10 − 3 ) using a reverse KL loss.
• TLSF-NA: same NF architecture as NPE-C. Encoder with embedding size 16 , 2 modules with 2 ISABs ( 2 heads, 8 inducing points), 1 PMA (seed size 1 ), 1 SAB and 1 linear unit each.
Minibatch size 1, 32 theta draws per X point (see appendix C.5), 1000 epochs with Adam ( 10 − 3 ) using a reverse KL loss.
• CF: auxiliary size 8, observed data encoders with 8 hidden units.
CF-A: minibatch size 32, 32 theta draws per X point (see appendix C.5), Adam ( 10 − 3 ), 200 epochs using a reverse KL loss.
CF-NA: minibatch size 1, 32 theta draws per X point (see appendix C.5), Adam ( 10 − 2 ), 1500 epochs using a reverse KL loss.
• ADAVI: NF with 1 Afﬁne block with diagonal scale, followed by 1 MAF with [32] units.
HE with embedding size 16 , 2 modules with 2 ISABs ( 4 heads, 8 inducing points), 1 PMA (seed size 1 ), 1 SAB and 1 linear unit each.
Minibatch size 32, 32 theta draws per X point (see appendix C.5), Adam ( 10 − 3 ), 50 epochs using a MAP loss on the afﬁne blocks, followed by 2 epochs using an unregularized ELBO loss on the afﬁne blocks, followed by 50 epochs of reverse KL loss (see appendix E.4 for the training strategy, total 102 epochs).
For the MSHBM example in toy dimensions (see appendix E.3):
• ADAVI: NF with 1 Afﬁne block with diagonal scale, followed by 1 MAF with [32] units.
HE with embedding size 32 , 2 modules with 2 SABs ( 4 heads), 1 PMA (seed size 1 ), 1 SAB and 1 linear unit each.
Minibatch size 32, 32 theta draws per X point (see appendix C.5), Adam ( 10 − 3 ), 5 epochs using a MAP loss on the afﬁne blocks, followed by 1 epoch using an unregularized ELBO loss on the afﬁne blocks, followed by 5 epochs of reverse KL loss (see appendix E.4 for the training strategy, total 11 epochs).
For the MSHBM example in (see section 3.5):
• MF-VI: variational distribution is [Equation] Dirichlet [Equation]
Π
[Equation] concentration= [Equation] ( L
[Equation]
We used the Adam optimizer with a learning rate of 10 − 2 . The optimization was ran for 10 , 000 steps, with a sample size of 32 . • ADAVI: NF with 1 Afﬁne block with diagonal scale, followed by 1 MAF with [1024] units. HE with embedding size 1024 , 3 modules with 1 SABs ( 4 heads), 1 PMA (seed size 1 ),SAB and 1 linear unit each. Minibatch size 1, 4 theta draws per X point (see appendix C.5), Adam ( 10 − 3 ), 1000 epochs using a MAP loss on the afﬁne blocks, followed by 1000 epochs using an unregularized ELBO loss on the afﬁne blocks, followed by 1000 epochs of reverse KL loss (see appendix E.4 for the training strategy, total 3000 epochs).