SlowGuess commited on
Commit
11d8d8a
·
verified ·
1 Parent(s): 9919a09

Add Batch 616e656c-481c-4591-b945-913e22cbb316

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. understandingandpreventingcapacitylossinreinforcementlearning/78e042a6-627b-4e6e-8bce-398dd81324a1_content_list.json +3 -0
  2. understandingandpreventingcapacitylossinreinforcementlearning/78e042a6-627b-4e6e-8bce-398dd81324a1_model.json +3 -0
  3. understandingandpreventingcapacitylossinreinforcementlearning/78e042a6-627b-4e6e-8bce-398dd81324a1_origin.pdf +3 -0
  4. understandingandpreventingcapacitylossinreinforcementlearning/full.md +560 -0
  5. understandingandpreventingcapacitylossinreinforcementlearning/images.zip +3 -0
  6. understandingandpreventingcapacitylossinreinforcementlearning/layout.json +3 -0
  7. understandinglatentcorrelationbasedmultiviewlearningandselfsupervisionanidentifiabilityperspective/2d3fc944-401f-4422-a5dd-600a142ba32a_content_list.json +3 -0
  8. understandinglatentcorrelationbasedmultiviewlearningandselfsupervisionanidentifiabilityperspective/2d3fc944-401f-4422-a5dd-600a142ba32a_model.json +3 -0
  9. understandinglatentcorrelationbasedmultiviewlearningandselfsupervisionanidentifiabilityperspective/2d3fc944-401f-4422-a5dd-600a142ba32a_origin.pdf +3 -0
  10. understandinglatentcorrelationbasedmultiviewlearningandselfsupervisionanidentifiabilityperspective/full.md +0 -0
  11. understandinglatentcorrelationbasedmultiviewlearningandselfsupervisionanidentifiabilityperspective/images.zip +3 -0
  12. understandinglatentcorrelationbasedmultiviewlearningandselfsupervisionanidentifiabilityperspective/layout.json +3 -0
  13. understandingtheroleofselfattentionforefficientspeechrecognition/6eab39ff-801f-4244-a054-726b9b2eab01_content_list.json +3 -0
  14. understandingtheroleofselfattentionforefficientspeechrecognition/6eab39ff-801f-4244-a054-726b9b2eab01_model.json +3 -0
  15. understandingtheroleofselfattentionforefficientspeechrecognition/6eab39ff-801f-4244-a054-726b9b2eab01_origin.pdf +3 -0
  16. understandingtheroleofselfattentionforefficientspeechrecognition/full.md +430 -0
  17. understandingtheroleofselfattentionforefficientspeechrecognition/images.zip +3 -0
  18. understandingtheroleofselfattentionforefficientspeechrecognition/layout.json +3 -0
  19. unifyinglikelihoodfreeinferencewithblackboxoptimizationandbeyond/233cc708-146f-4dc3-9d0a-3b19ec3ef5ab_content_list.json +3 -0
  20. unifyinglikelihoodfreeinferencewithblackboxoptimizationandbeyond/233cc708-146f-4dc3-9d0a-3b19ec3ef5ab_model.json +3 -0
  21. unifyinglikelihoodfreeinferencewithblackboxoptimizationandbeyond/233cc708-146f-4dc3-9d0a-3b19ec3ef5ab_origin.pdf +3 -0
  22. unifyinglikelihoodfreeinferencewithblackboxoptimizationandbeyond/full.md +490 -0
  23. unifyinglikelihoodfreeinferencewithblackboxoptimizationandbeyond/images.zip +3 -0
  24. unifyinglikelihoodfreeinferencewithblackboxoptimizationandbeyond/layout.json +3 -0
  25. universalapproximationunderconstraintsispossiblewithtransformers/73cdadad-7133-44f3-93c2-e97d9e3a6b1e_content_list.json +3 -0
  26. universalapproximationunderconstraintsispossiblewithtransformers/73cdadad-7133-44f3-93c2-e97d9e3a6b1e_model.json +3 -0
  27. universalapproximationunderconstraintsispossiblewithtransformers/73cdadad-7133-44f3-93c2-e97d9e3a6b1e_origin.pdf +3 -0
  28. universalapproximationunderconstraintsispossiblewithtransformers/full.md +435 -0
  29. universalapproximationunderconstraintsispossiblewithtransformers/images.zip +3 -0
  30. universalapproximationunderconstraintsispossiblewithtransformers/layout.json +3 -0
  31. vaeapproximationerrorelboandexponentialfamilies/59188a09-537b-42ec-af57-2e24f01fd95a_content_list.json +3 -0
  32. vaeapproximationerrorelboandexponentialfamilies/59188a09-537b-42ec-af57-2e24f01fd95a_model.json +3 -0
  33. vaeapproximationerrorelboandexponentialfamilies/59188a09-537b-42ec-af57-2e24f01fd95a_origin.pdf +3 -0
  34. vaeapproximationerrorelboandexponentialfamilies/full.md +657 -0
  35. vaeapproximationerrorelboandexponentialfamilies/images.zip +3 -0
  36. vaeapproximationerrorelboandexponentialfamilies/layout.json +3 -0
  37. valuegradientweightedmodelbasedreinforcementlearning/9c4cdf72-62f3-4a8d-9611-3d82d5c1330d_content_list.json +3 -0
  38. valuegradientweightedmodelbasedreinforcementlearning/9c4cdf72-62f3-4a8d-9611-3d82d5c1330d_model.json +3 -0
  39. valuegradientweightedmodelbasedreinforcementlearning/9c4cdf72-62f3-4a8d-9611-3d82d5c1330d_origin.pdf +3 -0
  40. valuegradientweightedmodelbasedreinforcementlearning/full.md +393 -0
  41. valuegradientweightedmodelbasedreinforcementlearning/images.zip +3 -0
  42. valuegradientweightedmodelbasedreinforcementlearning/layout.json +3 -0
  43. variationalmethodsforsimulationbasedinference/b631abec-cbcf-48ed-8993-df86144885bb_content_list.json +3 -0
  44. variationalmethodsforsimulationbasedinference/b631abec-cbcf-48ed-8993-df86144885bb_model.json +3 -0
  45. variationalmethodsforsimulationbasedinference/b631abec-cbcf-48ed-8993-df86144885bb_origin.pdf +3 -0
  46. variationalmethodsforsimulationbasedinference/full.md +624 -0
  47. variationalmethodsforsimulationbasedinference/images.zip +3 -0
  48. variationalmethodsforsimulationbasedinference/layout.json +3 -0
  49. vitgantrainingganswithvisiontransformers/f2dbc46a-fc3b-4c65-bcb7-5c78ee2242d4_content_list.json +3 -0
  50. vitgantrainingganswithvisiontransformers/f2dbc46a-fc3b-4c65-bcb7-5c78ee2242d4_model.json +3 -0
understandingandpreventingcapacitylossinreinforcementlearning/78e042a6-627b-4e6e-8bce-398dd81324a1_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6e43137038b99a45936f9d58b83d44e9698c1b5213386a9caad987f021e38695
3
+ size 129174
understandingandpreventingcapacitylossinreinforcementlearning/78e042a6-627b-4e6e-8bce-398dd81324a1_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1c7192802073a489b982d837c445221807d8edec1a6d920d6cf4c2794772e32d
3
+ size 146416
understandingandpreventingcapacitylossinreinforcementlearning/78e042a6-627b-4e6e-8bce-398dd81324a1_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0dc3671c8ea54622200c0e7eff808c0cb72cc72dc2c97d80b08698cc86012a2
3
+ size 3839217
understandingandpreventingcapacitylossinreinforcementlearning/full.md ADDED
@@ -0,0 +1,560 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # UNDERSTANDING AND PREVENTING CAPACITY LOSS IN REINFORCEMENT LEARNING
2
+
3
+ Clare Lyle
4
+
5
+ Department of Computer Science
6
+ University of Oxford*
7
+
8
+ Mark Rowland & Will Dabney
9
+
10
+ DeepMind
11
+
12
+ # ABSTRACT
13
+
14
+ The reinforcement learning (RL) problem is rife with sources of non-stationarity, making it a notoriously difficult problem domain for the application of neural networks. We identify a mechanism by which non-stationary prediction targets can prevent learning progress in deep RL agents: capacity loss, whereby networks trained on a sequence of target values lose their ability to quickly update their predictions over time. We demonstrate that capacity loss occurs in a range of RL agents and environments, and is particularly damaging to performance in sparse-reward tasks. We then present a simple regularizer, Initial Feature Regularization (InFeR), that mitigates this phenomenon by regressing a subspace of features towards its value at initialization, leading to significant performance improvements in sparse-reward environments such as Montezuma's Revenge. We conclude that preventing capacity loss is crucial to enable agents to maximally benefit from the learning signals they obtain throughout training.
15
+
16
+ # 1 INTRODUCTION
17
+
18
+ Deep reinforcement learning has achieved remarkable successes in a variety of tasks (Mnih et al., 2015; Moravčík et al., 2017; Silver et al., 2017; Abreu et al., 2019), but its impressive performance is mirrored by its brittleness and sensitivity to seemingly innocuous design choices (Henderson et al., 2018). In sparse-reward environments in particular, even different random seeds of the same algorithm can attain dramatically different performance outcomes. This presents a stark contrast to supervised learning, where existing approaches are reasonably robust to small hyperparameter changes, random seed inputs, and GPU parallelisation libraries. Much of the brittleness of deep RL algorithms has been attributed to the non-stationary nature of the prediction problems to which deep neural networks are applied in RL tasks. Indeed, naive applications of supervised learning methods to the RL problem may require explicit correction for non-stationarity and bootstrapping in order to yield similar improvements (Bengio et al., 2020; Raileanu et al., 2020).
19
+
20
+ We hypothesize that the non-stationary prediction problems agents face in RL may be a driving force in the challenges described above. RL agents must solve a sequence of similar prediction tasks as they iteratively improve their value function accuracy and their policy (Dabney et al., 2021). Solving each subproblem (at least to the extent that the agent's policy is improved) in this sequence is necessary to progress to the next subproblem. Ideally, features learned to solve one subproblem would enable forward transfer to future problems. However, prior work on both supervised and reinforcement learning (Ash & Adams, 2020; Igl et al., 2021; Fedus et al., 2020) suggests that the opposite is true: networks trained on a sequence of similar tasks are prone to overfitting, exhibiting negative transfer.
21
+
22
+ The principal thesis of this paper is that over the course of training, deep RL agents lose some of their capacity to quickly fit new prediction tasks, and in extreme cases this capacity loss prevents the agent entirely from making learning progress. We present a rigorous empirical analysis of this
23
+
24
+ phenomenon which considers both the ability of networks to learn new target functions via gradient-based optimization methods, and their ability to linearly disentangle states' feature representations. We confirm that agents' ability to fit new target functions declines over the course of training in several environments from the Atari suite (Bellemare et al., 2013) and non-stationary reward prediction tasks. We further find that the ability of representations to linearly distinguish different states, a proxy for their ability to represent certain functions, quickly diminishes in sparse-reward environments, leading to representation collapse, where the feature outputs for every state in the environment inhabit a low-dimensional – or possibly even zero – subspace. Crucially, we find evidence that sufficient capacity is a necessary condition in order for agents to make learning progress. Finally, we propose a simple regularization technique, Initial Feature Regularization (InFeR), to prevent representation collapse by regressing a set of auxiliary outputs towards their value under the network's initial parameters. We show that this regularization scheme mitigates capacity loss in a number of settings, and also enables significant performance improvements in a number of RL tasks.
25
+
26
+ One striking take-away from our results is that agents trained on so-called 'hard exploration' games such as Montezuma's Revenge can attain significant improvements over existing competitive baselines without using smart exploration algorithms, given a suitable representation learning objective. This suggests that the poor performance of deep RL agents in sparse-reward environments is not solely due to inadequate exploration, but rather also in part due to poor representation learning. Investigation into the interplay between representation learning and exploration, particularly in sparse-reward settings, thus presents a particularly promising direction for future work.
27
+
28
+ # 2 BACKGROUND
29
+
30
+ We consider the reinforcement learning problem wherein an agent interacts with an environment formalized by a Markov Decision Process $\mathcal{M} = (\mathcal{X},\mathcal{A},R,\mathcal{P},\gamma)$ , where $\mathcal{X}$ denotes the state space, $\mathcal{A}$ the action space, $R$ the reward function, $\mathcal{P}$ the transition probability function, and $\gamma$ the discount factor. We will be primarily interested in value-based RL, where the objective is to learn the value function $Q^{\pi}:\mathcal{X}\times \mathcal{A}\to \mathbb{R}$ associated with some (possibly stochastic) policy $\pi :\mathcal{X}\rightarrow \mathcal{P}(\mathcal{A})$ , defined as $Q^{\pi}(x,a) = \mathbb{E}_{\pi ,\mathcal{P}}[\sum_{k = 0}^{\infty}\gamma^{k}R(x_{k},a_{k})|x_{0} = x,a_{0} = a]$ . In particular, we are interested in learning the value function associated with the optimal policy $\pi^{*}$ which maximizes the expected discounted sum of rewards from any state.
31
+
32
+ In Q-Learning (Watkins & Dayan, 1992), the agent performs updates to minimize the distance between a predicted action-value function $Q$ and the bootstrap target defined as
33
+
34
+ $$
35
+ \mathcal {T} Q (x, a) = \mathbb {E} \left[ R \left(x _ {0}, a _ {0}\right) + \gamma \max _ {a ^ {\prime} \in \mathcal {A}} Q \left(x _ {1}, a ^ {\prime}\right) \mid x _ {0} = x, a _ {0} = a \right]. \tag {1}
36
+ $$
37
+
38
+ In most practical settings, updates are performed with respect to sampled transitions rather than on the entire state space. The target can be computed for a sampled transition $(x_{t},a_{t},r_{t},x_{t + 1})$ as $\hat{\mathcal{T}} Q(x_t,a_t) = r_t + \gamma \max_aQ(x_{t + 1},a)$ .
39
+
40
+ When a deep neural network is used as a function approximator (the deep RL setting), $Q$ is defined to be the output of a neural network with parameters $\theta$ , and updates are performed by gradient descent on sampled transitions $\tau = (x_{t},a_{t},r_{t},x_{t + 1})$ . A number of tricks are often used to improve stability: the sample-based objective is minimized following stochastic gradient descent based on minibatches sampled from a replay buffer of stored transitions, and a separate set of parameters $\bar{\theta}$ is used to compute the targets $Q_{\bar{\theta}}(x_{t + 1},a_{t + 1})$ which is typically updated more slowly than the network's online parameters. This yields the following loss function, given a sampled transition $\tau$ :
41
+
42
+ $$
43
+ \ell_ {T D} \left(Q _ {\theta}, \tau\right) = \left(R _ {t + 1} + \gamma \max _ {a ^ {\prime}} Q _ {\bar {\theta}} \left(X _ {t + 1}, a ^ {\prime}\right) - Q _ {\theta} \left(X _ {t}, A _ {t}\right)\right) ^ {2}. \tag {2}
44
+ $$
45
+
46
+ In this work we will be interested in how common variations on this basic learning objective shape agents' learning dynamics, in particular the dynamics of the learned representation, or features. We will refer to the outputs of the final hidden layer of the network (i.e. the penultimate layer)
47
+
48
+ ![](images/62612a89cbcdfc1388b680f967dc79a6710f5d805e9dc05657726d1b1b6ffd83.jpg)
49
+ Figure 1: Networks trained to fit a sequence of different targets on MNIST data see increasing error on new target functions with the number of tasks.
50
+
51
+ ![](images/5cb7fb9d38efc379a198c5eb92592d2122dddb4072a86b35cd33b38090a4dee9.jpg)
52
+ Figure 2: Networks see reduced ability to fit new targets over the course of training in two demonstrative Atari environments.
53
+
54
+ as its features, denoted $\phi_{\theta}(x)$ . Our choice of the penultimate layer is motivated by prior literature studying representations in RL (Ghosh & Bellemare, 2020; Kumar et al., 2021), although many works studying representation learning consider the outputs of earlier layers as well. In general, the features of a neural network are defined to be the outputs of whatever layer is used to compute additional representation learning objectives.
55
+
56
+ # 3 CAPACITY LOSS
57
+
58
+ Each time a value-based RL agent discovers a new source of reward in its environment or, in the case of temporal difference methods, updates its value estimate, the prediction problem it needs to solve changes. Over the course of learning, such an agent must solve a long sequence of target prediction problems as its value function and policy evolve. Studies of neural networks in supervised learning suggest that this sequential fitting of new targets may be harmful to a network's ability to adapt to new targets (Achille et al., 2018, see Section 5 for further details, e.g.). This presents a significant challenge to deep RL agents undergoing policy improvement, for which it is necessary to quickly make significant changes to the network's predictions even late in the training process. In this section, we show that training on a sequence of prediction targets can lead to a reduced ability to fit new targets in deep neural networks, a phenomenon that we term capacity loss. Further, we show that an agent's inability to quickly update its value function to distinguish states presents a barrier to performance improvement in deep RL agents.
59
+
60
+ # 3.1 TARGET-FITTING CAPACITY
61
+
62
+ The parameters of a neural network not only determine the network's current outputs, but also influence how these outputs will evolve over time. A network which outputs zero because its final-layer weights are zero will evolve differently from one whose ReLU units are fully saturated at zero despite both outputting the same function Maas et al. (2013) – in particular, it will have a much easier time adapting to new targets. It is this capacity to fit new targets that is crucial for RL agents to obtain performance improvements, and which frames our perspective on representation learning. We are interested in identifying when an agent's current parameters are flexible enough to allow it to perform gradient updates that meaningfully change its predictions based on new reward information in the environment or evolving bootstrap targets, a notion formalized in the following definition.
63
+
64
+ Definition 1 (Target-fitting capacity). Let $P_X \in \mathcal{P}(X)$ be some distribution over inputs $X$ and $P_{\mathcal{F}}$ a distribution over a family of real-valued functions $\mathcal{F}$ with domain $X$ . Let $\mathcal{N} = (g_{\theta}, \theta_0)$ represent the pairing of a neural network architecture with some initial parameters $\theta_0$ , and $\mathcal{O}$ correspond to an optimization algorithm for supervised learning. We measure the target-fitting capacity of $\mathcal{N}$ under the optimizer $\mathcal{O}$ to fit the data-generating distribution $\mathcal{D} = (P_X, P_{\mathcal{F}})$ as follows:
65
+
66
+ $$
67
+ \mathcal {C} (\mathcal {N}, \mathcal {O}, \mathcal {D}) = \mathbb {E} _ {f \sim P _ {\mathcal {F}}} \left[ \mathbb {E} _ {x \sim P _ {X}} \left[ \left(g _ {\theta^ {\prime}} (x) - f (x)\right) ^ {2} \right] \right] \quad \text {w h e r e} \theta^ {\prime} = \mathcal {O} \left(\theta_ {0}, P _ {X}, f\right). \tag {3}
68
+ $$
69
+
70
+ Our definition of capacity measures the ability of a network to reach a new set of targets within a limited optimization budget from its current parameters and optimizer state. The choice of optimization budget and target distribution are left as hyperparameters, and different choices result in different notions of capacity. In reinforcement learning we ultimately care about the network's ability to fit its Bellman targets quickly, however the ability on its own will not necessarily be a useful measure: for example, a network which can only output the zero function will attain low Bellman error immediately on a sparse-reward environment, but will fail to produce useful updates to improve the policy. Our evaluations of this measure will use target functions that are independent of the current network parameters to avoid these pathologies; the effect of this choice is explored further in Appendix B.2.
71
+
72
+ The process of training a neural network to fit a set of labels must by necessity change some properties of the network. Works studying the information bottleneck principle (Tishby & Zaslavsky, 2015), for example, identify a compression effect of training on the latent representation, where inputs with similar labels are mapped to similar feature vectors. This compression can benefit generalization on the current task, but in the face of the rapidly-changing nature of the targets used in value iteration algorithms may harm the learning process by impeding the network's ability to fit new targets. This motivates two hypotheses. First: that networks trained to iteratively fit a sequence of dissimilar targets will lose their capacity to fit new target functions (Hypothesis 1), and second: the non-stationary prediction problems in deep RL also result in capacity loss (Hypothesis 2).
73
+
74
+ To evaluate Hypothesis 1, we construct a series of toy iterative prediction problems on the MNIST data set, a widely-used computer vision benchmark which consists of images of handwritten digits and corresponding labels. We first fit a series of labels computed by a randomly initialized neural network $f_{\theta}$ : we transform input-label pairs $(x,y)$ from the canonical MNIST dataset to $(x,f_{\theta}(x))$ , where $f_{\theta}(x)$ is the network output. To generate a new task, we simply reinitialize the network. Given a target function, we then train the network for a fixed budget from the parameters obtained at the end of the previous iteration, and repeat this procedure of target initialization and training 30 times. We use a subset of MNIST inputs of size 1000 to reduce computational cost. In Figure 1 we see that the networks trained on this task exhibit decreasing ability to fit later target functions under a fixed optimization budget. This effect is strongest in the smaller networks, matching the intuition that solving tasks which are more challenging for the network will result in greater capacity loss. We consider two other tasks in Appendix B.2, obtaining similar results, as well as a wider range of architectures. We find that sufficiently over-parameterized networks (on the order of one million parameters for a task with one thousand data points) exhibit positive forward transfer, however models which are not over-parameterized relative to the task difficulty consistently exhibit increasing error as the number of targets trained on grows. This raises a question concerning our second hypothesis: are the deep neural networks used by value-based RL agents on popular benchmarks in the over- or under-parameterized regime?
75
+
76
+ To evaluate Hypothesis 2, we train an agent's network checkpoints sampled over the course of training to fit randomly generated target functions. We provide full details of this procedure in Appendix C. We generate target functions by randomly initializing neural networks with new parameters, and use the outputs of these networks as targets for regression. We then load initial parameters from an agent checkpoint at some time $t$ , sample inputs from the replay buffer, and regress on the random target function evaluated on these inputs. We then evaluate the mean squared error after training for fifty thousand steps. We consider a DQN (Mnih et al., 2015), a QR-DQN (Dabney et al., 2018), and a Rainbow agent (Hessel et al., 2018). We observe in all three cases that as training progresses agents' checkpoints on average get modestly worse at fitting these random targets in most environments; due to space limitations we only show two representative environments where this phenomenon occurs in Figure 2, and defer the full evaluation to Appendix C.3.
77
+
78
+ # 3.2 REPRESENTATION COLLAPSE AND PERFORMANCE
79
+
80
+ The notion of capacity in Definition 1 measures the ability of a network to eventually represent a given target function. This definition reflects the intuition that capacity should not increase over time.
81
+
82
+ ![](images/ef703af2623d8974758cf4478a601c839be57b3adf9d5f3582053b5278624fca.jpg)
83
+ Figure 3: Feature rank and performance over the course of training for Montezuma's Revenge (left) and Pong (right). We observe that feature rank is higher for environments and auxiliary tasks which provide denser reward signals than for sparse reward problems.
84
+
85
+ ![](images/2935b2693f1dfcdc1bc1d1753d5fb460b364e133436b9d467a973503317524a0.jpg)
86
+
87
+ ![](images/793e03412136163134abc5cf3df06823f6efa0cb89767615c945f3c919535270.jpg)
88
+
89
+ ![](images/a72348e039536396a32c3992c229b2a84b3645eee90b3c24e824f0a1bc7b47e1.jpg)
90
+
91
+ However, deep RL agents must quickly update their predictions in order to make efficient learning progress. We present an alternate measure of capacity that captures this property which we call the feature rank, as it corresponds to an approximation of the rank of a feature embedding. Intuitively, the feature rank measures how easily states can be distinguished by updating only the final layer of the network. This approximately captures a network's ability to quickly adapt to changes in the target function, while being significantly cheaper to estimate than Definition 1.
92
+
93
+ Definition 2 (Feature rank). Let $\phi : X \to \mathbb{R}^d$ be a feature mapping. Let $\mathbf{X}_n \subset X$ be a set of $n$ states in $X$ sampled from some fixed distribution $P$ . Fix $\varepsilon \geq 0$ , and let $\phi(\mathbf{X}_n) \in \mathbb{R}^{n \times d}$ denote the matrix whose rows are the feature embeddings of states $x \in \mathbf{X}_n$ . Let $\mathrm{SVD}(M)$ denote the multiset of singular values of a matrix $M$ . The feature rank of $\phi$ given input distribution $P$ is defined to be
94
+
95
+ $$
96
+ \rho (\phi , P, \epsilon) = \lim _ {n \rightarrow \infty} \mathbb {E} _ {\mathbf {X} _ {n} \sim P} [ | \{\sigma \in \operatorname {S V D} \left(\frac {1}{\sqrt {n}} \phi \left(\mathbf {X} _ {n}\right)\right) | \sigma > \varepsilon \} | ] \tag {4}
97
+ $$
98
+
99
+ for which a consistent estimator can be constructed as follows, letting $\mathbf{X} \subseteq X$ , $|\mathbf{X}| = n$
100
+
101
+ $$
102
+ \hat {\rho} _ {n} (\phi , \mathbf {X}, \epsilon) = | \{\sigma \in \operatorname {S V D} \left(\frac {1}{\sqrt {n}} \phi (\mathbf {X})\right) | \sigma > \varepsilon \} |. \tag {5}
103
+ $$
104
+
105
+ The numerical feature rank (henceforth abbreviated to feature rank) is equal to the dimension of the subspace spanned by the features when $\varepsilon = 0$ and the state space $\mathcal{X}$ is finite, and its estimator is equal to the numerical rank (Golub et al., 1976; Meier & Nakatsukasa, 2021) of the sampled feature matrix. For $\epsilon > 0$ , it throws away small components of the feature matrix. We show that $\rho$ is well-defined and that $\hat{\rho}_n$ is a consistent estimator in Appendix A.1. Our analysis of the feature rank resembles that of Kumar et al. (2021), but differs in two important ways: first, our estimator does not normalize by the maximal singular value. This allows us to more cleanly capture representation collapse, where the network features, and thus also their singular values, converge to zero. Second, we are interested in the capacity of agents with unlimited opportunity to interact with the environment, rather than in the data-limited regime. We compare our findings on feature rank against the $srank$ used in prior work in Appendix B.2.
106
+
107
+ In our empirical evaluations, we train a double DQN (DDQN) agent, a quantile regression (QRDQN) agent, and a double DQN agent with an auxiliary random cumulant prediction task (RC DQN) (Dabney et al., 2021), on environments from the Atari suite, then evaluate $\hat{\rho}_n$ with $n = 5000$ on agent checkpoints obtained during training. We consider two illustrative environments: Montezuma's Revenge (sparse reward), and Pong (dense reward), deferring two additional environments to Appendix C.3. We run 3 random seeds on each environment-agent combination.
108
+
109
+ We visualize agents' feature rank and performance in Figure 3. Non-trivial prediction tasks, either value prediction in the presence of environment rewards or auxiliary tasks, lead to higher feature rank. In Montezuma's Revenge, the higher feature rank induced by RC DQN corresponds to higher performance, but this auxiliary loss can have a detrimental effect on learning progress in complex, dense-reward games presumably due to interference between the random rewards and the true learning objective. Unlike in target-fitting capacity, we only see a consistent downward trend in sparse-reward environments, where a number of agents, most dramatically QR-DQN, exhibit representation collapse. We discuss potential mechanisms behind this trend in Appendix A.2.
110
+
111
+ ![](images/9883728fa342cac50153f0dbdeadb8d12618fcdcd4e382c275e6473bc411efde.jpg)
112
+ Figure 4: (a): Agent capacity vs human-normalized score in games where Rainbow does not achieve superhuman performance. While feature rank does not appear to solely determine agent performance, there is a positive correlation between feature rank and human-normalized score. Bottom row contains Rainbow agents trained with the regularizer presented in Equation 6. (b) An 'unlucky' seed from our evaluations on the sparsified version of Pong, where learning progress occurs only after the agent recovers from representation collapse.
113
+
114
+ ![](images/b36d777809f01d6113a330d366564e29756eefdd032d9ff9483244e38f5f0d88.jpg)
115
+
116
+ Figure 4a reveals a correlation between learning progress and feature rank for the Rainbow agent (Hessel et al., 2018) trained on challenging games in the Atari 2600 suite where it fails to achieve human-level performance; this trend is also reflected for other agents described in the next section. The points on the scatterplot largely fall into two clusters: those with low feature rank, which attain less than half of the average human score, and those with high feature rank, which tend to attain higher scores. Having a sufficiently high feature rank thus appears to be a necessary condition for learning progress, as demonstrated by the learning curves shown in Figure 4b, which highlights an unlucky agent trained on a variant of Pong (described in Appendix C.2) which experienced representation collapse, and only solved the task after it had overcome this collapse. However, high feature rank does not appear to be sufficient for learning progress. Other properties of an agent, such as its ability to perform accurate credit assignment, the stability of its update rule, the suitability of its optimizer, its exploration policy, and countless others, must be appropriately tuned to a given task in order for progress to occur. Simply mapping inputs to a relatively uniform distribution in feature space will not overcome failures in other components of the RL problem. An agent must be able to both collect useful learning signals from the environment and effectively update its predictions in response to those signals in order to make learning progress. This section has shown that at least in some instances poor performance can be attributed to the latter property.
117
+
118
+ # 4 INFER: MITIGATING CAPACITY LOSS WITH FEATURE REGULARIZATION
119
+
120
+ The previous section showed that capacity loss occurs in deep RL agents trained with online data, and in some cases appears to be a bottleneck to performance. We now consider how it might be mitigated, and whether explicitly regularizing the network to preserve its initial capacity improves performance in environments where representation collapse occurs. Our approach involves a function-space perspective on regularization, encouraging networks to preserve their ability to output linear functions of their features at initialization.
121
+
122
+ # 4.1 INFER: FEATURE-SPACE REGULARIZATION
123
+
124
+ Much like parameter regularization schemes seek to keep parameters close to their initial values, we wish to keep a network's ability to fit new targets close to its initial value. We motivate our approach with the intuition that a network which has preserved the ability to output functions it could easily fit at initialization should be better able to adapt to new targets. To this end, we will regress a set of network outputs towards the values they took at initialization. Our method, Initial Feature Regularization (InFeR), applies an $\ell_2$ regularization penalty on the output-space level by regressing
125
+
126
+ ![](images/a9cf70d5044224c77adcd7a859e8549fc6ab0cc1c19d6a100e379acaa0232256.jpg)
127
+ (a)
128
+
129
+ ![](images/f0f2e7aeb79650113d328126a02e5bdebc7e06b4244435aff81e217da6bf377b.jpg)
130
+ (b)
131
+
132
+ ![](images/2a74481000e9afb783b44d5587b28fb325cf16e8cf8f8309bb2e011d79efff19.jpg)
133
+
134
+ ![](images/6c82b84eb3d11e1d1510509769c79cc9bf82de08c276a261c1139d8b0c3492c6.jpg)
135
+ (c)
136
+
137
+ ![](images/a84d9ff8b75a2cfe1afbf1ff50a31a89a571f743d24dbefb02e1da29fe32301b.jpg)
138
+
139
+ ![](images/b991bcaa9cac732edcc555a2211c7ee698a2bbe22636e71f46f862655e7b3ee7.jpg)
140
+ Figure 5: (a) Visualization of InFeR. (b) Analysis of the effect of InFeR on capacity loss. (c) Effect of InFeR on performance in Montezuma's Revenge with respect to Rainbow and Double DQN baselines. (d) Performance of InFeR relative to Rainbow on all 57 Atari games.
141
+
142
+ a set of auxiliary network output heads to match their values at initialization. Similar perspectives have been used to prevent catastrophic forgetting in continual learning (Benjamin et al., 2019).
143
+
144
+ In our approach, illustrated in Figure 5, we begin with a fixed deep Q-learning neural network with parameters $\theta$ , and modify the network architecture by adding $k$ auxiliary linear prediction heads $g_{i}$ on top of the feature representation $\phi_{\theta}$ . We take a snapshot of the agent's parameters at initialization $\theta_0$ , and use the outputs of the $k$ auxiliary heads under these parameters as auxiliary prediction targets. We then compute the mean squared error between the outputs of the heads under the current parameters $g_{i}(x;\theta_{t})$ and their outputs at initialization $g_{i}(x;\theta_{0})$ . This approach has the interpretation of amplifying and preserving subspaces of the features that were present at initialization. In practice, we find that scaling the auxiliary head outputs by a constant $\beta$ increases this amplification effect. This results in the following form of our regularization objective, where we let $\mathcal{B}$ denote the replay buffer sampling scheme used by the agent:
145
+
146
+ $$
147
+ \mathcal {L} _ {\text {I n F e R}} \left(\theta , \theta_ {0}; \mathcal {B}, \beta\right) = \mathbb {E} _ {x \sim \mathcal {B}} \left[ \sum_ {i = 1} ^ {k} \left(g _ {i} (x; \theta) - \beta g _ {i} \left(x; \theta_ {0}\right)\right) ^ {2} \right]. \tag {6}
148
+ $$
149
+
150
+ We evaluate the effect of incorporating this loss in both DDQN (Van Hasselt et al., 2016) and Rainbow (Hessel et al., 2018) agents, and include the relative performance improvement obtained by the InFeR agents over Rainbow on 57 games from the Atari 2600 suite in Figure 5, deferring the comparison to DDQN, where the regularizer improved performance slightly on average but only yielded significant improvements on sparse-reward games, to the appendix. We observe a net improvement over the Rainbow baseline by incorporating the InFeR objective, with significant improvements in games where agents struggle to obtain human performance. The evaluations in Figure 5 are for $k = 10$ heads with $\beta = 100$ and $\alpha = 0.1$ , and we show the method's robustness to these hyperparameters in Appendix C.1. We further observe in Figure 5 that the InFeR loss reduces target-fitting error on the non-stationary MNIST prediction task described in the previous section. We show in Appendix C.2 that InFeR tends to increase the feature rank of agents trained on the Atari domain over the entire course of training; we study the early training period in Appendix C.3.
151
+
152
+ The striking improvement obtained in the sparse-reward Montezuma's Revenge environment begs the question of whether such results can be replicated in other RL agents. We follow the same experimental procedure as before, but now use the DDQN agent; see Figure 5. We find that adding InFeR to the DDQN objective produces a similar improvement as does adding it to Rainbow, leading the DDQN agent, which only follows an extremely naive $\epsilon$ -greedy exploration strategy and obtains zero reward at all points in training, to exceed the performance of the noisy networks approach taken by Rainbow in the last 40 million training frames. This leads to two intriguing conclusions: first, that agents which are explicitly regularized to prevent representation collapse can make progress in sparse reward problems without the help of good exploration strategies; and second, that this form of regularization yields significantly larger performance improvements in the presence of additional algorithm design choices that are designed to speed up learning progress.
153
+
154
+ # 4.2 UNDERSTANDING HOW INFER WORKS
155
+
156
+ While InFeR improves performance on average across the Atari games, its improvements are concentrated principally on games where the baseline rainbow agent performs significantly below the human baseline. It further slows down progress in a subset of environments such as Asteroids and Jamesbond. We now investigate two hypothesized mechanisms by which this regularizer may shape the agent's representation, in the hopes of explaining this differential effect on performance. Hypothesis 1: InFeR improves performance by preserving a random subspace of the representation that the final linear layer can use to better predict the value function. The effect of the regularizer on other aspects of the representation learning dynamics does not influence performance. Hypothesis 2: The InFeR loss slows down the rate at which the learned features at every layer of the network can drift from their initialization in function space, improving the learning dynamics of the entire network to prevent feature collapse and over-fitting to past targets. The precise subspace spanned by the auxiliary weights is not directly useful to value function estimation.
157
+
158
+ To evaluate Hypothesis 1, we concatenate the outputs of a randomly initialized network to the feature outputs of the network used to learn the Q-function, and train a linear layer on top of these joint learned and random features. If Hypothesis 1 were true, then we would expect this architecture to perform comparably to the InFeR agents, as the final linear layer has access to a randomly initialized feature subspace. Instead, Figure 6 shows that the performance of the agents with access to the random features to be comparable to that of the vanilla Rainbow agents, confirming that the effect of InFeR on earlier layers is crucial to its success.
159
+
160
+ We now consider Hypothesis 2. InFeR limits the degrees of freedom with which a network can collapse its representation, which may reduce the flexibility of the network to make the changes necessary to fit new value functions, slowing down progress in environments where representation collapse is not a concern. In such cases, increasing the dimension of the layer to which we apply InFeR should give the network more degrees of freedom to fit its targets, and so reduce the performance gap induced by the regularization. We test this hypothesis by doubling the width of the penultimate network layer and comparing the performance of InFeR and Rainbow on games where
161
+
162
+ ![](images/f1d0ff4264846548ac4a5233e5efaf6d99df4fe27d9f73d111a9a5edb5338ab3.jpg)
163
+ Figure 6: Left: agent performance does not improve over baseline when random features are added to the representation. Right: doubling the width of the neural network narrows the performance gap in games on which InFeR under-performed relative to Rainbow.
164
+
165
+ ![](images/c5792bdf5a5fdf0180bc2cd7bb29b97b8812955d1924df40226a8224a33092ae.jpg)
166
+
167
+ InFeR hurt performance in the original network. We refer to this agent as DoubleRainbow. We see in Figure 6 that increasing the network's size reduces, eliminates, or in some cases reverses the performance gap induced by InFeR in the smaller architecture. We therefore conclude that the principal mechanism by which InFeR affects performance is by regularizing the entire network's learning dynamics.
168
+
169
+ # 5 RELATED WORK
170
+
171
+ Suitably designed auxiliary tasks have been shown to improve performance and encourage learned representations to satisfy desirable properties in a wide range of settings (Jaderberg et al., 2017; Veeriah et al., 2019; Gelada et al., 2019; Machado et al., 2018), with further insight given by prior analysis of the geometry (Bellemare et al., 2019) and stability (Ghosh & Bellemare, 2020) of value functions in RL. Our analysis of linear algebraic properties of agents' representations is complemented by prior works which leverage similar ideas to analyze implicit under-parameterization (Kumar et al., 2021) and spectral normalization (Gogianu et al., 2021) in deep RL agents, and by the framework proposed by Lyle et al. (2021) to study learning dynamics in deep RL agents. In contrast to prior work, which treats the layers of the network which come before the features as a black box, we explicitly study the properties and learning dynamics of the whole network.
172
+
173
+ A separate line of work has studied the effect of interference between sub-tasks in both reinforcement learning (Schaul et al., 2019; Teh et al., 2017; Igl et al., 2021) and supervised learning settings (Sharkey & Sharkey, 1995; Ash & Adams, 2020; Beck et al., 2021). Of particular interest has been catastrophic forgetting, with prior work proposing novel training algorithms using regularization (Kirkpatrick et al., 2017; Bengio et al., 2014; Lopez-Paz & Ranzato, 2017) or distillation (Schwarz et al., 2018; Silver & Mercer, 2002; Li & Hoiem, 2017) approaches. Methods which involve reinitializing a new network have seen particular success at reducing interference between tasks in deep reinforcement learning (Igl et al., 2021; Teh et al., 2017; Rusu et al., 2016; Fedus et al., 2020). A closer relative of our approach is that of Benjamin et al. (2019), which also applies a function-space regularization approach, but which involves saving input-output pairs into a memory bank with the goal of mitigating catastrophic forgetting. Unlike prior work, InFeR seeks to maximize performance on future tasks, works without task labels, and incurs a minimal, fixed computational cost independent of the number of prediction problems seen during training.
174
+
175
+ # 6 CONCLUSIONS
176
+
177
+ This paper has demonstrated a fundamental challenge facing deep RL agents: loss of the capacity to distinguish states and represent new target functions over the course of training. We have shown that this phenomenon is particularly salient in sparse-reward settings, in some cases leading to complete collapse of the representation and preventing the agent from making learning progress. Our analysis revealed a number of nuances to this phenomenon, showing that larger networks trained on rich learning signals are more robust to capacity loss than smaller networks trained to fit sparse targets. To address this challenge, we proposed a regularizer to preserve capacity, yielding improved performance across a number of settings in which deep RL agents have historically struggled to match human performance. Further investigation into this method suggests that it is performing a form of function-space regularization on the neural network, and that settings where it appears the task reduces performance are actually instances of under-parameterization relative to the difficulty of the environment. Particularly notable is the effect of incorporating InFeR in the hard exploration game of Montezuma's Revenge: its success here suggests that effective representation learning can allow agents to learn good policies in sparse-reward environments even under naive exploration strategies. Our findings open up a number of exciting avenues for future work in reinforcement learning and beyond to better understand how to preserve plasticity in non-stationary prediction tasks.
178
+
179
+ # ACKNOWLEDGEMENTS
180
+
181
+ Thanks to Georg Ostrovski, Michael Hutchinson, Joost van Amersfoort, Daniel Guo, Diana Borsa, Anna Harutyunyan, Razvan Pascanu, Caglar Gulcehre, Srivatsan Srvinivasan, and Remi Munos for helpful discussions and feedback on early versions of this paper. CL is supported by an Open Philanthropy AI Fellowship.
182
+
183
+ # REFERENCES
184
+
185
+ Miguel Abreu, Luis Paulo Reis, and Nuno Lau. Learning to run faster in a humanoid robot soccer environment through reinforcement learning. In *Robot World Cup*, pp. 3-15. Springer, 2019.
186
+ Alessandro Achille, Matteo Rovere, and Stefano Soatto. Critical learning periods in deep networks. In International Conference on Learning Representations, 2018.
187
+ Jordan Ash and Ryan P Adams. On warm-starting neural network training. In Neural Information Processing Systems (NeurIPS), 2020.
188
+ Nathan Beck, Durga Sivasubramanian, Apurva Dani, Ganesh Ramakrishnan, and Rishabh Iyer. Effective evaluation of deep active learning on image classification tasks. arXiv, 2021.
189
+ Marc Bellemare, Will Dabney, Robert Dadashi, Adrien Ali Taiga, Pablo Samuel Castro, Nicolas Le Roux, Dale Schuurmans, Tor Lattimore, and Clare Lyle. A geometric perspective on optimal representations for reinforcement learning. In Neural Information Processing Systems (NeurIPS), 2019.
190
+ Marc G Bellemare, Yavar Naddaf, Joel Veness, and Michael Bowling. The arcade learning environment: An evaluation platform for general agents. Journal of Artificial Intelligence Research, 47: 253-279, 2013.
191
+ Emmanuel Bengio, Joelle Pineau, and Doina Precup. Correcting momentum in temporal difference learning. In NeurIPS Deep Reinforcement Learning Workshop, 2020.
192
+ Yoshua Bengio, Mehdi Mirza, Ian Goodfellow, Aaron Courville, and Xia Da. An empirical investigation of catastrophic forgetting in gradient-based neural networks. In International Conference on Learning Representations (ICLR), 2014.
193
+ Ari Benjamin, David Rolnick, and Konrad Kording. Measuring and regularizing networks in function space. In International Conference on Learning Representations (ICLR), 2019.
194
+ Will Dabney, Mark Rowland, Marc Bellemare, and Rémi Munos. Distributional reinforcement learning with quantile regression. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 32, 2018.
195
+ Will Dabney, André Barreto, Mark Rowland, Robert Dadashi, John Quan, Marc G Bellemare, and David Silver. The value-improvement path: Towards better representations for reinforcement learning. In AAAI Conference on Artificial Intelligence, 2021.
196
+ William Fedus, Dibya Ghosh, John D Martin, Marc G Bellemare, Yoshua Bengio, and Hugo Larochelle. On catastrophic interference in Atari 2600 games. arXiv, 2020.
197
+ Carles Gelada, Saurabh Kumar, Jacob Buckman, Ofir Nachum, and Marc G Bellemare. DeepMDP: Learning continuous latent space models for representation learning. In International Conference on Machine Learning (ICML), 2019.
198
+ Dibya Ghosh and Marc G Bellemare. Representations for stable off-policy reinforcement learning. In International Conference on Machine Learning (ICML), 2020.
199
+ Florin Gogianu, Tudor Berariu, Mihaela Rosca, Claudia Clopath, Lucian Busoniu, and Razvan Pascanu. Spectral normalisation for deep reinforcement learning: an optimisation perspective. arXiv preprint arXiv:2105.05246, 2021.
200
+ Gene Golub, Virginia Klema, and Gilbert W Stewart. Rank degeneracy and least squares problems. Technical report, STANFORD UNIV CA DEPT OF COMPUTER SCIENCE, 1976.
201
+ Peter Henderson, Riashat Islam, Philip Bachman, Joelle Pineau, Doina Precup, and David Meger. Deep reinforcement learning that matters. In Proceedings of the AAAI conference on artificial intelligence, volume 32, 2018.
202
+
203
+ Matteo Hessel, Joseph Modayil, Hado Van Hasselt, Tom Schaul, Georg Ostrovski, Will Dabney, Dan Horgan, Bilal Piot, Mohammad Azar, and David Silver. Rainbow: Combining improvements in deep reinforcement learning. In AAAI conference on artificial intelligence, 2018.
204
+ Maximilian Igl, Gregory Farquhar, Jelena Luketina, Wendelin Boehmer, and Shimon Whiteson. Transient non-stationarity and generalisation in deep reinforcement learning. In International Conference on Learning Representations (ICLR), 2021.
205
+ Max Jaderberg, Volodymyr Mnih, Wojciech Marian Czarnecki, Tom Schaul, Joel Z Leibo, David Silver, and Koray Kavukcuoglu. Reinforcement learning with unsupervised auxiliary tasks. In International Conference on Learning Representations (ICLR), 2017.
206
+ Diederik P Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In *ICLR (Poster)*, 2015.
207
+ James Kirkpatrick, Razvan Pascanu, Neil Rabinowitz, Joel Veness, Guillaume Desjardins, Andrei A Rusu, Kieran Milan, John Quan, Tiago Ramalho, Agnieszka Grabska-Barwinska, Demis Hassabis, Claudia Clopath, Dharshan Kumaran, and Raia Hadsell. Overcoming catastrophic forgetting in neural networks. Proceedings of the National Academy of Sciences, 114(13):3521-3526, 2017.
208
+ Aviral Kumar, Rishabh Agarwal, Dibya Ghosh, and Sergey Levine. Implicit under-parameterization inhibits data-efficient deep reinforcement learning. In International Conference on Learning Representations (ICLR), 2021.
209
+ Zhizhong Li and Derek Hoiem. Learning without forgetting. IEEE transactions on pattern analysis and machine intelligence, 40(12):2935-2947, 2017.
210
+ David Lopez-Paz and Marc'Aurelio Ranzato. Gradient episodic memory for continual learning. In Neural Information Processing Systems (NIPS), 2017.
211
+ Clare Lyle, Mark Rowland, Georg Ostrovski, and Will Dabney. On the effect of auxiliary tasks on representation dynamics. In Artificial Intelligence and Statistics (AISTATS), 2021.
212
+ Andrew L Maas, Awni Y Hannun, Andrew Y Ng, et al. Rectifier nonlinearities improve neural network acoustic models. In Proceedings of the International Conference on Machine Learning. CiteSeer, 2013.
213
+ Marlos C. Machado, Clemens Rosenbaum, Xiaoxiao Guo, Miao Liu, Gerald Tesauro, and Murray Campbell. Eigenoption discovery through the deep successor representation. In International Conference on Learning Representations (ICLR), 2018.
214
+ Maike Meier and Yuji Nakatsukasa. Fast randomized numerical rank estimation. arXiv e-prints, pp. arXiv-2105, 2021.
215
+ Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A Rusu, Joel Veness, Marc G Bellemare, Alex Graves, Martin Riedmiller, Andreas K Fidjeland, Georg Ostrovski, Stig Petersen, Charles Beattie, Amir Sadik, Ioannis Antonoglou, Helen King, Dharshan Kumaran, Daan Wierstra, Shane Legg, and Demis Hassabis. Human-level control through deep reinforcement learning. Nature, 518(7540):529-533, 2015.
216
+ Matej Moravčík, Martin Schmid, Neil Burch, Viliam Lisý, Dustin Morrill, Nolan Bard, Trevor Davis, Kevin Waugh, Michael Johanson, and Michael Bowling. DeepStack: Expert-level artificial intelligence in heads-up no-limit poker. Science, 356(6337):508-513, 2017. ISSN 0036-8075.
217
+ John Quan and Georg Ostrovski. DQN Zoo: Reference implementations of DQN-based agents, 2020. URL http://github.com/deepmind/dqn_zoo.
218
+ Roberta Raileanu, Maxwell Goldstein, Denis Yarats, Ilya Kostrikov, and Rob Fergus. Automatic data augmentation for generalization in reinforcement learning. arXiv, 2020.
219
+
220
+ Andrei A. Rusu, Sergio Gomez Colmenarejo, Caglar Gülçehre, Guillaume Desjardins, James Kirkpatrick, Razvan Pascanu, Volodymyr Mnih, Koray Kavukcuoglu, and Raia Hadsell. Policy distillation. In International Conference on Learning Representations (ICLR), 2016.
221
+ Tom Schaul, Diana Borsa, Joseph Modayil, and Razvan Pascanu. Ray interference: a source of plateaus in deep reinforcement learning. arXiv, 2019.
222
+ Jonathan Schwarz, Wojciech Czarnecki, Jelena Luketina, Agnieszka Grabska-Barwinska, Yee Whye Teh, Razvan Pascanu, and Raia Hadsell. Progress & compress: A scalable framework for continual learning. In International Conference on Machine Learning (ICML), 2018.
223
+ Noel E Sharkey and Amanda JC Sharkey. An analysis of catastrophic interference. Connection Science, 1995.
224
+ Daniel L Silver and Robert E Mercer. The task rehearsal method of life-long learning: Overcoming impoverished data. In Conference of the Canadian Society for Computational Studies of Intelligence, pp. 90-101, 2002.
225
+ David Silver, Julian Schrittwieser, Karen Simonyan, Ioannis Antonoglou, Aja Huang, Arthur Guez, Thomas Hubert, Lucas Baker, Matthew Lai, Adrian Bolton, Yutian Chen, Timothy Lillicrap, Fan Hui, Laurent Sifre, George van den Driessche, Thore Graepel, and Demis Hassabis. Mastering the game of Go without human knowledge. Nature, 550(7676):354-359, 2017.
226
+ Yee Whye Teh, Victor Bapst, Wojciech M Czarnecki, John Quan, James Kirkpatrick, Raia Hadsell, Nicolas Heess, and Razvan Pascanu. Distral: Robust multitask reinforcement learning. In Neural Information Processing Systems (NIPS), 2017.
227
+ Naftali Tishby and Noga Zaslavsky. Deep learning and the information bottleneck principle. In 2015 IEEE information theory workshop (itw), pp. 1-5. IEEE, 2015.
228
+ Hado Van Hasselt, Arthur Guez, and David Silver. Deep reinforcement learning with double Q-learning. In AAAI Conference on Artificial Intelligence, 2016.
229
+ Vivek Veeriah, Matteo Hessel, Zhongwen Xu, Richard Lewis, Janarthanan Rajendran, Junhyuk Oh, Hado van Hasselt, David Silver, and Satinder Singh. Discovery of useful questions as auxiliary tasks. In Neural Information Processing Systems (NeurIPS), 2019.
230
+ Christopher JCH Watkins and Peter Dayan. Q-learning. Machine learning, 8(3-4):279-292, 1992.
231
+
232
+ # A THEORETICAL RESULTS
233
+
234
+ # A.1 ESTIMATOR CONSISTENCY
235
+
236
+ We here show that our estimator of the agent's feature rank is consistent. First recall
237
+
238
+ $$
239
+ \left(\frac {1}{\sqrt {n}} \Phi_ {n}\right) ^ {\top} \left(\frac {1}{\sqrt {n}} \Phi_ {n}\right) = \frac {1}{n} \sum_ {i = 1} ^ {n} \phi \left(x _ {i}\right) \phi \left(x _ {i}\right) ^ {\top}. \tag {7}
240
+ $$
241
+
242
+ The following property of the expected value holds
243
+
244
+ $$
245
+ \mathbb {E} _ {x \sim P} [ \phi (x) \phi (x) ^ {\top} ] = \mathbb {E} \left[ \frac {1}{n} \sum_ {i = 1} ^ {n} \phi \left(x _ {i}\right) \phi \left(x _ {i}\right) ^ {\top} \right]. \tag {8}
246
+ $$
247
+
248
+ It is then straightforward to apply the strong law of large numbers. To be explicit, we consider an element of $M = \mathbb{E}[\phi \phi^{\top}]$ , $M_{ij}$ .
249
+
250
+ $$
251
+ \mathbb {E} \left[\left(\phi (x) \phi (x) ^ {\top}\right) _ {i j} \right] = M _ {i j} = \mathbb {E} \left[ \phi_ {i} (x) \phi_ {j} (x) \right] \Rightarrow \sum_ {k = 1} ^ {n} \frac {1}{n} \phi_ {i} \left(x _ {k}\right) \phi_ {j} \left(x _ {k}\right) \stackrel {{a. s.}} {\rightarrow} M _ {i j}. \tag {9}
252
+ $$
253
+
254
+ Since we have convergence for any $M_{ij}$ , we get convergence of the resulting matrix to $M$ . Because the singular values of $\Phi$ are the eigenvalues of $M$ and the eigenvalues are continuous functions of that matrix, the eigenvalues of $M_{n}$ converge to those of $M$ almost surely. Then for almost all values of $\epsilon$ , the threshold estimator $N(\lambda_1,\ldots ,\lambda_k;\epsilon) = |\{\lambda_i > \epsilon \} |$ will converge to $N(\operatorname {spec}(M);\epsilon)$ . Specifically, the estimator will be convergent for all values of $\epsilon$ which are not eigenvalues of $M$ itself.
255
+
256
+ # A.2 FEATURE DYNAMICS
257
+
258
+ We apply similar analysis to that of Lyle et al. (2021) to better understand the effect of sparse-reward environments on representation collapse. To do so, we consider the setting where $\Phi_t$ are features and $w_t$ a linear function approximator which jointly parameterize a value function $V_t = \langle \Phi_t(x), w_t \rangle$ . We will be interested in studying a continuous-time approximation to TD learning, where the discrete-time expected updates
259
+
260
+ $$
261
+ \Phi_ {t} \leftarrow \Phi_ {t} + \alpha \nabla_ {\Phi} V _ {t} \left[ \left(\gamma P ^ {\pi} - I\right) V _ {t} + R ^ {\pi} \right] \tag {10}
262
+ $$
263
+
264
+ $$
265
+ w _ {t} \leftarrow w _ {t} + \beta \nabla_ {w} V _ {t} \left(\gamma P ^ {\pi} - I\right) V _ {t} + R ^ {\pi} ] \tag {11}
266
+ $$
267
+
268
+ are translated into a continuous-time flow, described by the following equations.
269
+
270
+ $$
271
+ \partial_ {t} \Phi_ {t} = \alpha (\gamma P ^ {\pi} - I) \Phi_ {t} \left(w _ {t} w _ {t} ^ {\top}\right) + R ^ {\pi} w _ {t} ^ {\top} \tag {12}
272
+ $$
273
+
274
+ $$
275
+ \partial_ {t} w _ {t} = \beta \Phi_ {t} ^ {\top} \left[ \left(\gamma P ^ {\pi} - I\right) \Phi_ {t} w _ {t} + R ^ {\pi} \right], \tag {13}
276
+ $$
277
+
278
+ where $P^{\pi} \in \mathbb{R}^{\mathcal{X} \times \mathcal{X}}$ is the matrix of state-transition probabilities under $\pi$ , and $R^{\pi} \in \mathbb{R}^{\mathcal{X}}$ is the vector of expected rewards.
279
+
280
+ One of the key take-aways of prior works is that under certain assumptions, a tabular value function following continuous-time TD dynamics will converge to its limiting value $V^{\pi}$ along the principal components of the environment's transition matrix. In the function-approximation case described above, the dynamics of the features $\Phi_t$ are somewhat more complex. However, it turns out that under certain training regimes, we can obtain similar convergence results for the features. We therefore turn our attention to ensemble prediction, where $M$ linear prediction 'heads', each using a separate weight vector $w_{t}^{m}$ ( $m = 1, \dots, M$ ) are all trained to regress on the TD targets using the shared feature representation of the state as input, resulting in the following dynamics.
281
+
282
+ $$
283
+ \partial_ {t} \Phi_ {t} ^ {M} = \alpha \sum_ {m = 1} ^ {M} \left(R ^ {\pi} + \gamma P ^ {\pi} \Phi_ {t} ^ {M} w _ {t} ^ {m} - \Phi_ {t} ^ {M} w _ {t} ^ {m}\right) \left(w _ {t} ^ {m}\right) ^ {\top}, \tag {14}
284
+ $$
285
+
286
+ $$
287
+ \partial_ {t} w _ {t} ^ {m} = \beta \left(\Phi_ {t} ^ {M}\right) ^ {\top} \left(R ^ {\pi} + \gamma P ^ {\pi} \Phi_ {t} ^ {M} w _ {t} ^ {m} - \Phi_ {t} w _ {t} ^ {m}\right). \tag {15}
288
+ $$
289
+
290
+ We now restate the result of Lyle et al. (2021) regarding the behaviour of the representation in the limit of many ensemble heads.
291
+
292
+ Theorem 1 (Lyle et al., 2021). For $M \in \mathbb{N}$ , let $(\Phi_t^M)_{t \geq 0}$ be the solution to Equation 14, with each $w_t^m$ for $m = 1, \ldots, M$ initialised independently from $N(0, \sigma_M^2)$ , and fixed throughout training $(\beta = 0)$ . We consider two settings: first, where the learning rate $\alpha$ is scaled as $\frac{1}{M}$ and $\sigma_M^2 = 1$ for all $M$ , and second where $\sigma_M^2 = \frac{1}{M}$ and the learning rate $\alpha$ is equal to 1. These two settings yield the following dynamics, respectively:
293
+
294
+ $$
295
+ \lim _ {M \rightarrow \infty} \partial_ {t} \Phi_ {t} ^ {M} \stackrel {P} {=} - (I - \gamma P ^ {\pi}) \Phi_ {t} ^ {M}, a n d \tag {16}
296
+ $$
297
+
298
+ $$
299
+ \lim _ {M \rightarrow \infty} \partial_ {t} \Phi_ {t} ^ {M} \stackrel {{D}} {{=}} - (I - \gamma P ^ {\pi}) \Phi_ {t} ^ {M} + R ^ {\pi} \epsilon^ {\top}, \epsilon \sim \mathcal {N} (0, I). \tag {17}
300
+ $$
301
+
302
+ The corresponding limiting trajectories for a fixed initialisation $\Phi_0\in \mathbb{R}^{\mathcal{X}\times d}$ , are therefore given respectively by
303
+
304
+ $$
305
+ \begin{array}{l} \lim _ {M \rightarrow \infty} \Phi_ {t} ^ {M} \stackrel {P} {=} \exp (- t (I - \gamma P ^ {\pi})) \Phi_ {0}, a n d (18) \\ \lim _ {M \to \infty} \Phi_ {t} ^ {M} \stackrel {D} {=} \exp (- t (I - \gamma P ^ {\pi})) (\Phi_ {0} - (I - \gamma P ^ {\pi}) ^ {- 1} R ^ {\pi} \varepsilon^ {\top}) \\ + \left(I - \gamma P ^ {\pi}\right) ^ {- 1} R ^ {\pi} \varepsilon^ {\top}, \epsilon \sim \mathcal {N} (0, I). (19) \\ \end{array}
306
+ $$
307
+
308
+ One important corollary of this result occurs in sparse-reward environments under sub-optimal policies, where $R^{\pi} = \mathbf{0}$ . In this case, we see that the representation converges precisely to the zero vector.
309
+
310
+ Corollary 1. Let $\Phi_t^M$ , $(w)_{i=1}^M$ be defined as in Theorem 1. Then if $R^\pi = 0$ , the feature representation converges to the zero vector for every state, independent of whether the learning rate $\alpha$ is scaled as $\frac{1}{M}$ or the linear weight initialization variance scales as $\frac{1}{M}$ . In particular:
311
+
312
+ $$
313
+ \lim _ {t \rightarrow \infty} \lim _ {M \rightarrow \infty} \Phi_ {t} ^ {M} \stackrel {P} {=} \mathbf {0}. \tag {20}
314
+ $$
315
+
316
+ As a result, we have that the feature rank of $\Phi$ will also tend to zero
317
+
318
+ $$
319
+ \forall \epsilon > 0 \quad \lim _ {t \rightarrow \infty} \lim _ {M \rightarrow \infty} | \{\sigma \in S V D \left(\Phi_ {t} ^ {M}\right) | \sigma > \epsilon \} | \stackrel {P} {=} 0. \tag {21}
320
+ $$
321
+
322
+ Proof. The proof of this result follows from a straightforward application of Theorem 1, setting $R^{\pi} = 0$ and letting $t \to \infty$ . We can obtain an analogous result for the rank of $\Phi_t^M$ when $P^{\pi}$ is diagonalizable by noting that for any eigenvector $v_i$ of $P^{\pi}$ , the value of $v_i^\top \Phi_t^M v_i$ evolves as $c\exp (-t\lambda_i)$ for some constant $c$ that depends on $\Phi_0^M$ . In this case, we obtain a limiting value of 1 for the rank so long as $P^{\pi}$ corresponds to an ergodic Markov chain.
323
+
324
+ The setting of this result is distinct from that of deep neural network representation dynamics, as neural networks use discrete optimization steps, finite learning rates, and typically do not leverage linear ensembles. However, we emphasize two crucial observations that suggest the intuition developed in this setting may be relevant: first, in sparse reward environments the representation will be pushed to zero along dimensions spanned by the linear weights used to compute outputs. Once sufficiently many independent weight vectors are being used to make predictions, this effectively forces every dimension of the representation to fit the zero vector output. We would therefore expect representation collapse to be particularly pronounced in the QR-DQN agents trained on sparse-reward environments, as in this setting we obtain many independently initialized heads all identically trying to fit the zero target.
325
+
326
+ Second, in the presence of ReLU activations and stochastic optimization, the trajectories followed by the learned features in deep neural networks run the risk of getting 'trapped' in negative values. If these features would normally tend to small values close to zero (as we would expect in agents following similar dynamics to those obtained in Theorem 1), this increases the risk of unit saturation, where the representation may get trapped in bad local minima. This appears to be what happens in the QR-DQN agents trained on sparse-reward environments such as Montezuma's Revenge.
327
+
328
+ # B SEQUENTIAL SUPERVISED LEARNING
329
+
330
+ # B.1 DETAILS: TARGET-FITTING CAPACITY IN NON-STATIONARY MNIST
331
+
332
+ In addition to our evaluations in the Atari domain, we also consider a variant of the MNIST dataset in which the labels change over the course of training.
333
+
334
+ - Inputs and Labels: We use 1000 randomly sampled input digits from the MNIST dataset and assign either binary or random targets.
335
+ - Distribution Shift: We divide training into $N = 30$ or $N = 10$ iterations depending on the structure of the target function. In each iteration, a target function is randomly sampled, and the network's parameters obtained at the end of the previous iteration are used the initial values for a new optimization run. We use the Adam (Kingma & Ba, 2015) optimizer with learning rate $1 \in -3$ , and train to minimize the mean squared error between the network outputs and the targets for either 3000 or 5000 steps depending on the nature of the target function.
336
+ - Architecture: we use a standard fully-connected architecture with ReLU activations, and vary with width and depth of the network. The parameters at the start of the procedure are initialized following the defaults in the Jax Haiku library.
337
+
338
+ We note that the dataset sizes, training budgets, and network sizes in the following experiments are all relatively small. This was chosen to enable short training times and decrease the computational budget necessary too replicate the experiments. The particular experiment parameters were selected to be the fastest and cheapest settings in which we could observe the capacity loss phenomenon, while still being nontrivial tasks. In general, we found that capacity loss is easiest to measure in a 'sweet spot' where the task for a given architecture is simple enough for a freshly-initialized network to attain low loss, but complex enough that the network cannot trivially solve the task. In the findings of the following section, we see how some of the larger architectures don't exhibit capacity loss on 'easier' target functions, but do on more challenging ones that exhibit less structure. This suggests that replicating these results in larger networks will be achievable, but will require re-tuning the task difficulty to the larger network's capacity.
339
+
340
+ # B.2 ADDITIONAL EVALUATIONS
341
+
342
+ We expand on the MNIST target-fitting task shown in the main paper by considering how network size and target function structure influences capacity loss.
343
+
344
+ - Random-MNIST (smooth) this task uses the images from the MNIST dataset as inputs. The goal is to perform regression on the outputs of a randomly initialized, fixed neural network. We use a small network for this task, consisting of two width-30 fully connected hidden layers with ReLU activations which feed into a final linear layer which outputs a scalar. Because the network outputs are small, we scale them by 10 so that it is not possible to get a low loss by simply predicting the network's bias term. This task, while randomly generated, has some structure: neural networks tend to map similar inputs to similar outputs, and so the inductive bias of the targets will match that of the function approximator we train on them.
345
+ - Hash-MNIST (non-smooth) uses the same neural network architecture as the previous task to generate targets, however rather than using the scaled network output as the target, we multiply the output by 1e3 and feed it into a sine function. The resulting targets no longer have the structure induced by the neural network. This task amounts to memorizing a set of labels for the input points.
346
+ - Threshold-MNIST (sparse) replaces the label of an image with a binary indicator variable indicating whether the label is smaller than some threshold. To construct a sequence of tasks, we set the threshold at iteration $i$ to be equal to $i$ . This means that at the first iteration,
347
+
348
+ # Target-fitting error: non-smooth
349
+
350
+ ![](images/5c74946487bcc7f5ca8ffb4ab7147a7a7da74eac1795e346c186676fa17de0cc.jpg)
351
+
352
+ ![](images/267b0fa4ad4a19190a310ade5860d390366f61c21ecd6a7662a15aa357de22bc.jpg)
353
+
354
+ ![](images/d38d3f086411bf9b398b4fd78528a49c89132b80668168251e234eefab4e8d0f.jpg)
355
+
356
+ Figure 7: Mean squared error at the end of training on each iteration of the hash-MNIST task. Target-fitting error increases over time in smaller networks, but increasing the depth or width of the network slows down capacity loss, enabling positive transfer in the largest networks we studied.
357
+ ![](images/2bad7ef6492122b143e6ee693e51b8b24a53d4bb28593f13a783b6c13c97e05a.jpg)
358
+ Loss Feature num. rank Feature srank
359
+
360
+ ![](images/7cf18b4fc072828980bd2bde1a49ff31b272df7d76cd341596cd084c29b6473d.jpg)
361
+
362
+ ![](images/fcf151622f8fc4a359b054e43a0a4ff0d52e8653e8f30294a77b959dbd250d70.jpg)
363
+
364
+ the labels are of the form $(x,0)$ for all inputs $x$ . At the second iteration, they are of the form $(x,\delta(y < 1))$ , where $y$ is the digit in the image $x$ , and so on.
365
+
366
+ We consider MLP networks of varying widths and depths, noting that the network architecture used to generate the random targets is fixed and independent of the approximating architecture. We are interested in evaluating whether factors such as target function difficulty, network parameterization, and number of target functions previously fit influence the network's ability to fit future target functions. Our results are shown in Figure 7, 8, and 9. We visualize rank and feature rank of the features output at the network's penultimate layer, in addition to the loss obtained at the end of each iteration.
367
+
368
+ # B.3 EFFECT OF INFER ON TARGET-FITTING CAPACITY IN MNIST
369
+
370
+ In addition to our study of the Atari suite, we also study the effect of InFeR on the non-stationary MNIST reward prediction task with a fully-connected architecture; see Figure 10. We find that it significantly mitigates the decline in target-fitting capacity demonstrated in Figure 1.
371
+
372
+ # C ATARI EVALUATIONS
373
+
374
+ We now present full evaluations of many of the quantities described in the paper, along with a study of the sensitivity of InFeR to its hyperparameters. We use the same training procedure for all of the figures in this section, loading agent parameters from checkpoints to compute the quantities shown.
375
+
376
+ # C.1 HYPERPARAMETER SENSITIVITY OF INFER IN DEEP REINFORCEMENT LEARNING AGENTS
377
+
378
+ We report results of hyperparameter sweeps over the salient hyperparameters relating to InFeR, so as to assess the robustness of the method. For both the DDQN and Rainbow agents augmented with InFeR, we sweep over the number of auxiliary predictions (1, 5, 10, 20), the cumulant scale used in the predictions (10, 100, 200), and the scale of the auxiliary loss (0.01, 0.05, 0.1, 0.2). We consider
379
+
380
+ # Target-fitting error: smooth
381
+
382
+ ![](images/b6e03440dca282c5d82711a1900c2f60ae4d9da387f625602bbb10279f6f4fe2.jpg)
383
+
384
+ ![](images/bf422c0f6b249fb60ba2dd8b782e10647b8ec355059f522b85ef2aa6853463c5.jpg)
385
+
386
+ ![](images/a806dc849a4b364bde37a61b10361e8ee234b4d30b891f96eb1a512c3c54d84d.jpg)
387
+
388
+ Figure 8: Mean squared error after 2e3 training steps on the random-MNIST task. Target-fitting error increases over time in under-parameterized networks, but increasing the depth or width of the network slows down capacity loss, enabling positive transfer in the largest network we studied.
389
+ ![](images/b1284f977c58755307e101089e9ba10474dda60cb88aa2cfa34a9b25c1d6b77a.jpg)
390
+ Loss Feature num. rank Feature srank
391
+
392
+ ![](images/5658fdd396daf2d482ec4cc8e4c6854f29c860e5764c7ae22604dcf3180273bf.jpg)
393
+
394
+ ![](images/0b8c5f5bd41ca1a7fe6a598f60adb52900f062aaa8198942b86018c9862354be.jpg)
395
+
396
+ # Target-fitting error: sparse
397
+
398
+ ![](images/6bc5dd3cbb47dc82cac88c96854f809f3e79c27b688db9229385f2e0eb0a4482.jpg)
399
+
400
+ ![](images/eb6a205efb4f7ca941686a9e5dc3a8160fe5b3f603fcdffc6d4f3bf70ca11f65.jpg)
401
+
402
+ ![](images/f4df9c001e3866dabc9977d173daadca29da448ed9e9cbc1694f7f03e6244953.jpg)
403
+
404
+ Figure 9: Mean squared error after 2e3 training steps on the threshold-MNIST task. Target-fitting error increases over time in under-parameterized networks, but increasing the depth or width of the network slows down capacity loss, enabling positive transfer in the largest network we studied.
405
+ ![](images/93b00e0f1994cff4e0684afa65f43cc1982672e779f94374f1d28888943f7b80.jpg)
406
+ Loss Feature num. rank Feature srank
407
+
408
+ ![](images/02f6963c51e1e516f356467fdc0efc7dfd8d1b29e10c4e1c86433f15a6a3ae16.jpg)
409
+
410
+ ![](images/a216bbebc986511125bdde11b98c4479e5ef3464658d6a0a8017e951c8cbe64e.jpg)
411
+
412
+ ![](images/4ec8be1ca931e03d37d96355e1a17eecf8e49f523181619ccf2c0194905429f8.jpg)
413
+
414
+ ![](images/b12a7a7c0ead11913c005b33f72901ce15d7ccb01b8acfc47c61923ed362a8ca.jpg)
415
+ Target-fitting error on hash prediction task over time
416
+
417
+ ![](images/948cb9378a7699c5b4d629d68c10d5cdeffbce60ffaeb62958399368f1a7a2d6.jpg)
418
+
419
+ ![](images/caa4e0f3b8178db99710ca2c55df6266f3fc343cdc42a2a3b7029b1384fae56e.jpg)
420
+
421
+ ![](images/e6ae8caca732343af4c7cb62c9c5e85c52bc682c1e447e2bd3441858b42f36a9.jpg)
422
+
423
+ ![](images/14ff0cb85d67585a20329dbe36076b1476c01b77e9110a579ea29b540e109427.jpg)
424
+
425
+ ![](images/be3ba1e292e0f7480d375edfb88f972ec33783a000d12354650b1a59cc02a80c.jpg)
426
+
427
+ ![](images/b709588ea0caa5fb3aa36f29f173ce4b6c5535beb06d9dc904dec71792b53e2d.jpg)
428
+ Target-fitting error on threshold prediction task over time
429
+
430
+ ![](images/e8a6d4a47801e77d023da06e479e354c2828391a5c0c7c1893b7ded696e34c46.jpg)
431
+
432
+ ![](images/e64a13457fe2b3cc5388ad696cf860a0181a45ff9b61bae75914b039aad00ca4.jpg)
433
+
434
+ ![](images/9c736f16b0767e894128b4c2ed1b8b0ccafbd87c1b81ff63a86d80e7a79c90eb.jpg)
435
+
436
+ ![](images/75a1eb864eb151658a49d47968207baa3256d55efef2f1d3d55698c805e2f4df.jpg)
437
+
438
+ ![](images/2c1d3d5073a561efca79883279642c215003b7ec6742235ecdf6290a0b163285.jpg)
439
+ Figure 10: Effect of adding InFeR to the regression objective in a random reward prediction problem on the non-stationary MNIST environment studied previously. We see that the InFeR objective produces networks that can consistently outperform those trained with a standard regression objective, exhibiting minimal capacity loss in comparison to the same network architecture trained on the same sequence of targets.
440
+
441
+ ![](images/8baa9819b06229e3462c0e4d521c1ad3b011af149a772f348f62f0e5c5d6c7ed.jpg)
442
+ Target-fitting error on random prediction task over time
443
+
444
+ ![](images/495ea556c96f69efb139caac426754637f609da3d2b79d67604cb1545ae8f596.jpg)
445
+
446
+ ![](images/b32eb3e452aa8a180618d3c39f2c007066937a75c4cbd3c6f635128ae37732b5.jpg)
447
+
448
+ ![](images/63fa586b1ef7700d1ee9d884f2c1a321374ea92e0e601251f33740ad0a767241.jpg)
449
+
450
+ ![](images/2677e1bf7870be0362ec7235d42c7f5764226dd5f17be8c7a0aeeecdb9cdf6be.jpg)
451
+
452
+ ![](images/f0fd782d4f733976a0138c2c78efe666130d050dd7a7f6f6bc8f07329187a251.jpg)
453
+ Figure 11: Hyperparameter sweeps for the DDQN+InFeR agent. Each contour plot shows average capped human-normalized score at the end of training marginalized over all hyperparameters not shown on its axes.
454
+
455
+ ![](images/6ab0e39d1da2a17bd8c6f72b94e8171c181eaf08b90ded0cb17fc18f83ca7c25.jpg)
456
+
457
+ ![](images/c6a6607d2a88d667106c7407aa0d17582d55eae45bfbc26f102ab032988354a8.jpg)
458
+
459
+ the capped human-normalized return across four games (Montezuma's Revenge, Hero, James Bond, and MsPacman), and run each hyperparameter configuration with 3 seeds. Results are shown in Figure 11 for the DDQN agent; we compare performance as each pair of hyperparameters varies (averaging across the other hyperparameter, games, and seeds, and the last five evaluation runs of each agent). Corresponding results for Rainbow are given in Figure 12.
460
+
461
+ ![](images/6552599d4c79e00c06efe7ada25cc9b8714d0035031079ce0ae02ca187e86dea.jpg)
462
+ Figure 12: Hyperparameter sweeps for the Rainbow+InFeR agent. Each contour plot shows average capped human-normalized score at the end of training marginalized over all hyperparameters not shown on its axes.
463
+
464
+ ![](images/3da6f13c9269c428575a2977d55d8a09c8d3b776fad3aab9eabefc0cfd21b032.jpg)
465
+
466
+ ![](images/8e66a3b40ea863006678b3e67ee0b317e8a6de2a29d75ad35feed541dd608fc7.jpg)
467
+
468
+ ![](images/c9f383d8a7d8a519830a4dd8cfffaf4b65e4d84b7b9ba7b12faa95b58abda066.jpg)
469
+
470
+ ![](images/9d9857d263df4c8d3843fa9ddf1ac8856acea3ff961a4ce569b5a0b743622411.jpg)
471
+ Figure 13: Feature rank and performance of RL agents on demonstrative Atari environments.
472
+
473
+ ![](images/0699b047b6560c3c8c233ea53ce7c0d3dd82084594973218392b1306df9609a0.jpg)
474
+
475
+ ![](images/bac2e8f7c9f640aac032dccbaafa6a2345857ce1b3ce16ad5391758dced78935.jpg)
476
+
477
+ ![](images/be833303ba94c847d2d1a945f7c12518e6767d33e280054eabba77430aa424d0.jpg)
478
+
479
+ ![](images/755b182c76ecf92297e26e3e90c72e8895598a6b57024d7c932cc99ebb580daf.jpg)
480
+
481
+ ![](images/685ead010fb4d1675d158fccc54d747f0ad92c2d480de069814e1f69e9820f87.jpg)
482
+
483
+ ![](images/03a6ada2f77706ddec40d74a0e9247b794f8ef1e9ede8701c6dfa6d3577920aa.jpg)
484
+
485
+ ![](images/298ae178fe3419f8052e92de81a5daf3099af4d4ffc61ebaf28c544a47b68f00.jpg)
486
+
487
+ ![](images/85dcb4e0b654a8a4f5bafb3449bd665d4375952416cf9cf8bac1abc5c54d4eff.jpg)
488
+
489
+ - Agent: We train a Rainbow agent (Hessel et al., 2018) with the same architecture and hyperparameters as are described in the open-source implementation made available by Quan & Ostrovski (2020). We additionally add InFeR, as described in Section 4, with 10 heads, gradient weight 0.1 and scale 100.
490
+ - Training: We follow the training procedure found in the Rainbow implementation mentioned above. We train for 200 million frames, with 500K evaluation frames interspersed every 1M training frames. We save the agent parameters and replay buffer every 10M frames to estimate feature dimension and target-fitting capacity.
491
+
492
+ # C.2 FEATURE RANK
493
+
494
+ We first extend the results shown in Figure 3 to two additional games: Seaquest, and a sparsified version of Pong in which the agent does not receive negative rewards when the opponent scores. In these settings, we stored agent checkpoints once every 10M frames in each 200M frame trajectory, and used 5000 sampled inputs from the agent's replay buffer to estimate the feature rank, using the cutoff $\epsilon = 0.01$ . Results are shown in Figure 13.
495
+
496
+ We further evaluate the evolution of feature rank in agents trained on all 57 games in the arcade learning environment. We find that the decline in dimension after the first checkpoint at 10M frames shown across the different agents in the selected games also occurs more generally in Rainbow agents across most environments in the Atari benchmark. We also show that in most cases adding InFeR mitigates this phenomenon. Our observations here do not show a uniform decrease in feature rank or a uniformly beneficial effect of InFeR. The waters become particularly muddied in settings where neither the Rainbow nor Rainbow+InFeR agent consistently make learning progress such as in tennis, solaris, and private eye. It is outside the scope of this work to identify precisely why the agents do not make learning progress in these settings, but it does not appear to be due to the type of representation collapse that can be effectively prevented by InFeR.
497
+
498
+ Procedure. We compute the feature rank by sampling $n = 50000$ transitions from the replay buffer and take the set of origin states as the input set. We then compute a $n \times d$ matrix whose row $i$ is given by the output of the penultimate layer of the neural network given input $S_{i}$ . We then take the singular value decomposition of this matrix and count the number of singular values greater than 0.01 to get an estimate of the dimension of the network's representation layer.
499
+
500
+ In most games, we see a decline in feature rank after the first checkpoint at 10M frames. Strikingly, this decline in dimension holds even in the online RL setting where the agent's improving policy presumably leads it to observe a more diverse set of states over time, which under a fixed representation would tend to increase the numerical rank of the feature matrix. This indicates that even in the face of increasing state diversity, agents' representations face strong pressure towards degeneracy. It is worth noting, however, that the agents in dense-reward games do tend to see their feature rank increase significantly early in training; this is presumably due to the network initially learning to disentangle the visually similar states that yield different bootstrap targets.
501
+
502
+ ![](images/3ba562f7a74b608836c2acf49c5cdd40cae2888b6032e75319e70b736a1d5303.jpg)
503
+ Figure 14: feature rank of agent representations over the course of training on all 57 games in the Atari benchmark. We compare Rainbow against Rainbow+InFeR. Rainbow+InFeR does not uniformly prevent decreases in feature rank across all games, but on average it has a beneficial effect on preserving representation dimension.
504
+
505
+ # C.3 TARGET-FITTING CAPACITY
506
+
507
+ In this section we examine the target-fitting capacity of neural networks trained with DQN, QR-DQN, and Rainbow over the course of 50 million environment frames on five games in the Atari benchmark (amidar, montezuma's revenge, pong, bowling, and hero). Every 1 million training frames we save a checkpoint of the neural network weights and replay buffer. For each checkpoint, we generate a random target network by initializing network weights with a new random seed. We then train the checkpoint network to predict the output of this random target network for 10000 mini-batch updates (batch size of 32) under a mean squared error loss, for states sampled from the first 100,000 frames in the checkpoint's replay buffer. Furthermore, we repeat this for 10 seeds used to initialize the random target network weights.
508
+
509
+ The results of this experiment are shown in Figure 15 (in orange), where the solid lines show means and shaded regions indicate standard deviations over all seeds (both agent seeds (5) and target fitting seeds (10), for a total of 50 trials). We also show srank and feature rank of the features output at the network's penultimate layer for each of the checkpointed networks used for target fitting. These are computed using the network features generated from 1000 states sampled randomly from that checkpoint's replay buffer. For feature rank, averages and standard deviations are only over the 5 agent seeds.
510
+
511
+ ![](images/94e427e0e6c7a7004c691408b667e47ddf665230b7f763a252cd18a2ad6def98.jpg)
512
+
513
+ ![](images/5f9db834c94f5e4623d10b4313c41a450ae7bd6c7803860ae5790b1f83357753.jpg)
514
+
515
+ ![](images/8ad8f879794dcda50355f84f6496d73a68882fa148a02f0d184dcf96c92a5c69.jpg)
516
+
517
+ ![](images/0d5792f58b86c5da61d7369d89d582514fee95f942bb00b6703daa5827b2e43f.jpg)
518
+
519
+ ![](images/54945b866a1c26ea2ef99e9df3f516c61f0edc7dd0e20e5b12bf6efcd1ea177c.jpg)
520
+
521
+ ![](images/23ccc3f57660b8708c0a7d897b6bd3f3fa9f934674e69241f7f2ad4f2acc0148.jpg)
522
+
523
+ ![](images/76f9d71f4cfcf3c3c09c042bf4d450f6921afcd9d213e8bf0a37907dbd9899e2.jpg)
524
+
525
+ ![](images/5aab8ba0b6faf29de73223ee6b28e79ac4117238c2b773c5ae7d91297cc3cd29.jpg)
526
+
527
+ ![](images/ff470b9074f5fadfbe88c70e70885035a682b0b249f7ed417e00863803588759.jpg)
528
+
529
+ ![](images/17c78b6c3776a92ecf06922d31b7b2af36c88a4f43f957c363e17444c9ffa09c.jpg)
530
+
531
+ ![](images/4ef368574827c2d3404e9069265726fff9a83a4b4de9c28339d5494ce762fc56.jpg)
532
+ Figure 15: Mean squared error, after 10000 training steps for the target-fitting on random network targets. We also show the corresponding feature rank of the pre-trained neural network (before target-fitting).
533
+
534
+ ![](images/0c8c437e94d16d197c7feb3253d84c301d4c6347e9f12cf2777d1005536358ca.jpg)
535
+ Loss Feature num. rank Feature srank
536
+
537
+ ![](images/647cc66701a06fd3891b2cfdb2e406887f0d95f66cae22f4c1aa836aaaea29ae.jpg)
538
+
539
+ ![](images/3172eb6846a5e1ab0586f6d9a59dc72fe4dc957e3e944a0a9c54c65de324386a.jpg)
540
+
541
+ ![](images/7f8f77eb4c8ede947ebc3e1f46909c5d16c7485a5df4839594923bf9d58eeb52.jpg)
542
+
543
+ # C.4 PERFORMANCE
544
+
545
+ We provide full training curves for both Rainbow and Rainbow+InFeR on all games in Figures 16 & 17 (capped human-normalized performance), and 18 & 19 (raw evaluation score). We also provide evaluation performance curves for DDQN and DDQN+InFeR agents in Figure 20.
546
+
547
+ ![](images/22e6ea123f2fb5b4d0b0c716a0c6460d640b6e43fa7efc48871cc75df01f0f2d.jpg)
548
+ Figure 16: Full evaluation of capped human-normalized performance on Atari benchmarks for the default Rainbow architecture.
549
+
550
+ ![](images/2b83193c531df881d2185d7d85f1fdda6a77e81d5be972e12d225f104c1e36b8.jpg)
551
+ Figure 17: Full evaluation of capped human-normalized performance on Atari benchmarks in the double-width Rainbow architecture.
552
+
553
+ ![](images/124903730eb8bc792bda39100afc0377af3eb0a053b111a38940ad1ebbce9dd6.jpg)
554
+ Figure 18: Full evaluation of raw scores on Atari benchmarks for the default Rainbow architecture.
555
+
556
+ ![](images/0817c96c35e8b8e6a27105a5dd61c2e1641d11af8c068531de4ee64bb528b28c.jpg)
557
+ Figure 19: Full evaluation of raw scores on Atari benchmarks for the double-width Rainbow architecture.
558
+
559
+ ![](images/7fb54613b367f9842ac24d3b2385d88e886a226e1bc88591fa06525e39ef8d82.jpg)
560
+ Figure 20: Evaluations of the effect of InFeR on performance of a Double DQN agent. Overall we do not see as pronounced an improvement as in Rainbow, but note that the average human-normalized score over the entire benchmark is nonetheless slightly higher for the InFeR agent, and that the performance improvement obtained by InFeR in Montezuma's Revenge is still significant in this agent.
understandingandpreventingcapacitylossinreinforcementlearning/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7594b106d08b5ce44726f8516aa14783e67a71a711031ebe0cff6f99852a7785
3
+ size 2155547
understandingandpreventingcapacitylossinreinforcementlearning/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5dac9d4263b10da62c5e5dc7d3f522b54633295b71031287cbe078649323d05d
3
+ size 657190
understandinglatentcorrelationbasedmultiviewlearningandselfsupervisionanidentifiabilityperspective/2d3fc944-401f-4422-a5dd-600a142ba32a_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d9a4d4b0cc7052a4c035154e3dede2986d96cd94eea0d2a0b00091177ad4a19
3
+ size 272088
understandinglatentcorrelationbasedmultiviewlearningandselfsupervisionanidentifiabilityperspective/2d3fc944-401f-4422-a5dd-600a142ba32a_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4906cff60302d9a41f10e185db86d1bbfba1ec7cef4d09c00e8cb5f09f19da21
3
+ size 314620
understandinglatentcorrelationbasedmultiviewlearningandselfsupervisionanidentifiabilityperspective/2d3fc944-401f-4422-a5dd-600a142ba32a_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:66f0287dd1cad2315dd04901d9385bf410cbcec47b003f17937691574bed1574
3
+ size 1789389
understandinglatentcorrelationbasedmultiviewlearningandselfsupervisionanidentifiabilityperspective/full.md ADDED
The diff for this file is too large to render. See raw diff
 
understandinglatentcorrelationbasedmultiviewlearningandselfsupervisionanidentifiabilityperspective/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e1ebb5a4646ff2816b9cd006d5bb2811d42e7bbcea97120889b985fbfc3926f1
3
+ size 2069524
understandinglatentcorrelationbasedmultiviewlearningandselfsupervisionanidentifiabilityperspective/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52745b60c01688ef22ea11d6fd6c0c0fb4e6fb6e523b13575e4d7d79fda10b07
3
+ size 1627538
understandingtheroleofselfattentionforefficientspeechrecognition/6eab39ff-801f-4244-a054-726b9b2eab01_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:67b3774dc711ea574e1496e2005bbde3caec7273c03ce4cd7e78e5aa12bd291d
3
+ size 110833
understandingtheroleofselfattentionforefficientspeechrecognition/6eab39ff-801f-4244-a054-726b9b2eab01_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f58dfc0a9e823c8fb7992a790566f99c1f0ec7198e592ca8e9ab2a00ef8347d
3
+ size 136051
understandingtheroleofselfattentionforefficientspeechrecognition/6eab39ff-801f-4244-a054-726b9b2eab01_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d35e5177585ee2a6ad6d21e66fb8b56758ad999268ec44da7baeed21631a20a0
3
+ size 9575143
understandingtheroleofselfattentionforefficientspeechrecognition/full.md ADDED
@@ -0,0 +1,430 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # UNDERSTANDING THE ROLE OF SELF ATTENTION FOR EFFICIENT SPEECH RECOGNITION
2
+
3
+ Kyuhong Shim<sup>1</sup>, Jungwook Choi<sup>2</sup>, Wonyong Sung<sup>1</sup>
4
+
5
+ Department of Electrical and Computer Engineering, Seoul National University<sup>1</sup>
6
+ Department of Electrical Engineering, Hanyang University<sup>2</sup>
7
+
8
+ skhu20@snu.ac.kr, choij@hanyang.ac.kr, wysung@snu.ac.kr
9
+
10
+ # ABSTRACT
11
+
12
+ Self-attention (SA) is a critical component of Transformer neural networks that have succeeded in automatic speech recognition (ASR). In this paper, we analyze the role of SA in Transformer-based ASR models for not only understanding the mechanism of improved recognition accuracy but also lowering the computational complexity. We reveal that SA performs two distinct roles: phonetic and linguistic localization. Especially, we show by experiments that phonetic localization in the lower layers extracts phonologically meaningful features from speech and reduces the phonetic variance in the utterance for proper linguistic localization in the upper layers. From this understanding, we discover that attention maps can be reused as long as their localization capability is preserved. To evaluate this idea, we implement the layer-wise attention map reuse on real GPU platforms and achieve up to 1.96 times speedup in inference and $33\%$ savings in training time with noticeably improved ASR performance for the challenging benchmark on LibriSpeech dev/test-other dataset.
13
+
14
+ # 1 INTRODUCTION
15
+
16
+ Recent advances in end-to-end automatic speech recognition (ASR) have been driven by Transformer models (Vaswani et al., 2017). Transformer was first introduced for natural language processing (NLP) tasks such as neural machine translation (Vaswani et al., 2017; Ott et al., 2018), language modeling (Dai et al., 2019; Rae et al., 2019), and text generation (Raffel et al., 2020). Thanks to its superior performance in processing sequence input, Transformer has been widely adopted in various state-of-art ASR models (Zhang et al., 2020b; Ng et al., 2021; Guo et al., 2021). Self-attention (SA) is a core component of Transformer-based ASR, which dynamically collects information from multiple frames of an audio sequence. However, the computation and memory costs of SA increase quadratically with the length of a sequence, which is particularly problematic for ASR. For example, just a 30-second utterance corresponds to about 750 frames with a widely used window stride of 40ms.
17
+
18
+ Understanding the role of SA may provide essential insights for the efficient design of Transformer-based ASR models. Extensive studies have examined the behavior of SA in the field of NLP (Kovaleva et al., 2019; Park et al., 2019; Gong et al., 2019; Rogers et al., 2020). Recently, several studies further attempted to discover the characteristics of SA in the speech domain. Yang et al. (2020) revealed that self-attention features in the self-supervised audio Transformer are categorized into global, vertical, and diagonal patterns. Zhang et al. (2021b) focused on the diagonality of upper SA layers in ASR models for improving efficiency. However, these prior works revealed limited insights on the patterns discovered in SA, constraining its use for improving model efficiency. Thus, providing a holistic view of the role of SA is desirable for efficient ASR model design.
19
+
20
+ In this work, we reveal that SA plays two distinct roles in the success of Transformer-based ASR models: phonetic and linguistic localization, as illustrated in Figure 1. First, phonetic localization of lower SA layers attends to the phonologically meaningful global context. Second, linguistic localization of upper SA layers mainly attends to the local context of a near-diagonal attention map. We hypothesize that the phonetic variance in utterances such as variations in pronunciation is standardized in the lower SA layers so that the upper SA layers can identify local linguistic features
21
+
22
+ ![](images/b553aad44575289979ad6b2c91ed96e5b4235d534f16cf6a6c4d36315ecd436b.jpg)
23
+ Figure 1: Illustration of the role of SA layers in Transformer-based ASR models and the proposed layer-wise attention map reuse. We discover that lower layers and upper layers show different behavior.
24
+
25
+ for accurate transcription. To investigate the behavior of SA layers, we propose phoneme attention relationship (PAR) to explain how phoneme localization works quantitatively. Interestingly, we discover that the phonetic localization represents the traditional knowledge on phonetics; for example, labial, velar, or nasal phonemes tend to attend to each other.
26
+
27
+ Based on this understanding, we propose a practical method for efficient ASR model design. We reuse the attention maps of SA layers while preserving the phonetic localization capability of the lower SA layers, resulting in up to 1.96x speedup in inference and $33\%$ savings of training time with considerably improved performance in challenging ASR tasks (LibriSpeech dev/test-other dataset).
28
+
29
+ Our contributions can be summarized as follows:
30
+
31
+ - We reveal that SA layers contribute to ASR with two distinct roles: phonetic localization in the lower layers and linguistic localization in the upper layers. This unique distinction leads to an in-depth analysis of phonetic SA for the first time. We further propose phoneme attention relationship (PAR) to quantitatively identify the role of phonetic localization.
32
+ - We propose layer-wise attention map reuse for efficient Transformer-based ASR models. In particular, we discover that attention map reuse is possible in lower SA layers as long as the phonetic localization property quantified by PAR is preserved. We demonstrate with the popular ASR model and dataset that ASR performance can be maintained or slightly improved even if the attention map is reused.
33
+ - We implement the attention map reuse on real GPU platforms and achieve up to 1.96x inference speedup and $33\%$ savings in training time, demonstrating that the proposed method is practical.
34
+
35
+ # 2 BACKGROUND
36
+
37
+ # 2.1 ASR ENCODER AND SELF-ATTENTION
38
+
39
+ SA is usually utilized as a module inside the ASR model consisting of stacked Transformer encoder layers. ASR encoder takes a sequence of short-time Fourier-transformed (STFT) audio features, known as a 'frame', as input and extracts a high-level feature of each frame through multiple layers. As illustrated in Figure 1, the extracted high-level feature changes for each layer; stacked SA layers
40
+
41
+ first extract phonetic features from audio features and utilize these features to build linguistic features for the output transcription.
42
+
43
+ We briefly review the $\mathrm{SA}^1$ computation procedure. Consider a sequence of $d$ -dimensional column vectors $X = \{x_{1}, x_{2}, \ldots, x_{T}\}$ as input. Each vector corresponds to each frame of speech where the total number of $T$ frames are included. The input feature vector $X$ is projected to query $(Q)$ , key $(K)$ , and value $(V)$ of $h$ -th attention head as follows:
44
+
45
+ $$
46
+ q _ {h, i} = W _ {h} ^ {Q} x _ {i}, \quad k _ {h, i} = W _ {h} ^ {K} x _ {i}, \quad v _ {h, i} = W _ {h} ^ {V} x _ {i} \quad \left(W _ {h} ^ {Q}, W _ {h} ^ {K}, W _ {h} ^ {V} \in \mathbb {R} ^ {d _ {h} \times d}\right) \tag {1}
47
+ $$
48
+
49
+ $W^{Q,K,V}$ indicates projection matrices for $Q, K, V$ , respectively. $d_h = d / H$ is the dimension of each attention head where $H$ is the number of attention heads. The attention map $(A_h)$ , which represents how much frames attend to each other, is computed by scaled dot-product operation followed by softmax. The resulting attention map takes a form of a 2D matrix where each row is a probability vector. A single element of the attention map $(A_h[i,j])$ represents how much $i$ -th frame attends to $j$ -th frame. The attention head $(d_h)$ is a weighted sum of $V$ using the attention map as weight. Note that each attention head corresponds to a different attention map $A_h$ ; this multi-head design enables focusing on various perspectives within a single SA layer. The output $O = \{o_1,o_2,\dots o_T\}$ is computed by the projection $(W^O \in \mathbb{R}^{d\times d})$ on the concatenated attention heads<sup>2</sup>.
50
+
51
+ $$
52
+ A _ {h} [ i,: ] = \operatorname {S o f t m a x} _ {j} \left(\frac {q _ {h , i} k _ {h , j} ^ {T}}{\sqrt {d _ {h}}}\right), \quad d _ {h, i} = \sum_ {j = 1} ^ {T} A _ {h} [ i, j ] v _ {h, j}, \quad o _ {i} = W ^ {O} \underset {h} {\operatorname {C o n c a t}} \left(d _ {h, i}\right) \tag {2}
53
+ $$
54
+
55
+ SA layer contains $O(d^{2})$ parameters. As shown in equations, SA requires quadratic computation and memory complexity $O(T^{2})$ , in exchange for the ability to access any location in the sequence. When $N$ layers of SA are stacked, the burden proportionally increases.
56
+
57
+ # 2.2 PREVIOUS WORK ON SELF-ATTENTION ANALYSIS
58
+
59
+ ASR considers both phonetic and linguistic aspects to transform audio input to text output. However, the studies on NLP mostly analyze the linguistic characteristics of SA, and the studies on self-supervised audio representation learning (SSAL) mainly focus on the phonetic behaviors of SA. The valuable findings from both domains cannot be directly applied to ASR.
60
+
61
+ NLP The behavior of SA has been widely studied in the NLP domain (Rogers et al., 2020), mostly focused on BERT (Devlin et al., 2019), a self-supervised language representation learning model. Kovaleva et al. (2019) and Guan et al. (2020) suggested that attention patterns can be clustered into several groups and the pattern may change depending on the fine-tuning task. Clark et al. (2019) and Tenney et al. (2019) observed attention maps that correspond to linguistic concepts of the language. Voita et al. (2019) also characterized linguistic attention heads and connected the knowledge to efficient model structure. However, studies on NLP only provide analysis on linguistic attention.
62
+
63
+ SSAL Recently, several studies have been introduced to understand how the audio information is encoded in SSAL models, such as CPC (Oord et al., 2018), Wav2Vec 2.0 (Baevski et al., 2020), Mockingjay (Liu et al., 2020), HuBERT (Hsu et al., 2021), and Audio ALBERT (Chi et al., 2021). Ma et al. (2021) and Shah et al. (2021) demonstrated that a wide spectrum of phonetic information is included in these models. Especially, Yang et al. (2020) categorized attention maps into three categories: global, vertical, and diagonal, where diagonal heads attend to local frames and vertical heads either focus or neglect specific phonemes. However, Yang et al. (2020) only discovered attention patterns without an explanation on how phonetic feature extraction is achieved with these patterns.
64
+
65
+ ASR Previous works have investigated the redundancy of attention maps mainly based on diagonality. From the observation that attention maps in upper layers show highly diagonal patterns, Zhang et al. (2021b) proposed replacing upper SA layers to feed-forward layers without performance loss. Zhang et al. (2021a) removed SA heads of high diagonality during training as a regularization
66
+
67
+ ![](images/8704e95f3091f4fc182f4600702f2656e7a4d9c24e1928e5f9cafd08570ec90b.jpg)
68
+ Figure 2: Cumulative attention diagonality (CAD) of each attention head. Four points for each layer correspond to the CAD of four attention heads. The black line connects the median across the layers.
69
+
70
+ but keep every head for the test time. Similarly, Chang et al. (2020) introduced adaptive attention span where each attention head equips a different attention span width to reduce the sequence length for the computation, starting from the intuition that some heads only attend to neighboring frames. These approaches mainly focus on reducing the burden of diagonal and concentrated attention, however, diagonality-based analysis has limitations in optimizing phonetic attention. We distinguish SA into two groups and provide proper analysis for each.
71
+
72
+ # 3 UNDERSTANDING THE ROLE OF SELF-ATTENTION IN ASR
73
+
74
+ # 3.1 ANALYSIS SETUP
75
+
76
+ We train and evaluate the model on the LibriSpeech-960 (Panayotov et al., 2015) dataset. The dataset include two types of data, clean and other, where other contains more challenging utterances. We extract the 80-dimensional log-Mel filterbank feature from a 25ms window with a stride of 10ms. We use 128 sub-word tokens as vocabulary, built on SentencePiece (Kudo & Richardson, 2018) library using the byte-pair encoding (Sennrich et al., 2016). The analyses are performed on LibriSpeech test-clean dataset unless specified.
77
+
78
+ We use Conformer-M(medium) (Gulati et al., 2020) as the baseline ASR encoder, trained with CTC (Graves et al., 2006) loss. Conformer is a variant of Transformer, which combines an additional convolution module to enhance the ability to collect local neighboring features. We follow recently introduced state-of-the-art ASR studies (Zhang et al., 2020b; Ng et al., 2021; Guo et al., 2021) that have adopted Conformer as their ASR encoder. We train the model with AdamW (Loshchilov & Hutter, 2018) optimizer for 200K iterations. Please see Appendix A.1 and A.2 for the model configuration and training details.
79
+
80
+ # 3.2 Distinguishing BETWEEN PHONETIC AND LINGUISTIC SELF ATTENTIONS
81
+
82
+ To understand the role of SA, we start by examining the attention map $A_{h}$ , which characterizes the functionality of SA. The attention map indicates how a frame attends the other frames in terms of probabilistic distribution for each attention head. Thus, analysis on attention maps across the heads of a SA layer would discover important characteristics of SA. To measure the diagonality of the attention map, we introduce cumulative attention diagonality (CAD) defined as the integral of the sum of attention probabilities constrained by distance as below:
83
+
84
+ $$
85
+ \mathrm {C A D} _ {h} = \int_ {r = 0} ^ {1} \frac {1}{T} \sum_ {i = 1} ^ {T} \sum_ {j = 1} ^ {T} A _ {h} [ i, j ] \cdot \mathbb {I} [ | i - j | \leq r (T - 1) ] \mathrm {d} r \tag {3}
86
+ $$
87
+
88
+ where $T$ is the number of frames in a sequence, $r$ determines the range of distribution in the attention map under test, and $h$ is an index of the attention head. Appendix B.1.1 provides detailed explanations of above equation and visualizes some CAD examples.
89
+
90
+ Figure 2 shows the attention diagonality analysis for the SA layers. There is a clear transition of CAD from lower layers (layer 1-8) to upper layers (layer 9-16). We emphasize this is a unique trend observed in ASR models compared to other domains: Kovaleva et al. (2019) classified attention maps in BERT but did not report the grouping of the same types. Yang et al. (2020) also categorized attention maps in SSAL but those categories broadly appear through layers. In ASR, Zhang et al. (2021b) observed a similar diagonality pattern for SA layers, but they considered it as an increase of diagonality over layers and did not separate the distinct patterns.
91
+
92
+ ![](images/0f5a2709b1c2148fca4247efdabbe1f51994b32347dfb0ee94b787f1f74f4187.jpg)
93
+ Figure 3: Visualization of the phonetic localization. Each element corresponds to $A[i,j]$ where $i,j$ indicates the frame index. Several rows that correspond to a certain phoneme, give higher attention to similar phonemes across the columns. For better visualization, we selectively draw boxes on three representative patterns (S, ER, and IY).
94
+
95
+ From the diagonality analysis, we categorize the role of SA layers into two parts: phonetic and linguistic localization. In ASR, linguistic localization refers to the behavior of the attention map that focuses on local (near in distance) frames and aggregates the information for text transcription. Since these local frames are particularly important in audio to text transcription in ASR, the attention map is characterized with a diagonal pattern. As shown in Figure 2, the upper layers tend to exhibit diagonally dominant patterns, implying their role as a linguistic localizer. We visualize two cases of diagonal attention patterns in Figure 1, extracted from layers 12 and 15 of the baseline model. Our observation is consistent with the prior work such as Zhang et al. (2021b). On the other hand, there has been little discussion about the role of lower layers in ASR in the context of phoneme localization. We discuss this in detail in the next section.
96
+
97
+ # 3.3 CHARACTERISTIC OF PHONETIC LOCALIZATION
98
+
99
+ Phonetic localization denotes the role of the attention map that focuses on similar (near in content) frames and extracts the phonologically meaningful features. We observe two characteristics of phonetic localization. First, phonetic localization is realized as attention to similar phonemes across the sequence. Second, the localization transforms each corresponding frame more likely to others.
100
+
101
+ To analyze phonetic attention, we exploit the phoneme information to find out the relationship between attention and phonemes. For the LibriSpeech dataset, we use the frame-level phoneme alignments obtained from Montreal Forced Aligner (McAuliffe et al., 2017). Table 1 lists all phoneme classes. Please visit Appendix A.3 for details on phoneme pre-processing.
102
+
103
+ <table><tr><td>Idx.</td><td>0</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td></tr><tr><td>Phn.</td><td>AA</td><td>AE</td><td>AW</td><td>AY</td><td>AH</td><td>EH</td><td>ER</td><td>EY</td><td>IY</td><td>IH</td><td>O</td><td>UH</td><td>UW</td><td>L</td><td>R</td><td>M</td><td>N</td><td>NG</td></tr><tr><td>Idx.</td><td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td><td>25</td><td>26</td><td>27</td><td>28</td><td>29</td><td>30</td><td>31</td><td>32</td><td>33</td><td>34</td><td>35</td></tr><tr><td>Phn.</td><td>B</td><td>D</td><td>DH</td><td>G</td><td>K</td><td>P</td><td>T</td><td>F</td><td>CH</td><td>SH</td><td>TH</td><td>S</td><td>Z</td><td>V</td><td>JH</td><td>W</td><td>Y</td><td>HH</td></tr></table>
104
+
105
+ Table 1: Phoneme index for the analysis. Phonemes are extracted from the LibriSpeech lexicon and collapsed into 36 classes. Phonemes are reordered according to their phonological properties.
106
+
107
+ Figure 3 demonstrates the first characteristic of phoneme localization. The attention map presents that the same or similar phonemes tend to assign high attention weight to each other, for example, ('S' to 'Z'), ('ER' to 'R'), and ('IY' to 'IH').
108
+
109
+ We evaluate our second statement by phoneme classification on hidden layer representations (output of layers, also known as a hidden activation or hidden vector), similar to previous approaches (Baevski et al., 2021; Liu et al., 2021). We extract hidden layer representations and train a softmax classifier for each layer. Input is 256-dimensional vector and output contains total 37 output classes (36 phonemes + "silence"). See Appendix A.5 for the details on training the classifier and visualization of the confusion matrix.
110
+
111
+ ![](images/3dc03a97aaa86d5153ef5115d4a61977e2e72715cd1d86ea9b461f7c2dd69fec.jpg)
112
+ Figure 4: Phoneme classification accuracy on LibriSpeech test datasets. The zeroth entry implies the classifier is trained from hidden representations obtained before the first SA layer.
113
+ Figure 4 shows the phoneme classification accuracy for different layers. The accuracy increases for the lower layers (layer 1-8) where phonetic localization dominates. Specifically, the accuracy of layer 0 (before SA) is only $53.8\%$ , but it consistently increases to $81.7\%$ at layer 8. The phoneme classification accuracy indicates how well hidden vectors can be distinguished according to their phoneme classes. Therefore, the accuracy increase on lower layers implies that hidden layer representations are more standardized by phonetic localization. We assume that the accuracy decreases for the upper layers because they perform the linguistic localization and convert phoneme-level information to output text.
114
+
115
+ # 3.4 LAYER-WISE ANALYSIS OF PHONETIC ATTENTIONS
116
+
117
+ In phonetic attention, we observed that similar phonemes attend to each other and the phonetic features are clustered through layers. For the next step, we investigate the layer-wise behavior of phonetic attention to understand the contribution of each phonetic attention layer. We introduce phoneme attention relationship (PAR) to understand how SA processes phonological information by exposing how much each phoneme class attends to the other phonemes on average. Specifically, we directly map an attention probability $A_{h}[i,j]$ to $P_{h}[p,q]$ where $i$ -th frame and $j$ -th frame correspond to phoneme $p$ and $q$ , respectively. If two phoneme classes $p$ and $q$ are different, we simply transport the probability from $A_{h}[i,j]$ to $P_{h}[p,q]$ . On the other hand, if two frames are within the same phoneme class $p$ , we exclude consecutive frames of the same class to avoid unnecessarily emphasize the effect of diagonal attention maps. PAR is computed as below<sup>3</sup>:
118
+
119
+ $$
120
+ P _ {h} [ p, q ] = \frac {T}{\left| C _ {p} \right| \cdot \left| C _ {q} \right|} \sum_ {i \in C _ {p}} \sum_ {j \in C _ {q}} A _ {h} [ i, j ] \quad (p \neq q) \tag {4}
121
+ $$
122
+
123
+ $$
124
+ P _ {h} [ p, p ] = \frac {T}{\left| C _ {p} \right|} \sum_ {i \in C _ {p}} \frac {1}{\left| C _ {p} \right| - \left| E _ {p} (i) \right|} \sum_ {j \in C _ {p} - E _ {p} (i)} A _ {h} [ i, j ] \quad (p = q) \tag {5}
125
+ $$
126
+
127
+ $C_p, C_q$ indicates the set of frame indices that correspond to phoneme class $p$ and $q$ . $E_p(i)$ indicates the number of frames that satisfies two conditions: belong to the same class $p$ as $i$ -th frame and all frames between itself and $i$ -th frame also belong to the same class. In other words, $C_p - E_p(i)$ indicates the subset of $C_p$ that are not connected to $i$ -th frame by consecutive class $p$ frames. For the $P_h[p,p]$ calculation, we do not include consecutive frames of the same class. We discuss the purpose of this exclusion in Appendix B.2.1.
128
+
129
+ We visualize the average PAR of the lower half and upper half of layers in Figure 5. A prominent diagonal component appears, representing that phonemes put high attention to themselves. Interestingly, we also discover well-known phonological characteristics in the lower half of layers. For example, labial (B, P), velar (G, K), and alveolar (S, Z) consonants highly attend to each other. Nasal phonemes (M, N, NG) also show a high correlation. From the empirical observations, we denote that phonetic attention map creates heterogeneous patterns. Thanks to the multi-head structure, a single SA layer can capture multiple phonetic relationships. Please see Figure 12 in Appendix B.2.2 for various PAR examples for each head.
130
+
131
+ If each phonetic attention map corresponds to different relationships, can we reuse phonetic attention maps across multiple layers? We answer this question by introducing the PAR coverage, which
132
+
133
+ ![](images/cf6727a48025342ba7708fdab9021e729502317d62aeca67996a4b3e531864f4.jpg)
134
+ (a) Lower half of layers
135
+
136
+ ![](images/f7e2dd326293ce5abd4bbe6452559f90f0d1f3d2793e4dd96448fcd8611672ff.jpg)
137
+ (b) Upper half of layers
138
+ Figure 5: Averaged phoneme attention relationship of the lower half (1st, ... 8th) and upper half (9th, ... 16th) layers. The result is averaged through layers and heads on test-clean dataset. Each row and column corresponds to the phoneme index. Brighter (yellow) values indicate stronger attention between phonemes. Elements that stand out are highlighted, where phonemes with similar properties tend to attend to each other.
139
+
140
+ ![](images/39244cad1f3a54444c3f2b4fc6f177939f306a972447bc69f3b3273c1ce593ec.jpg)
141
+ Figure 6: Accumulated PAR coverage of lower layers (1st, ... 8th). Averaged PAR of the baseline (Figure 5(a)) is set to 1.0, which is considered to be a desirable reference. The left plot on the accumulated coverage shows how each layer participates in covering the strength of the relationship. The right table summarizes the coverage of different reuse configurations. A higher average per-layer coverage ratio implies that each layer performs more similarly to the baseline.
142
+
143
+ <table><tr><td>Reusing Config.</td><td>Avg. Per-layer Coverage (%)</td><td>Accumulated Coverage (%)</td></tr><tr><td>1x16</td><td>0.915 ± 0.041</td><td>1.0</td></tr><tr><td>2x8</td><td>0.960 ± 0.021</td><td>0.996</td></tr><tr><td>4x4</td><td>0.968 ± 0.016</td><td>0.992</td></tr><tr><td>8x2</td><td>0.973 ± 0.000</td><td>0.974</td></tr></table>
144
+
145
+ indicates how much each layer covers the phonetic relationship represented in the averaged PAR from the baseline (Figure 5(a)). The averaged PAR of the baseline is considered to represent all the essential phoneme relationships. Please refer to Appendix A.4 for details.
146
+
147
+ To investigate the effect of reuse, we plot the accumulated PAR coverage for different reuse configurations in Figure 6. In calculating the accumulated coverage ratio, we take the average on every PAR under a certain layer and compare it with the reference PAR. The accumulated coverage consistently increases to 1, which means that the missing relationships are fulfilled through layers. We test four configurations (will be introduced in detail in the next Section) $X \times Y$ , where $X$ layers share the same attention map. As the number of reuse increases $(2 \times 8 \rightarrow 4 \times 4 \rightarrow 8 \times 2)$ , the average per-layer coverage also grows, which implies that each SA layer tries to capture more phonetic relationships to recover the performance. However, for $8 \times 2$ , the model fails to fully cover the reference, represented as a low accumulated coverage ratio of 0.974. In Appendix B.3, we visualize the effect of the reuse on PAR coverage where phonetic features captured in $2 \times 8$ and $4 \times 4$ are missed in $8 \times 2$ .
148
+
149
+ Table 2: Word error rate $(\%)$ for different attention map reuse configurations. "HX" indicates that the number of attention heads in the self-attention layer is set to X. All configurations carry almost the same number of parameters. No external language model is used.
150
+
151
+ <table><tr><td>Configuration</td><td>#Heads</td><td>Head dim.</td><td>dev-clean</td><td>dev-other</td><td>test-clean</td><td>test-other</td></tr><tr><td>1(H4) × 16 (baseline)</td><td>64</td><td>64</td><td>3.1</td><td>8.3</td><td>3.2</td><td>8.4</td></tr><tr><td>2(H4) × 8</td><td>32</td><td>64</td><td>3.0</td><td>8.2</td><td>3.3</td><td>8.2</td></tr><tr><td>4(H8) + 4(H8) + 4(H8) + 4(H8)</td><td>32</td><td>32</td><td>3.1</td><td>8.1</td><td>3.2</td><td>8.1</td></tr><tr><td>4(H2) + 4(H2) + 4(H4) + 4(H4)</td><td>12</td><td>128/64</td><td>3.1</td><td>8.2</td><td>3.4</td><td>8.3</td></tr><tr><td>4(H4) + 4(H4) + 4(H4) + 4(H4)</td><td>16</td><td>64</td><td>3.0</td><td>8.2</td><td>3.3</td><td>8.2</td></tr><tr><td>4(H8) + 4(H8) + 4(H4) + 4(H4)</td><td>24</td><td>32/64</td><td>3.1</td><td>8.3</td><td>3.2</td><td>8.4</td></tr><tr><td>4(H4) + 4(H4) + 4(H2) + 4(H2)</td><td>12</td><td>64/128</td><td>3.1</td><td>8.5</td><td>3.4</td><td>8.5</td></tr><tr><td>4(H4) + 4(H4) + 4(H4) + 4(H4)</td><td>16</td><td>64</td><td>3.0</td><td>8.2</td><td>3.3</td><td>8.2</td></tr><tr><td>4(H4) + 4(H4) + 4(H8) + 4(H8)</td><td>24</td><td>64/32</td><td>3.1</td><td>8.2</td><td>3.3</td><td>8.1</td></tr><tr><td>4(H4) + 4(H4) + 8(H4)</td><td>12</td><td>64</td><td>3.1</td><td>8.3</td><td>3.3</td><td>8.2</td></tr><tr><td>8(H4) + 4(H4) + 4(H4)</td><td>12</td><td>64</td><td>3.1</td><td>8.5</td><td>3.3</td><td>8.6</td></tr><tr><td>8(H4) + 8(H4)</td><td>8</td><td>64</td><td>3.3</td><td>8.8</td><td>3.6</td><td>8.7</td></tr><tr><td>8(H8) + 8(H8)</td><td>16</td><td>32</td><td>3.2</td><td>8.5</td><td>3.4</td><td>8.5</td></tr></table>
152
+
153
+ # 4 LAYER-WISE ATTENTION MAP REUSE
154
+
155
+ We propose layer-wise attention map reuse, a method to design an efficient Transformer-based ASR encoder by reducing the heavy SA computation. The core idea is to reuse the computed attention map from the previous layer. More specifically, we reuse attention map of $l$ -th SA layer to $(l + 1)$ , $(l + 2)$ , ... $(l + M - 1)$ -th consecutive SA layers. If a single attention map is shared through $M$ layers, the computation burden of SA can be reduced by $M$ times. During training, the reused attention map receives gradients from $M$ layers. This layer-wise reuse is easy to implement and fully supported by modern accelerator hardware. The idea of reuse attention map through layers have been proposed for NLP (Xiao et al., 2019; Ying et al., 2021) but not tested for ASR. We discuss the difference in Section 5. For SA layers that receive the pre-computed attention map, query and key are not used and can be removed. To compensate the parameter size for those layers, we simply double the output dimension of $V$ ( $W_h^V \in \mathbb{R}^{2d_h \times d}$ , $W^O \in \mathbb{R}^{d \times 2d}$ ).
156
+
157
+ Table 2 shows the word error rate (WER) on LibriSpeech dev and test dataset. Configuration “ $X \times Y$ ” indicates that $X$ successive layers are grouped to share the same attention map and total $Y$ groups are built. Therefore, there exist HXY unique attention heads for each model. We also use the notation ‘+’, for example, $4 \times 4$ is identical to $4 + 4 + 4 + 4$ . For each configuration, we train the model from scratch with the same training setup as the baseline. Note that the increased number of heads comes with the decreased per-head dimension to keep the parameter size comparable.
158
+
159
+ Best and Worst We first compare the best $(4(\mathsf{H8})\times 4)$ and the worst configuration $(8(\mathsf{H4})\times 2)$ . The worst is the most naive setting that just applies very aggressive attention map reuse. Although the speed is about the same, performance can be improved by increasing the number of heads $(8(\mathsf{H8})\times 2)$ . In contrast, the best working setting is carefully designed to maximize performance. For example, equipping the same number of heads $(2(\mathsf{H4})\times 8)$ does not show similar performance compared to the best configuration.
160
+
161
+ Sensitivity to Reuse We examine which of the phonetic or linguistic localization is more sensitive to attention map reuse. Comparing two configurations with the identical number of heads and head dimensions $(4 + 4 + 8$ vs. $8 + 4 + 4)$ in the 5th block of Table 2, we conclude the phonetic localization suffers more from increasing the reuse of layers. In other words, the linguistic localization seems to be more robust to the reuse. We conjecture that too few phonetic localization heads fail to capture every essential relationship.
162
+
163
+ Number of Heads in Phonetic Localization To better understand the trade-off between the number of heads and head dimension, we conduct three experiments that only differ on the number of heads in lower layers. As shown in the 3rd block of Table 2, among the three configurations,
164
+
165
+ Table 3: Effect of different configurations on speed. The numbers inside of the parentheses indicate the speed-up ratio. The front convolutional sub-sampling is not included. Changing the number of heads does not make much difference to the speed.
166
+
167
+ <table><tr><td rowspan="2">Config.</td><td rowspan="2">#Param (M)</td><td colspan="4">Latency(ms) by sequence length (approx. sec)</td><td rowspan="2">Training cost(h)</td></tr><tr><td>128 (5.1s)</td><td>256 (10.2s)</td><td>512 (20.5s)</td><td>768 (30.7s)</td></tr><tr><td>1 × 16</td><td>25.45</td><td>1.43 (x1.00)</td><td>3.74 (x1.00)</td><td>11.11 (x1.00)</td><td>22.32 (x1.00)</td><td>430.0</td></tr><tr><td>2 × 8</td><td>24.92</td><td>1.25 (x1.15)</td><td>2.98 (x1.26)</td><td>7.92 (x1.40)</td><td>15.05 (x1.48)</td><td>337.5</td></tr><tr><td>4 × 4</td><td>24.66</td><td>1.14 (x1.25)</td><td>2.56 (x1.46)</td><td>6.29 (x1.77)</td><td>11.38 (x1.96)</td><td>288.4</td></tr><tr><td>8 × 2</td><td>24.52</td><td>1.08 (x1.32)</td><td>2.35 (x1.59)</td><td>5.47 (x2.03)</td><td>9.55 (x2.34)</td><td>268.8</td></tr></table>
168
+
169
+ $(4(\mathsf{H}4)\times 4)$ surpasses the other two in 3 over 4 benchmarks. We expect a trade-off between the number of phonetic localization heads and per-head dimension; the former enables more various aspects to be covered while the latter helps richer representation for each head.
170
+
171
+ Number of Heads in Linguistic Localization We perform the same experiment as above for the upper layers, shown in the 4th block of Table 2. Interestingly, we found that increasing the number of heads for linguistic localization tends to improve the overall performance. In addition, a considerable performance loss is detected when the number of heads is decreased to $2(\mathrm{H}2)$ . This observation implies that the previous studies that only reduce linguistic attention may face limitations when the remaining linguistic heads are too few.
172
+
173
+ Inference and Training Speed Table 3 compares different reuse configurations. Both training and inference speed can be greatly improved by reducing the number of attention computation. The impact becomes more significant for longer sequences as $T$ increases. Our best configuration $(4(\mathrm{H}8) \times 4)$ accelerates the inference by 1.96x times (for 30-second utterance) and reduces training cost by $33\%$ . Note that the number of parameters is almost equivalent for all configurations because of the expansion of $V$ dimension. Inference speed is evaluated on a single RTX-Titan(24GB) GPU and training cost is measured in GPU-hours on A100(40GB) GPU.
174
+
175
+ # 5 RELATED WORK
176
+
177
+ Attention Map Reuse in NLP Xiao et al. (2019) proposed sharing of attention map through consecutive layers for neural machine translation. They determine the reuse policy by Jensen-Shannon divergence (JSD) values between two attention maps. Ying et al. (2021) propose a similar approach for BERT but with manual reuse configurations. In addition to the critical difference in the domain (NLP vs. ASR), both works depend on the similarities of the attention map, however, do not investigate why the similarity is developed.
178
+
179
+ Efficient Attention Map Computation for ASR Several studies have been proposed to reduce the cost of attention computation for ASR. Wang et al. (2021) proposed a prob-sparse SA that only computes the top-k queries that are less uniform. For the streaming purpose, block processing of input sequence has been widely adopted (Yeh et al., 2021; Shi et al., 2021). Masked attention, which restricts the attention range to local neighbors, have also been used (Zhang et al., 2020a; Tripathi et al., 2020; Audhkhasi et al., 2021). While these approaches focus on reducing the effective sequence length, our method directly reduces SA computation.
180
+
181
+ # 6 CONCLUSION
182
+
183
+ In this paper, we analyze the role of self-attention in Transformer-based ASR and show that the role can be distinguished into two types: phonetic and linguistic localization. Especially, we showed that the phonetic localization captures various phonetic relationships and contributes to the performance by standardizing the features over similar phonemes, verified by the increasing phoneme classification accuracy over lower layers. The distinguished roles of SA in lower and upper layers also lead to an efficient ASR model that reuses the attention map for multiple SA layers. The proposed method has achieved a significant 1.96 times of speedup in inference and $33\%$ reduced training time, with the reduction of word error rate from $8.40\%$ to $8.05\%$ on the LibriSpeech test-other dataset.
184
+
185
+ # REPRODUCIBILITY STATEMENT
186
+
187
+ We explain extra details for the model architecture, training procedure, pre-processing steps, and experiments for analyses in Appendix A. We also provide the source code for the experiments in supplemental materials.
188
+
189
+ # ACKNOWLEDGMENTS
190
+
191
+ This work was supported by the National Research Foundation of Korea (NRF) grant funded by Korea government (MSIT) (No. 2021R1A2C1013513). This work was also partly supported by Institute of Information & communications Technology Planning & Evaluation (IITP) grant funded by MSIT (No. 2020-0-01373, No. 2021-0-00020-001). This work was also supported in part by Samsung Advanced Institute of Technology, Samsung Electronics Co., Ltd. This work was also partly supported by the Google AI Focused Research Awards Program awarded to Wonyong Sung. We gratefully acknowledge the GCP credit support from Google AI and the GPU server support from the Artificial Intelligence Cluster Agency (AICA, Korea).
192
+
193
+ # REFERENCES
194
+
195
+ Kartik Audhkhasi, Tongzhou Chen, Bhuvana Ramabhadran, and Pedro J Moreno. Mixture model attention: Flexible streaming and non-streaming automatic speech recognition. Proc. Interspeech 2021, pp. 1812-1816, 2021.
196
+ Alexei Baevski, Yuhao Zhou, Abdelrahman Mohamed, and Michael Auli. wav2vec 2.0: A framework for self-supervised learning of speech representations. Advances in Neural Information Processing Systems, 33, 2020.
197
+ Alexei Baevski, Wei-Ning Hsu, Alexis Conneau, and Michael Auli. Unsupervised speech recognition. arXiv preprint arXiv:2105.11084, 2021.
198
+ Xuankai Chang, Aswin Shanmugam Subramanian, Pengcheng Guo, Shinji Watanabe, Yuya Fujita, and Motoi Omachi. End-to-end asr with adaptive span self-attention. In INTERSPEECH, pp. 3595–3599, 2020.
199
+ Po-Han Chi, Pei-Hung Chung, Tsung-Han Wu, Chun-Cheng Hsieh, Yen-Hao Chen, Shang-Wen Li, and Hung-yi Lee. Audio albert: A lite bert for self-supervised learning of audio representation. In 2021 IEEE Spoken Language Technology Workshop (SLT), pp. 344-350. IEEE, 2021.
200
+ Kevin Clark, Urvashi Khandelwal, Omer Levy, and Christopher D Manning. What does bert look at? an analysis of bert's attention. In Proceedings of the 2019 ACL Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP, pp. 276-286, 2019.
201
+ Zihang Dai, Zhilin Yang, Yiming Yang, Jaime G Carbonell, Quoc Viet Le, and Ruslan Salakhutdinov. Transformer-xl: Attentive language models beyond a fixed-length context. In ACL (1), 2019.
202
+ Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. Bert: Pre-training of deep bidirectional transformers for language understanding. In *NAACL-HLT* (1), 2019.
203
+ Linyuan Gong, Di He, Zhuohan Li, Tao Qin, Liwei Wang, and Tieyan Liu. Efficient training of bert by progressively stacking. In International Conference on Machine Learning, pp. 2337-2346. PMLR, 2019.
204
+ Alex Graves, Santiago Fernández, Faustino Gomez, and Jürgen Schmidhuber. Connectionist temporal classification: labelling unsegmented sequence data with recurrent neural networks. In Proceedings of the 23rd international conference on Machine learning, pp. 369-376, 2006.
205
+ Yue Guan, Jingwen Leng, Chao Li, Quan Chen, and Minyi Guo. How far does bert look at: Distance-based clustering and analysis of bert's attention. arXiv preprint arXiv:2011.00943, 2020.
206
+ Anmol Gulati, James Qin, Chung-Cheng Chiu, Niki Parmar, Yu Zhang, Jiahui Yu, Wei Han, Shibo Wang, Zhengdong Zhang, Yonghui Wu, and Ruoming Pang. Conformer: Convolution-augmented transformer for speech recognition. In Proc. Interspeech 2020, pp. 5036-5040, 2020.
207
+
208
+ Pengcheng Guo, Florian Boyer, Xuankai Chang, Tomoki Hayashi, Yosuke Higuchi, Hirofumi Inaguma, Naoyuki Kamo, Chenda Li, Daniel Garcia-Romero, Jiatong Shi, et al. Recent developments on espnet toolkit boosted by conformer. In ICASSP 2021-2021 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 5874-5878. IEEE, 2021.
209
+ Wei-Ning Hsu, Benjamin Bolte, Yao-Hung Hubert Tsai, Kushal Lakhotia, Ruslan Salakhutdinov, and Abdelrahman Mohamed. Hubert: Self-supervised speech representation learning by masked prediction of hidden units. arXiv preprint arXiv:2106.07447, 2021.
210
+ Mingkun Huang, Jun Zhang, Meng Cai, Yang Zhang, Jiali Yao, Yongbin You, Yi He, and Zejun Ma. Improving rn transducer with normalized jointer network. arXiv preprint arXiv:2011.01576, 2020.
211
+ P Izmailov, AG Wilson, D Podoprikhin, D Vetrov, and T Garipov. Averaging weights leads to wider optima and better generalization. In 34th Conference on Uncertainty in Artificial Intelligence 2018, UAI 2018, pp. 876-885, 2018.
212
+ Goro Kobayashi, Tatsuki Kuribayashi, Sho Yokoi, and Kentaro Inui. Attention is not only a weight: Analyzing transformers with vector norms. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pp. 7057-7075, 2020.
213
+ Olga Kovaleva, Alexey Romanov, Anna Rogers, and Anna Rumshisky. Revealing the dark secrets of bert. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), pp. 4365-4374, 2019.
214
+ Taku Kudo and John Richardson. Sentencepiece: A simple and language independent subword tokenizer and detokenizer for neural text processing. In Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, pp. 66-71, 2018.
215
+ Andy T Liu, Shu-wen Yang, Po-Han Chi, Po-chun Hsu, and Hung-yi Lee. Mockingjay: Unsupervised speech representation learning with deep bidirectional transformer encoders. In ICASSP 2020-2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 6419-6423. IEEE, 2020.
216
+ Andy T Liu, Shang-Wen Li, and Hung-yi Lee. Tera: Self-supervised learning of transformer encoder representation for speech. IEEE/ACM Transactions on Audio, Speech, and Language Processing, 29:2351-2366, 2021.
217
+ Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations, 2018.
218
+ Danni Ma, Neville Ryan, and Mark Liberman. Probing acoustic representations for phonetic properties. In ICASSP 2021-2021 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 311-315. IEEE, 2021.
219
+ Michael McAuliffe, Michaela Socolof, Sarah Mihuc, Michael Wagner, and Morgan Sonderegger. Montreal forced aligner: Trainable text-speech alignment using kaldi. In Interspeech, volume 2017, pp. 498-502, 2017.
220
+ Edwin G Ng, Chung-Cheng Chiu, Yu Zhang, and William Chan. Pushing the limits of non-autoregressive speech recognition. arXiv preprint arXiv:2104.03416, 2021.
221
+ Aaron van den Oord, Yazhe Li, and Oriol Vinyals. Representation learning with contrastive predictive coding. arXiv preprint arXiv:1807.03748, 2018.
222
+ Myle Ott, Sergey Edunov, David Grangier, and Michael Auli. Scaling neural machine translation. In Proceedings of the Third Conference on Machine Translation: Research Papers, pp. 1-9, 2018.
223
+ Vassil Panayotov, Guoguo Chen, Daniel Povey, and Sanjeev Khudanpur. Librispeech: an asr corpus based on public domain audio books. In 2015 IEEE international conference on acoustics, speech and signal processing (ICASSP), pp. 5206-5210. IEEE, 2015.
224
+
225
+ Cheonbok Park, Inyoup Na, Yongjang Jo, Sungbok Shin, Jaehyo Yoo, Bum Chul Kwon, Jian Zhao, Hyungjong Noh, Yeonsoo Lee, and Jaegul Choo. Sanvis: Visual analytics for understanding self-attention networks. In 2019 IEEE Visualization Conference (VIS), pp. 146–150. IEEE, 2019.
226
+ Daniel S Park, Yu Zhang, Chung-Cheng Chiu, Youzheng Chen, Bo Li, William Chan, Quoc V Le, and Yonghui Wu. Specaugment on large scale datasets. In ICASSP 2020-2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 6879-6883. IEEE, 2020.
227
+ Chao Peng, Tete Xiao, Zeming Li, Yuning Jiang, Xiangyu Zhang, Kai Jia, Gang Yu, and Jian Sun. Megdet: A large mini-batch object detector. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 6181-6189, 2018.
228
+ Jiezhong Qiu, Hao Ma, Omer Levy, Wen-tau Yih, Sinong Wang, and Jie Tang. Blockwise self-attention for long document understanding. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: Findings, pp. 2555–2565, 2020.
229
+ Jack W Rae, Anna Potapenko, Siddhant M Jayakumar, Chloe Hillier, and Timothy P Lillicrap. Compressive transformers for long-range sequence modelling. In International Conference on Learning Representations, 2019.
230
+ Colin Raffel, Noam Shazeer, Adam Roberts, Katherine Lee, Sharan Narang, Michael Matena, Yanqi Zhou, Wei Li, and Peter J Liu. Exploring the limits of transfer learning with a unified text-to-text transformer. Journal of Machine Learning Research, 21:1-67, 2020.
231
+ Anna Rogers, Olga Kovaleva, and Anna Rumshisky. A primer in bertology: What we know about how bert works. Transactions of the Association for Computational Linguistics, 8:842-866, 2020.
232
+ Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words with subword units. In Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1715-1725, 2016.
233
+ Jui Shah, Yaman Kumar Singla, Changyou Chen, and Rajiv Ratn Shah. What all do audio transformer models hear? probing acoustic representations for language delivery and its structure. arXiv preprint arXiv:2101.00387, 2021.
234
+ Tao Shen, Tianyi Zhou, Guodong Long, Jing Jiang, and Chengqi Zhang. Bi-directional block selfattention for fast and memory-efficient sequence modeling. In International Conference on Learning Representations, 2018.
235
+ Yangyang Shi, Yongqiang Wang, Chunyang Wu, Christian Fuegen, Frank Zhang, Duc Le, Ching-Feng Yeh, and Michael L Seltzer. Weak-attention suppression for transformer based speech recognition. In Interspeech, 2020.
236
+ Yangyang Shi, Yongqiang Wang, Chunyang Wu, Ching-Feng Yeh, Julian Chan, Frank Zhang, Duc Le, and Mike Seltzer. Emformer: Efficient memory transformer based acoustic model for low latency streaming speech recognition. In ICASSP 2021-2021 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 6783-6787. IEEE, 2021.
237
+ Kaiser Sun and Ana Marasovic. Effective attention sheds light on interpretability. arXiv preprint arXiv:2105.08855, 2021.
238
+ Ian Tenney, Dipanjan Das, and Ellie Pavlick. Bert rediscovers the classical nlp pipeline. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 4593-4601, 2019.
239
+ Anshuman Tripathi, Jaeyoung Kim, Qian Zhang, Han Lu, and Hasim Sak. Transformer transducer: One model unifying streaming and non-streaming speech recognition. arXiv preprint arXiv:2010.03192, 2020.
240
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Advances in neural information processing systems, pp. 5998-6008, 2017.
241
+
242
+ Elena Voita, David Talbot, Fedor Moiseev, Rico Sennrich, and Ivan Titov. Analyzing multi-head self-attention: Specialized heads do the heavy lifting, the rest can be pruned. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics, pp. 5797–5808, 2019.
243
+ Xiong Wang, Sining Sun, Lei Xie, and Long Ma. Efficient conformer with prob-sparse attention mechanism for end-to-endspeech recognition. In *INTERSPEECH*, 2021.
244
+ Tong Xiao, Yinqiao Li, Jingbo Zhu, Zhengtao Yu, and Tongran Liu. Sharing attention weights for fast transformer. In Proceedings of the Twenty-Eighth International Joint Conference on Artificial Intelligence (IJCAI-19), 2019.
245
+ Shuwen Yang, Andy T. Liu, and Hung yi Lee. Understanding self-attention of self-supervised audio transformers. In Proc. Interspeech 2020, pp. 3785-3789, 2020. doi: 10.21437/Interspeech.2020-2231.
246
+ Ching-Feng Yeh, Yongqiang Wang, Yangyang Shi, Chunyang Wu, Frank Zhang, Julian Chan, and Michael L Seltzer. Streaming attention-based models with augmented memory for end-to-end speech recognition. In 2021 IEEE Spoken Language Technology Workshop (SLT), pp. 8-14. IEEE, 2021.
247
+ Chengxuan Ying, Guolin Ke, Di He, and Tie-Yan Liu. Lazyformer: Self attention with lazy update. arXiv preprint arXiv:2102.12702, 2021.
248
+ Qian Zhang, Han Lu, Hasim Sak, Anshuman Tripathi, Erik McDermott, Stephen Koo, and Shankar Kumar. Transformer transducer: A streamable speech recognition model with transformer encoders and rn-t loss. In ICASSP 2020-2020 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pp. 7829-7833. IEEE, 2020a.
249
+ Shuong Zhang, Erfan Loweimi, Peter Bell, and Steve Renals. Stochastic attention head removal: A simple and effective method for improving transformer based asr models. In Proc. Interspeech 2021, 2021a.
250
+ Shucong Zhang, Erfan Loweimi, Peter Bell, and Steve Renals. On the usefulness of self-attention for automatic speech recognition with transformers. In 2021 IEEE Spoken Language Technology Workshop (SLT), pp. 89-96. IEEE, 2021b.
251
+ Yu Zhang, James Qin, Daniel S Park, Wei Han, Chung-Cheng Chiu, Ruoming Pang, Quoc V Le, and Yonghui Wu. Pushing the limits of semi-supervised learning for automatic speech recognition. arXiv preprint arXiv:2010.10504, 2020b.
252
+
253
+ # A DETAILS
254
+
255
+ # A.1 MODEL
256
+
257
+ Our baseline model is Conformer-M(medium) (Gulati et al., 2020) trained with CTC (Graves et al., 2006) loss. Table 4 shows the configuration of the model. Unspecified details follow the original Conformer paper. We observed that SyncBN (Peng et al., 2018) is critical for the overall performance. We employ weak attention suppression (WAS) (Shi et al., 2020) of $\gamma = 0.5$ for faster convergence and improved performance.
258
+
259
+ <table><tr><td colspan="4">Encoder</td></tr><tr><td>#Layers</td><td>16</td><td>Hidden dim.</td><td>256</td></tr><tr><td>#Heads</td><td>4</td><td>Feed-forward dim.</td><td>1024</td></tr><tr><td>Conv. kernel size</td><td>31</td><td>Conv. normalization</td><td>SyncBN</td></tr><tr><td>BN momentum</td><td>0.005</td><td>BN epsilon</td><td>1e-5</td></tr><tr><td>Hidden drop prob.</td><td>0.1</td><td>Attention drop prob.</td><td>0.1</td></tr><tr><td colspan="4">Conv. Subsampling</td></tr><tr><td>#Layers</td><td>2</td><td>#Channels</td><td>256</td></tr><tr><td>Conv. kernel size</td><td>3</td><td>Conv. normalization</td><td>SyncBN</td></tr><tr><td>Conv. stride</td><td>2</td><td>Activation func.</td><td>ReLU</td></tr></table>
260
+
261
+ We decide to use Conformer as our baseline, following recent state-of-the-art ASR models, because these models can benefit the most from the proposed efficient model design. However, there may be several concerns on the clarity of our analysis on SA because the convolution module is jointly used with SA inside Conformer. Because the ability to gather information from the entire sequence is only equipped in SA, the analysis results on the role of phonetic heads could not be presented without SA. The convolution kernel size of 31, which covers about 1.2 seconds, is too short to gather long-range information. We believe that the convolution module may guide the model to focus on local information first at the early stage of the training, however, the role of SA is not much affected by the difference between Conformer and Transformer.
262
+
263
+ # A.2 TRAINING
264
+
265
+ Table 4: Conformer-M implementation details.
266
+
267
+ <table><tr><td colspan="4">Optimizer &amp; Scheduler</td></tr><tr><td>Maximum LR</td><td>1.5e-3</td><td>Weight decay</td><td>1e-5</td></tr><tr><td>Adam epsilon</td><td>1e-8</td><td>Adam betas</td><td>(0.9, 0.99)</td></tr><tr><td>LR warm-up iters</td><td>5K</td><td>LR keep iters</td><td>95K</td></tr><tr><td>Total iters</td><td>200K</td><td>Batch size</td><td>480</td></tr><tr><td colspan="4">Additional Details</td></tr><tr><td>#Frequency masking</td><td>2</td><td>Frequency mask width</td><td>27</td></tr><tr><td>#Time masking</td><td>10</td><td>Time mask width</td><td>0.05 (5%)</td></tr><tr><td>#Models for SWA</td><td>45</td><td>Variational noise</td><td>0.02</td></tr><tr><td>CTC beam size</td><td>32</td><td>Gradient norm clip</td><td>20</td></tr></table>
268
+
269
+ Table 5: Training details including optimizer, scheduler, augmentation and other hyper-parameters.
270
+
271
+ We use AdamW (Loshchilov & Hutter, 2018) optimizer with the inverse square-root learning rate schedule (Vaswani et al., 2017). Table 4 shows the training configuration. We linearly increase the learning rate (LR) to the maximum value for 5K iterations and keep LR at maximum for 95K iterations, followed by 100K iterations of LR decrease. We use 4x A100(40GB) GPUs for the experiments. To fit the batch size of 480 in these GPUs, we assign 40 samples per GPU and accumulate the gradient of 3 batches. We don't use bucketing for generating the mini-batch during training. We also employ adaptive SpecAugment (Park et al., 2020), stochastic weight averaging (SWA) (Izmailov et al., 2018), and variational noise.
272
+
273
+ # A.3 PHONEMPRE-PROCESSING
274
+
275
+ For phonetic analyses, We employ the collapsed list of phonemes that are included in the LibriSpeech lexicon. We collapse ('AA, AO' to 'AA'), ('OW, OY' to 'O'), and ('SH, ZH' to 'SH'), which leads to the phoneme classes in Table 1, for better understanding the characteristics. Because the LibriSpeech dataset does not provide frame-wise phoneme alignments, we extract the phoneme alignment from MFA (McAuliffe et al., 2017) and map these alignments to each frame. Especially, we exploit the fact that each frame corresponds to a 40ms interval after passing through two convolutional layers (convolutional sub-sampling) of stride 2 in front of the model. We assign the phoneme class to each frame if the center of the frame is within the phoneme duration, including the 'silence' phoneme.
276
+
277
+ Except for the phoneme classification, our analysis excludes 'silence' frames by exploiting frame-level phoneme alignments. Then, we re-normalize the remaining attention probability to preserve the probability sum to 1. We observe that these silence frames sometimes consume too much probability mass for both linguistic and phonetic heads, which makes our analysis difficult. Note that this phenomenon of assigning strong attention to ambiguous tokens, such as [CLS] or [SEP], has been also reported in NLP (Kobayashi et al., 2020; Sun & Marasović, 2021). Recently, Kobayashi et al. (2020) introduced the concept of norm-based analysis and reported that those [CLS] and [SEP] does not contribute much to the output even though their attention weight is large. We leave analysis using effective attention as a future work.
278
+
279
+ # A.4 PHONEME ATTENTION RELATIONSHIP COVERAGE
280
+
281
+ ![](images/d65372a6a013db016a7368941517ec0e80f6bacc7ea9289b62a510fde472f4a5.jpg)
282
+ Figure 7: Top-10 phoneme classes (column) for each phoneme (row) in the reference phoneme attention relationship of Figure 5(a).
283
+
284
+ The coverage ratio $R$ of the target PAR compared to the reference PAR is calculated as below:
285
+
286
+ $$
287
+ R _ {h} [ p, q ] = \operatorname {M i n i m u m} \left(\frac {\operatorname {P A R} _ {h} [ p , q ]}{\operatorname {P A R} _ {h} ^ {\text {r e f}} [ p , q ]}, 1\right), \quad R _ {h} = \frac {1}{| P |} \sum_ {p \in P} \frac {1}{| Q _ {p} |} \sum_ {q \in Q _ {p}} R _ {h} [ p, q ] \tag {6}
288
+ $$
289
+
290
+ $P$ indicates every phoneme class and $Q_{p}$ indicates top-10 phoneme classes in the order of the largest PAR elements for the phoneme $p$ $(R_{h}[p,:])$ . Top-10 classes are visualized in Figure 7. We exploit topmost phoneme classes because our interest is at the important relationships.
291
+
292
+ # A.5 PHONEME CLASSIFICATION
293
+
294
+ For the phoneme classification, we train a single fully-connected layer as a classifier. We choose the simplest architecture as a classifier to more directly correlate the phoneme accuracy and hidden layer representations. These representations are extracted from dev-clean and dev-other dataset and evaluated on test-clean and test-other dataset. We use SGD with a learning rate of 0.1, momentum of 0.9, and weight decay of 1e-3. The training takes 15 epochs, where the learning rate is multiplied by 0.1 for every 3 epochs. We visualize confusion matrices of the phoneme classification in Figure 8. As layer proceeds, wrongly classified phonemes (non-diagonal) disappear and leave a clear diagonal line on the confusion matrix.
295
+
296
+ ![](images/d84c159770b5a25d73b9a564ad604e64b9fc19b7d400b87369a8b929e3becbc5.jpg)
297
+ (a) Layer 0 $(48.4\%)$
298
+
299
+ ![](images/9190e2f4f2995a20f47d1a6e27105ea69403af7c44c75f8453338c412fd244df.jpg)
300
+ (b) Layer 4 $(68.0\%)$
301
+
302
+ ![](images/2d243b90ce680ce654cc88dbdd7a0bf7fa223b90f63e49c7e7db587d81464b1a.jpg)
303
+ Accuracy $(\%)$
304
+ (c) Layer 8 $(75.5\%)$
305
+
306
+ ![](images/f061fdc845b31972b5b3d574651029d64e3a23373114bcecad5ac8c894423d12.jpg)
307
+ Figure 8: Confusion matrix and phoneme accuracy for selected layers. Visualized the result from the LibriSpeech test-other dataset. Each row and column corresponds to the 37 phoneme classes, including 'silence' as zeroth class.
308
+
309
+ ![](images/2b86bfa19665c3e4fb715c27c9ce050af7f27dee01ed5d0fdd0edc5944ea5b93.jpg)
310
+ Figure 9: Examples of typical cumulative attention diagonality (CAD). (a) and (b) visualizes curves (before the integral) of four attention heads in each layer. $x$ -axis and $y$ -axis depict the relative distance $r$ and accumulated attention probability, respectively. CAD is represented as the area under curve. CAD values of each head are also listed.
311
+
312
+ # B ADDITIONAL RESULTS AND DISCUSSIONS
313
+
314
+ # B.1 DIAGONALITY
315
+
316
+ # B.1.1 CAD RESULTS
317
+
318
+ The CAD is a good indicator of how fast the accumulated attention increases over the distance, directly represents the diagonality of the attention weight. The CAD is interpreted as the area under the function $D(r)$ , where $D(r)$ calculates the amount of total attention weight within the restricted range $j \in [i - r(T - 1), i + r(T - 1)]$ . ( $T - 1$ ) is the maximum possible distance between two frames where $T$ is the number of frames.
319
+
320
+ $$
321
+ \mathrm {C A D} _ {h} = \int_ {r = 0} ^ {1} \frac {1}{T} \sum_ {i = 1} ^ {T} \left(\sum_ {\substack {j = \max (1, \\ i - r (T - 1))}} ^ {\min (T,)} A _ {h} [ i, j ]\right) \mathrm {d} r = \int_ {r = 0} ^ {1} D (r) \mathrm {d} r \tag{7}
322
+ $$
323
+
324
+ If the $r$ is same, a larger $D(r)$ means that the attention is more concentrated near the diagonal. Please note that $D(r)$ is a monotonically increasing function whose output is always in the range [0, 1].
325
+
326
+ To help understand the concept of CAD, we visualize two typical examples of the cumulative attention diagonality in Figure 9. For layer 2, where attention heads perform the phonetic localization, CAD values are low. In contrast, for layer 14 that concentrates on linguistic localization, CAD values are much higher.
327
+
328
+ Figure 10 plots the sorted CAD values. We determined the threshold (0.75) where the curve of sorted CAD values changes from convex to concave. The higher CAD value represents that more probability mass is concentrated near the diagonal in the attention map, while the lower CAD value
329
+
330
+ ![](images/8d252c2c384ca2d2cfe556a9898981cdbff43bcd940c60b4d517a1577a7a8b99.jpg)
331
+ Figure 10: Sorted CAD over attention heads in the baseline model. Over 64 heads, 42 heads belong to the CAD value under 0.75. The table on the right side indicates the number of linguistic attention heads that are of CAD value under 0.75.
332
+
333
+ <table><tr><td>#Layer</td><td>0</td><td>1</td><td>2</td><td>3</td></tr><tr><td>&lt; 0.75</td><td>4</td><td>4</td><td>4</td><td>4</td></tr><tr><td>#Layer</td><td>4</td><td>5</td><td>6</td><td>7</td></tr><tr><td>&lt; 0.75</td><td>4</td><td>4</td><td>4</td><td>4</td></tr><tr><td>#Layer</td><td>8</td><td>9</td><td>10</td><td>11</td></tr><tr><td>&lt; 0.75</td><td>4</td><td>2</td><td>2</td><td>0</td></tr><tr><td>#Layer</td><td>12</td><td>13</td><td>14</td><td>15</td></tr><tr><td>&lt; 0.75</td><td>1</td><td>0</td><td>0</td><td>1</td></tr></table>
334
+
335
+ implies that the distribution is more uniformly distributed. We observe that diagonally concentrated heads take a large portion in upper layers.
336
+
337
+ # B.1.2 PREVIOUS DIAGONALITY ANALYSIS
338
+
339
+ Previous studies utilized a different metric to calculate the diagonality of an attention map (Zhang et al., 2021b; Yang et al., 2020). In this version of diagonality, the metric is interpreted as the negative normalized average attention distance (span-length). In Yang et al. (2020), the diagonality is calculated as below:
340
+
341
+ $$
342
+ D _ {h} = 1 - \frac {1}{T ^ {2}} \sum_ {i = 1} ^ {T} \sum_ {j = 1} ^ {T} A _ {h} [ i, j ] \cdot | i - j | \tag {8}
343
+ $$
344
+
345
+ We introduced the cumulative attention diagonality (CAD) because the previous diagonality metric lacks information about how attention is distributed by distance. In other words, CAD is more comprehensive because it provides the overall diagonality value as well as the tendency of the attention according to the distance. Our CAD metric dearly captures the flat region in lower layers (Figure 2). In contrast, in Zhang et al. (2021b), the diagonality increases from the lower layers to the upper layers, which may not be sufficient observation in ASR.
346
+
347
+ # B.2 PHONEME ATTENTION RELATIONSHIP
348
+
349
+ # B.2.1 EXCLUDING CONSECUTIVE FRAMES
350
+
351
+ We treat $P_{h}[p,q](p \neq q)$ and $P_{h}[p,p]$ differently because we want to separate the effect of the diagonal (position-based) attention map. An attention map that highly focuses on the surroundings (diagonal-like) can unintentionally disturb the purpose of PAR in measuring $P_{h}[p,p]$ , because it will give a high value to $p-p$ relationship not because the contents are similar, but because the location is close. Our purpose on PAR is to examine the phonetic (content-based) behavior, so excluding consecutive frames of the same phoneme class better represents SA in lower layers that correspond to the phonetic localization.
352
+
353
+ # B.2.2 PAR RESULTS
354
+
355
+ Figure 11 visualizes how averaged PAR changes through layers. Lower layers (first row in Figure) show noticeable regions that represent the important phoneme relationships, including the diagonal. Note that the diagonal stands out even though we excluded the consecutive same phoneme classes. Each lower layer focuses on different aspects, supporting our analysis on the PAR coverage (Figure 6) that the accumulated coverage ratio continuously increases through layers. In other words, each layer covers a certain part of the reference PAR with less overlap between layers. On the other hand, the upper layers (second row in Figure) do not show the emphasized pattern. This is expected for linguistic localization heads that generate highly diagonal attention maps because their attention is mainly assigned to near frames regardless of their phoneme classes.
356
+
357
+ For the finer understanding, we also visualize how attention heads compose the averaged PAR. Figure 12 shows that each head corresponds to different phonological properties but their averaged
358
+
359
+ ![](images/f7cae79d9010981a5d6da116aa6edaabd841c3a1129662303d77dd952796fb92.jpg)
360
+ (a) Layer 2
361
+
362
+ ![](images/59f1b2409cb8ec2639afb75e16c3b9fff35593427343bfab777c39bdd0edd764.jpg)
363
+
364
+ ![](images/916c44037505b3ea5b405a319420b391c9d1acd7b9a0674775b1b897f6d093e1.jpg)
365
+
366
+ ![](images/2525d21588e337beb10b66b81a34df56491dfdf5c5e808d3af6974b258898250.jpg)
367
+
368
+ ![](images/8a60e4c4b4f899c17aa9595d525ec9759f122b6dc88a27fb10391c3109a33e9b.jpg)
369
+ (e) Layer 10
370
+
371
+ ![](images/10bfbe933f91586b9bc43579e554a3036620d3805de4c033e6cd208e55a98053.jpg)
372
+ (b) Layer 4
373
+ (f) Layer 12
374
+
375
+ ![](images/ea76f5d67bb0a8ab70e837e09eb11b07af0c1c7283d54fcf63167ba3958684d9.jpg)
376
+ (c) Layer 6
377
+ (g) Layer 14
378
+
379
+ ![](images/6eebd145bf0813ef6c3a79b0cb5ddf71d3303243ddd46e90cad33e4797202542.jpg)
380
+ (d) Layer 8
381
+ (h) Layer 16
382
+
383
+ ![](images/57bd7a7eb5d04d64d3524267cee6b0da624d21ff84d54a7348bed2b8e6cbbdd3.jpg)
384
+ (Layer 7)
385
+
386
+ ![](images/a3e97b748e99ca7cf89c5dcf4176aa1a7f294752fd81da940517a20c27c985f0.jpg)
387
+ Figure 11: Phoneme attention relationships (PAR) in SA layers. Averaged PAR of even-numbered layers (2nd, 4th, ... 16th) are visualized. Lower layers show high correlations between similar phonetic features, but these relationships are weakened in upper layers.
388
+ Head 1
389
+
390
+ ![](images/f158a7e1760e6fd80b32c754cde76bee4a78460c9133ffea3f60b956eb2a5aed.jpg)
391
+ Head 2
392
+
393
+ ![](images/b32d957f1428d9d85f28b5989308fbba17acdf680c0a0551cac3f7e6456b4890.jpg)
394
+ Head 3
395
+ Figure 12: Phoneme attention relationships of self-attention heads. Each head see different aspects, enriching the overall information the layer captures.
396
+
397
+ ![](images/33f891894a646ab7ea1e23c264d9fdebefd781f4ab0c0b224f1d6781dd792abe.jpg)
398
+ Head 4
399
+
400
+ interests mimic the reference PAR. This emphasizes the importance of multiple attention heads in phonetic localization; each head specializes in capturing the specific phoneme relationship and contributes differently.
401
+
402
+ # B.2.3 PREVIOUS PHONEMERELATIONSHIPANALYSIS
403
+
404
+ The idea of phoneme relationship analysis is first introduced in Yang et al. (2020) as phoneme relation map (PRM), but our PAR is different from PRM in two ways. First and the most difference is that PRM do not distinguish consecutive frames and discontinuous frames that corresponds to the same phoneme class. Therefore, attention heads that only focus on neighbors would also present heavy self-to-self phoneme relationship in PRM, which hinders the clarity of the analysis. Second, PRM do not apply correction according to the sequence length. We multiply $T$ to reduce the effect of sequence length, inspired by the fact that the expectation of (averaged) probability is potentially smaller for longer sequences.
405
+
406
+ ![](images/1a7e2a56eaf40701f538e245fc4b87c1eed9b18f9b2228b48bf297014b4bdd4a.jpg)
407
+ (a) $2 \times 8$
408
+
409
+ ![](images/3023a57a2fd6d2938fe4f81d5a1edde303f9faee7aa79f36e1032a3ab22836ab.jpg)
410
+ (b) $4 \times 4$
411
+ Figure 13: Phoneme attention relationship (PAR) for three attention map reuse configurations $(2 \times 8, 4 \times 4, 8 \times 2)$ . PAR(a)(b)(c) are obtained by averaging PAR of lower layers. Key missing relationship is highlighted in white circles, such as (B, P), (G, K), and (DH, TH) in Figure 5(a).
412
+
413
+ ![](images/13a899e91c69ac70f60724e776f7e7297c2180863e35a4bf6316416d7d94e2cb.jpg)
414
+ (c) $8 \times 2$
415
+
416
+ # B.3 ATTENTION MAP REUSE AND PAR
417
+
418
+ For the understanding of the performance loss for extreme reuse cases, we visualize the PAR of different configurations in Figure 13. We observe that most of the patterns resemble the baseline model, which implies that heads learn similar roles during training. However, for $8 \times 2$ , several information is lost; diagonal became unclear and highlighted correlations disappeared.
419
+
420
+ # B.4 COMPARISON TO MASKED ATTENTION
421
+
422
+ We compare the masked attention (Zhang et al., 2020a; Tripathi et al., 2020; Audhkhasi et al., 2021; Huang et al., 2020) with the proposed attention map reuse. Masked attention, similar to block-based attention (Shen et al., 2018; Qiu et al., 2020), is a method to reduce the computational burden of self-attention by restricting the length of the accessible context. If masked attention is adopted for ASR, each frame only attends to local neighbors; $L$ frames to the left and $R$ frames to the right, denoted as $[-L,R]$ .
423
+
424
+ Table 6: Comparison of the word error rate between the proposed attention reuse and the masked attention. “-” indicates that the attention range is not restricted (unlimited).
425
+
426
+ <table><tr><td>Model</td><td>Lower layers</td><td>Upper layers</td><td>dev-clean</td><td>dev-other</td><td>test-clean</td><td>test-other</td></tr><tr><td>Baseline</td><td>-</td><td>-</td><td>3.1</td><td>8.3</td><td>3.2</td><td>8.4</td></tr><tr><td>Low64</td><td>[-64, 64]</td><td>-</td><td>3.1</td><td>8.4</td><td>3.4</td><td>8.5</td></tr><tr><td>Up64</td><td>-</td><td>[-64, 64]</td><td>3.1</td><td>8.2</td><td>3.3</td><td>8.2</td></tr><tr><td>4(H8) × 4</td><td>-</td><td>-</td><td>3.1</td><td>8.1</td><td>3.2</td><td>8.1</td></tr></table>
427
+
428
+ We train the models with the same setting as the Conformer-M baseline (as in Table 2) but with a limited attention range for either lower or upper layers. Among the 16 layers in the baseline, lower and upper layers consist of 8 layers each and correspond to phonetic localization and linguistic localization, respectively. For selected layers, we restrict each frame to only attend to near neighbors within the distance of 64 frames. Table 6 shows the performance on the LibriSpeech dataset.
429
+
430
+ For lower layers, attention range restriction causes a clear degradation of the recognition accuracy. We consider that phonetic localization in lower layers demands a wide range of attention. On the other hand, for upper layers, attention range restriction shows almost comparable performance to the baseline, and even better in some subsets. We hypothesize that the upper layers for CTC-based ASR may not require a very wide context, because their attention pattern is highly diagonal. In addition, the restriction-based computational savings seems to be no larger than the proposed attention reuse. A context range of 128 (64+64) frames corresponds to about 5.1 seconds, where the average utterance length of the corpora is about 7.4 seconds. Therefore, we expect approximately $30\%$ reduction in attention calculation when masked attention is applied to every layer. Our attention reuse $(4 \times 4)$ reduces about $75\%$ of the attention computation without any degradation in the performance.
understandingtheroleofselfattentionforefficientspeechrecognition/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4811423ee8c20c7932c446a79ffa5efd6ceb9485a4139363c2540e49db0a278f
3
+ size 885128
understandingtheroleofselfattentionforefficientspeechrecognition/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d1af7190219c1e39b581cbae76761047b9b01e570976bf92be3698a41673f350
3
+ size 571100
unifyinglikelihoodfreeinferencewithblackboxoptimizationandbeyond/233cc708-146f-4dc3-9d0a-3b19ec3ef5ab_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e957a5dbccd8e0b563c165fad528ae36d43312b722e3bd9e209f199b4e68e5cf
3
+ size 127732
unifyinglikelihoodfreeinferencewithblackboxoptimizationandbeyond/233cc708-146f-4dc3-9d0a-3b19ec3ef5ab_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1654f0441debfe953740e5a36230ab5799b1f73a68bc0bac77fea5ace552e64d
3
+ size 153675
unifyinglikelihoodfreeinferencewithblackboxoptimizationandbeyond/233cc708-146f-4dc3-9d0a-3b19ec3ef5ab_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:42091c03a64758daa4ac4381290d4c94e668452f1fdb4216154cdfe1b8874787
3
+ size 504899
unifyinglikelihoodfreeinferencewithblackboxoptimizationandbeyond/full.md ADDED
@@ -0,0 +1,490 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # UNIFYING LIKELIHOOD-FREE INFERENCE WITH BLACK-BOX OPTIMIZATION AND BEYOND
2
+
3
+ Dinghuai Zhang $^{1,2}$ , Jie Fu $^{1,2*}$ , Yoshua Bengio $^{1,2,3}$ , Aaron Courville $^{1,2,3}$
4
+
5
+ <sup>1</sup>Mila, <sup>2</sup>University of Montreal, <sup>3</sup>CIFAR Fellow
6
+
7
+ Montreal, Canada
8
+
9
+ {dinghuai.zhang, fujie}@mila.quebec
10
+
11
+ # ABSTRACT
12
+
13
+ Black-box optimization formulations for biological sequence design have drawn recent attention due to their promising potential impact on the pharmaceutical industry. In this work, we propose to unify two seemingly distinct worlds: likelihood-free inference and black-box optimization, under one probabilistic framework. In tandem, we provide a recipe for constructing various sequence design methods based on this framework. We show how previous optimization approaches can be "reinvented" in our framework, and further propose new probabilistic black-box optimization algorithms. Extensive experiments on sequence design application illustrate the benefits of the proposed methodology.
14
+
15
+ # 1 INTRODUCTION
16
+
17
+ Discovering new drugs to fulfill specific criteria, such as binding affinity towards a given molecular target, is a fundamental problem in chemistry and the pharmaceutical industry (Hughes et al., 2011). In this work, we focus on an important subdomain: de novo biological sequence design. This task is challenging for two reasons: (1) the exploration space for sequences is combinatorially large; and (2) sequence usefulness is evaluated via a complicated process which usually involves time-consuming and expensive wet-lab experiments.
18
+
19
+ Despite the difficulty of this task, many approaches have been developed over the past few decades thanks to recent advances in biochemistry and machine learning. The Nobel Prize wining paradigm, directed evolution (Chen & Arnold, 1991), which conducts local evolutionary search under human guidance, is one of the popular techniques. Unfortunately, it is limited by its sample inefficiency and reliance on strong prior knowledge, e.g., about where to mutate (Ahn et al., 2020). Furthermore, to compete with other machine learning methods (Gottipati et al., 2020), guided evolution (Yoshikawa et al., 2018; Jensen, 2019; Nigam et al., 2019) heavily relies on human intuition for designing domain-specific evolutionary operators, which may not always apply to tasks at hand.
20
+
21
+ In this work, we deem sequence design to be a black-box optimization problem, tasked with maximizing an unknown oracle function. We assume that oracle queries are limited due to the constraint on resources, such as the budgets for evaluating queries in a wet-lab. Thus, sample efficiency is crucial. We develop a probabilistic framework by reformulating the aforementioned black-box optimization target as a posterior modeling problem. With this framework, we draw a surprising connection between likelihood-free inference and sequence design, and thus linking two fields which are previously considered as unrelated. The key observation we leverage here for establishing this connection is that both settings share similar elements and targets which will be elaborated in Section 2.2. This connection facilitates our understanding of both fields and provides a recipe for developing sequence design algorithms. Going beyond, we also combine different probabilistic modeling insights and develop three novel composite probabilistic algorithms. We point out that our framework could actually be applied to any black-box optimization settings, but in this work we focus on its application to biological sequence design.
22
+
23
+ To demonstrate the empirical effectiveness of our methods, we conduct systematical experiments to evaluate their performance on four in-silico sequence design benchmarks. Our proposed meth-
24
+
25
+ ods achieve at least comparable results to existing baselines, and the proposed composite methods behave consistently better than all other ones across various sequence design tasks.
26
+
27
+ We summarize our contribution as follows:
28
+
29
+ - We develop a probabilistic framework that unifies likelihood-free inference and black-box optimization.
30
+ - Based on this framework, we provide a recipe for designing algorithms for black-box problems. We apply these ideas to propose a series of composite design algorithms.
31
+ - We perform systematical evaluation on a series of black-box sequence design benchmarks, and find that these algorithms achieve consistently comparable or better results compared to previous ones, thus illustrating the benefit of the proposed unified framework.
32
+
33
+ # 2 A UNIFYING PROBABILISTIC FRAMEWORK
34
+
35
+ # 2.1 BACKGROUND
36
+
37
+ Likelihood-free inference (LFI). We use $\theta \in \Theta$ and $\mathbf{x} \in \mathcal{X}$ to separately denote the parameters and the data generated via the mechanism $\mathbf{x} \sim p(\mathbf{x}|\boldsymbol{\theta})$ . In this scenario, LFI refers to a special kind of Bayesian inference setting where the likelihood function is not tractable but sampling (by simulation) from the likelihood is feasible. Consider the objective of modeling the Bayesian posterior when we cannot compute the likelihood $p(\mathbf{x}_o|\boldsymbol{\theta})$ :
38
+
39
+ $$
40
+ p (\boldsymbol {\theta} | \mathbf {x} _ {o}) \propto p (\boldsymbol {\theta}) \underbrace {p (\mathbf {x} _ {o} | \boldsymbol {\theta})} _ {?}, \tag {1}
41
+ $$
42
+
43
+ where $\mathbf{x}_o$ is the observed data, $p(\boldsymbol{\theta})$ is the (given) prior over the model parameters $\boldsymbol{\theta}$ , $p(\mathbf{x}|\boldsymbol{\theta})$ is the intractable likelihood function and $p(\boldsymbol{\theta}|\mathbf{x})$ is the desired posterior over $\boldsymbol{\theta}$ . While we do not have access to the exact likelihood, we can still simulate (sample) data $\mathbf{x}$ from the model simulator: $\mathbf{x} \sim p(\mathbf{x}|\boldsymbol{\theta})$ . Instead of trying to obtain a numerical value of the generic posterior $p(\boldsymbol{\theta}|\mathbf{x})$ for arbitrary $\mathbf{x}$ , LFI only tries to obtain an approximation of $p(\boldsymbol{\theta}|\mathbf{x}_o)$ for the given $\mathbf{x}_o$ . During the inference process, we can take advantage of the sampled data: $\mathcal{D} = \{(\boldsymbol{\theta}_i, \mathbf{x}_i)\}_{i=1}^n$ where $\mathbf{x}_i \sim p(\mathbf{x}|\boldsymbol{\theta}_i)$ for selected values of $\boldsymbol{\theta}_i$ .
44
+
45
+ Biological black-box sequence design. We consider biological sequence design as a black-box optimization problem:
46
+
47
+ $$
48
+ \mathbf{m}^{*} = \operatorname *{arg max}_{\mathbf{m}\in \mathcal{M}}f(\mathbf{m}),
49
+ $$
50
+
51
+ where $f(\cdot)$ is the oracle score function, and we would like to discover values of $\mathbf{m}$ for which $f(\mathbf{m})$ is large. In real-world situations, a query of this oracle $f$ could represent a series of wet-lab experiments to measure specific chemical properties or specificity for a given binding site target. In general, these experiments are time- and cost-consuming. As a result, the total number of queries is limited.
52
+
53
+ In our setting, we use $\mathcal{M} = \mathcal{V}^L$ to denote the search space for sequences with fixed length $L$ , where $\mathcal{V}$ is the vocabulary for each entry of the sequence: for DNA nucleotides $|\mathcal{V}| = 4$ , and for protein amino acids $|\mathcal{V}| = 20$ . For variable length setting, we have $\mathcal{M} = \cup_{L \in [L_{\min}, L_{\max}]} \mathcal{V}^L$ , where $L_{\min}$ and $L_{\max}$ are the minimal and maximal length, respectively.
54
+
55
+ # 2.2 CONNECTING LFI AND BLACK-BOX OPTIMIZATION
56
+
57
+ In order to draw a connection to LFI, we require a probabilistic formulation of the black-box sequence design problem. To this end, we relax the goal of searching for a single maximum of the oracle / score function $f$ to a posterior modeling problem, i.e., finding a representative sample of the configurations of $\mathbf{m}$ sampled with probability related to some target posterior. Think of $\mathcal{C}$ is the set of sequences with these desirable configurations, $\mathcal{E}$ is a Boolean event about whether a sequence $\mathbf{m}$ belongs to $\mathcal{C}$ , and our goal is to characterize the posterior distribution $p(\mathbf{m}|\mathcal{E})$ from which we obtain the desired sequences. Below, we consider two specific ways of doing this:
58
+
59
+ Example A. We explicitly define $\mathcal{C}$ (and $\mathcal{E}$ accordingly) as all the sequences whose scores are larger than a given threshold $s$ :
60
+
61
+ $$
62
+ \mathcal {C} = \left\{\mathbf {m} \mid f (\mathbf {m}) \geq s \right\}. \tag {2}
63
+ $$
64
+
65
+ Here $s$ could be any fixed value, or a certain quantile of a particular score distribution. In this way, we have $p(\mathcal{E}|\mathbf{m}) = p(\mathbf{m}\in \mathcal{C}|\mathbf{m}) = \mathbb{1}\{f(\mathbf{m})\geq s\}$ where $\mathbb{1}\{\}$ is the indicator function.
66
+
67
+ Example B. In a softer version of $\mathcal{E}$ and $\mathcal{C}$ , we can define its conditional probability of being true to follow a Boltzmann distribution:
68
+
69
+ $$
70
+ p (\mathcal {E} | \mathbf {m}) = p (\mathbf {m} \in \mathcal {C} | \mathbf {m}) \propto \exp (f (\mathbf {m}) / \tau). \tag {3}
71
+ $$
72
+
73
+ where $\tau$ is a temperature parameter. We introduce the exponential because $f(\cdot)$ does not necessarily take positive values. Any monotone transformation of $f(\cdot)$ to non-negative reals could be used, so that sequences with larger oracle scores have a greater probability of making $\mathcal{E}$ true.
74
+
75
+ With this posterior objective, our goal now becomes effectively modeling and sampling from the posterior $p(\mathbf{m}|\mathcal{E})$ . It is thus natural to resort to the tools of Bayesian inference for this task. In order to examine this possibility, we draw a detailed comparison between the settings of black-box sequence design problem and likelihood-free Bayesian inference in Table 1.
76
+
77
+ <table><tr><td></td><td>Likelihood-free inference</td><td>Black-box optimization</td></tr><tr><td>Element</td><td>(θ, x)</td><td>(m, s)</td></tr><tr><td>Target</td><td>p(θ|x_o)</td><td>p(m|ε)</td></tr><tr><td rowspan="2">Constraint</td><td>limited simulation: x ~ p(x|θ)</td><td>limited query: s ~ f(m)</td></tr><tr><td>intractable likelihood: p(x|θ)</td><td>black-box oracle: f(m)</td></tr></table>
78
+
79
+ Table 1: Correspondence between likelihood-free inference and black-box optimization.
80
+
81
+ It can be observed that both tasks share similar elements and targets. The two settings also share similar limitations on the allowed queries, which are too time-consuming and / or cost-intensive. Notice that in sequence design, the oracle could be either exact or noisy, thus we use the more general $s \sim f(\mathbf{m})$ formulation rather than $s = f(\mathbf{m})$ . We will further present several concrete examples as demonstrations of this correspondence in the following section.
82
+
83
+ Another way to understand this correspondence is to consider the following mapping $T$ :
84
+
85
+ $$
86
+ \begin{array}{l} T: \Theta \times \mathcal {X} \to \mathcal {M} \times \mathbb {R} \\ (\boldsymbol {\theta}, \mathbf {x}) \mapsto (\mathbf {m}, s), \quad \text {s . t .} \quad s = - \| \mathbf {x} - \mathbf {x} _ {o} \| . \\ \end{array}
87
+ $$
88
+
89
+ Here we can see the score value $s$ as a quantitative metric for how close the generated data $\mathbf{x}$ (given $\theta$ ) is to the target observed data $\mathbf{x}_o$ . In addition, querying the oracle in the sequence design setting can also be thought of as follows: (1) sample $\mathbf{x} \sim p(\cdot | \boldsymbol{\theta})$ and then (2) calculate $s = -\| \mathbf{x} - \mathbf{x}_o \|$ under some distance $\| \cdot \|$ . In this manner, $T$ could conceptually transform any LFI problem into a black-box optimization task. In this work, we only focus on the application of sequence design.
90
+
91
+ # 3 METHODOLOGY
92
+
93
+ We provide a recipe for designing new sequence design algorithms based on the correspondence in Section 2.2. The recipe induces different approaches by modeling different probabilistic components of the Bayesian inference problem. We begin with common algorithm restrictions under this setting.
94
+
95
+ Common constraint for algorithms. Due to the restriction of simulation / query in our setting, we constrain our algorithms to act in a sequential / iterative way, gradually achieving the desired posterior round by round. Every algorithm starts with an empty dataset $\mathcal{D} = \varnothing$ and an initial proposal $p_1(\cdot) = p(\cdot)$ , where $p(\cdot)$ is the prior given by the task. In the $r$ -th round of this multi-round setting, the algorithm would use the proposal $p_r(\cdot)$ of this round to sample a batch of data $(\theta / \mathbf{m})$ for simulation / query, and augment the current dataset $\mathcal{D}$ with the newly obtained batch of data. We use $n$ to denote the batch size for each round's simulation / query. Afterwards, the algorithm updates
96
+
97
+ the proposal to $p_{r + 1}(\cdot)$ . The outcomes for the two settings we discuss may be slightly different: an algorithm for likelihood-free inference would return the posterior, while a sequence design method would return the dataset of all the sequences it has queried, which hopefully contains desired high scored sequences. On the other hand, a sequence design method could produce as an intermediate result a generative model for sampling queries, which then completely fits with the LFI framework.
98
+
99
+ # 3.1 BACKWARD MODELING OF THE MECHANISM
100
+
101
+ Approximate Bayesian Computation (ABC) (Beaumont et al., 2002) is a standard method for tackling LFI problems. In Algorithm 1, we display one of the most popular variants: Sequential Monte Carlo-Approximate Bayesian Computation (SMC-ABC) (Beaumont et al., 2009). In each round, parameters $\theta$ are sampled from the current proposal distribution $p_r(\theta)$ for simulation. A rejection step is then involved to remove the $\theta_i$ whose simulation outcomes $\mathbf{x}_i$ cannot reproduce the observed data $\mathbf{x}_o$ with sufficient accuracy. The remaining accepted $\{\theta_i\}_i$ are adopted to update the next round's proposal $p_{r + 1}(\cdot)$ towards the target posterior, i.e., by refitting $q_{\phi}$ with the modified data. We defer more details of this approach to Section A.1 in Appendix.
102
+
103
+ Algorithm 1 SMC-ABC
104
+ $p_1(\pmb {\theta})\gets p(\pmb {\theta})$
105
+ for $r$ in 1 to $R$ do repeat sample $\pmb {\theta}_i\sim p_r(\pmb {\theta})$ simulate $\mathbf{x}_i\sim p(\mathbf{x}|\pmb {\theta}_i)$ until $n$ samples are obtained $\mathcal{D}\leftarrow \mathcal{D}\cup \{(\pmb {\theta}_i,\mathbf{x}_i)\}_{i = 1}^n$ sort $\mathcal{D}$ according to $-\| \mathbf{x}_i - \mathbf{x}_o\|$ fit $q_{\phi}(\pmb {\theta})$ with top $\{\pmb {\theta}_i\} _i$ in $\mathcal{D}$ $p_{r + 1}(\pmb {\theta})\gets q_{\phi}(\pmb {\theta})$
106
+ end for
107
+ return $\hat{p} (\pmb {\theta}|\mathbf{x}_o) = p_{R + 1}(\pmb {\theta})$
108
+
109
+ Algorithm 2 FB-VAE
110
+ $p_1(\mathbf{m})\gets p(\mathbf{m})$
111
+ for $r$ in 1 to $R$ do repeat sample $\mathbf{m}_i\sim p_r(\mathbf{m})$ query the oracle: $s_i\gets f(\mathbf{m}_i)$ until $n$ samples are obtained $\mathcal{D}\gets \mathcal{D}\cup \{( \mathbf { m } _ { i } , s _ { i } ) \} _ { i = 1 } ^ { n }$ sort $\mathcal{D}$ according to $s_i$ fit $q_{\phi}(\mathbf{m})$ with top $\{\mathbf{m}_i\}_{i}$ in $\mathcal{D}$ $p_{r + 1}(\mathbf{m})\leftarrow q_{\phi}(\mathbf{m})$ end for return $\{\mathbf{m}:(\mathbf{m},s)\in \mathcal{D}\}$
112
+
113
+ It would then be natural to construct an analogical sequence design algorithm using top scored entities $\{\mathbf{m}_i\}_i$ to guide the update of a certain sequence distribution, see Algorithm 2. Interestingly, this is the proposed sequence design algorithm in Gupta & Zou (2019), where the authors name this kind of updating "feedback" because training of the parametric generator $q_{\phi}(\mathbf{m})$ exploits feedback signals from the oracle. In this paper, we follow Brookes & Listgarten (2018) to crystallize $q_{\phi}(\mathbf{m})$ to be a variational autoencoder (Kingma & Welling, 2014), and use the term Feedback-Variational AutoEncoder (FB-VAE) to refer to Algorithm 2. We place Algorithm 1 & 2 side-by-side to highlight their correspondence. We also make the same arrangement for the following Algorithm 3 & 4, Algorithm 5 & 6 and Algorithm 7 & 8.
114
+
115
+ Algorithm 3 Sequential Neural Posterior
116
+ $p_1(\pmb {\theta})\gets p(\pmb {\theta})$
117
+ for $r$ in 1 to $R$ do repeat sample $\pmb {\theta}_i\sim p_r(\pmb {\theta})$ simulate $\mathbf{x}_i\sim p(\mathbf{x}|\pmb {\theta}_i)$ until $n$ samples are obtained $\mathcal{D}\gets \mathcal{D}\cup \{(\pmb {\theta}_i,\mathbf{x}_i)\}_{i = 1}^n$ $q_{\phi}\gets \arg \min_{q}\mathbb{E}_{\mathbf{x}}[D_{\mathrm{KL}}(p(\pmb {\theta}|\mathbf{x})||q)];$ $p_{r + 1}(\pmb {\theta})\gets q_{\phi}(\pmb {\theta}|\mathbf{x}_o);$
118
+ end for
119
+ return $\hat{p} (\pmb {\theta}|\mathbf{x}_o) = p_{R + 1}(\pmb {\theta})$
120
+
121
+ Algorithm 4 Design by Adaptive Sampling
122
+ $p_1(\mathbf{m})\gets p(\mathbf{m})$
123
+ for $r$ in 1 to $R$ do repeat sample $\mathbf{m}_i\sim p_r(\mathbf{m})$ query the oracle: $s_i\gets f(\mathbf{m}_i)$ until $n$ samples are obtained $\mathcal{D}\gets \mathcal{D}\cup \{( \mathbf { m } _ { i } , s _ { i } ) \} _ { i = 1 } ^ { n }$ $q_{\phi}\leftarrow \arg \min_{q}D_{\mathrm{KL}}(p(\mathbf{m}|\mathcal{E})||q);\right.$ $p_{r + 1}(\mathbf{m})\gets q_{\phi}(\mathbf{m});$
124
+ end for
125
+ return $\{\mathbf{m}:(\mathbf{m},s)\in \mathcal{D}\}$
126
+
127
+ In comparison with SMC-ABC, the Sequential Neural Posterior (SNP) method (Papamakarios & Murray, 2016; Lueckmann et al., 2017; Greenberg et al., 2019) for likelihood-free inference adopts a more flexible approach, taking the power of conditional neural density estimator (e.g., Papamakarios et al. (2017)) to model the general posterior $p(\pmb{\theta}|\mathbf{x})$ , which takes arbitrary $\pmb{\theta}$ and $\mathbf{x}$ as two inputs and outputs a distribution. This neural estimator is trained via approximately minimizing the
128
+
129
+ Kullback-Leibler (KL) divergence between $q_{\phi}(\pmb{\theta}|\mathbf{x})$ and the true posterior $p(\pmb{\theta}|\mathbf{x})$ . We defer more training details to Section A.1 in Appendix. Under the connection viewpoint, one similar algorithm for sequence design is the Design by Adaptive Sampling (DbAS) proposed in Brookes & Listgarten (2018) which is characterized in Algorithm 4, fitting $q_{\phi}(\mathbf{m})$ through minimizing the KL divergence with the posterior $p(\mathbf{m}|\mathcal{E})$ . Based on the difference in specific implementations, both algorithms have more than one variant, whose details are deferred to Section A.1 in Appendix.
130
+
131
+ We refer to the above algorithms as "backward modeling" because the trained generative network $q_{\phi}$ (going from $\mathbf{x} / \mathcal{E}$ to $\theta / \mathbf{m}$ ) is a sort of reverse model of the simulation mechanism (which goes from $\theta / \mathbf{m}$ to $\mathbf{x} / s$ ).
132
+
133
+ # 3.2 FORWARD MODELING OF THE MECHANISM
134
+
135
+ Whereas the above methods focus on directly modeling the target posterior with a generative model that learns a "reverse mechanism" of the simulation process, it is also possible to model the "forward mechanism", which is consistent with the simulation process. Papamakarios et al. (2019) claim that the forward modeling approach may be an easier task than its backward counterpart, as unbiased estimation of the likelihood does not depend on the choice of proposal. Consequently, in contrast to SNP, Papamakarios et al. (2019) chooses to train a neural density estimator to model the conditional likelihood distribution $q_{\phi}(\mathbf{x}|\boldsymbol{\theta})$ sequentially in each round. The training is achieved by maximizing the total log likelihood $\max_q\sum_i\log q_\phi (\mathbf{x}_i|\boldsymbol {\theta}_i)$ with data samples from the dataset $\mathcal{D}$ at the current $(r$ -th) round. The downside of this forward approach is an additional computational Markov Chain Monte Carlo (MCMC) step is needed to sample from the $r$ -th round posterior / proposal $p_r(\boldsymbol{\theta})$ . The resulting approach, which is coined (Papamakarios et al., 2019) the Sequential Neural Likelihood (SNL), is summarized in Algorithm 5.
136
+
137
+ In the spirit of directly modeling the forward mechanism of sequence design, we train a regressor $\hat{f}_{\phi}(\mathbf{m})$ in a supervised manner to fit the oracle scorer. In order to adapt this regressor into the update procedure of the proposal of the next round, we use $\tilde{q} (\mathbf{m})$ to denote the unknown posterior $p(\mathbf{m}|\mathcal{E})$ with knowledge of $\hat{f}_{\phi}(\mathbf{m})$ and prior $p(\mathbf{m})$ . The specific construction of $\tilde{q} (\mathbf{m})$ depends on the choice of $\mathcal{E}$ . For instance, if we choose Example B in Section 2.2 to be the definition of $\mathcal{E}$ , then $\tilde{q} (\mathbf{m})$ is the distribution with (unnormized) probability $p(\mathbf{m})\cdot \exp (\hat{f}_{\phi}(\mathbf{m}) / \tau)$ . See Section A.2 in Appendix for more elaboration about this point. We then choose the update procedure of the proposal $p_{r + 1}(\mathbf{m})$ to be analogical to that of SNL. We name this proposed algorithm to be Iterative Scoring (IS) to avoid confusion with likelihood-free inference algorithms. Furthermore, depending on different definition of $\mathcal{E}$ , we use the name "IS-A" and "IS-B" for them in the following sections.
138
+
139
+ Algorithm 5 Sequential Neural Likelihood
140
+ $p_1(\theta)\gets p(\theta);$
141
+ for $r$ in 1 to $R$ do repeat sample $\pmb {\theta}_i\sim p_r(\pmb {\theta})$ simulate $\mathbf{x}_i\sim p(\mathbf{x}|\pmb {\theta}_i)$ until $n$ samples are obtained $\mathcal{D}\gets \mathcal{D}\cup \{(\pmb {\theta}_i,\mathbf{x}_i)\}_{i = 1}^n$ fit $q_{\phi}(\mathbf{x}|\pmb {\theta})$ with $\mathcal{D}$ .. $p_{r + 1}(\pmb {\theta})\propto p(\pmb {\theta})\cdot q_{\phi}(\mathbf{x}_o|\pmb {\theta})$ end for return $\hat{p} (\pmb {\theta}|\mathbf{x}_o) = p_{R + 1}(\pmb {\theta})$
142
+
143
+ Algorithm 6 Iterative Scoring
144
+ $p_1(\mathbf{m})\gets p(\mathbf{m})$
145
+ for $r$ in 1 to $R$ do repeat sample $\mathbf{m}_i\sim p_r(\mathbf{m})$ query the oracle: $s_i\gets f(\mathbf{m}_i)$ until $n$ samples are obtained $\mathcal{D}\leftarrow \mathcal{D}\cup \{(\mathbf{m}_i,s_i)\}_{i = 1}^n$ fit $\hat{f}_{\phi}(\mathbf{m})$ with $\mathcal{D}$ construct $\tilde{q} (\mathbf{m})$ with $\hat{f}_{\phi}(\cdot)$ and $p(\mathbf{m})$ $p_{r + 1}(\mathbf{m})\gets \tilde{q} (\mathbf{m})$
146
+ end for
147
+ return $\{\mathbf{m}:(\mathbf{m},s)\in \mathcal{D}\}$
148
+
149
+ # 3.3 MODELING A PROBABILITY RATIO
150
+
151
+ In this subsection, we discuss yet another approach, through the estimation of a probability ratio. Gutmann & Hyvarinen (2010) proposes noise contrastive estimation as a statistical inference approach. This methodology turns a hard probability modeling problem into binary classification, which is considered easier to learn. In contrast to the aforementioned likelihood-free inference methods which rely on a form of density estimation to perform the task, Sequential Neural Ratio
152
+
153
+ (SNR) (Hermans et al., 2019) takes a similar approach as noise contrastive estimation. SNR adopts a classification approach to estimate the likelihood-to-evidence ratio $r(\pmb{\theta}, \mathbf{x}) = p(\pmb{\theta}|\mathbf{x}) / p(\pmb{\theta})$ . SNR is summarized in Algorithm 7. Specifically, in each round, SNR fits a binary classifier $d_{\phi}(\pmb{\theta}, \mathbf{x}) \in [0,1]$ in the following manner:
154
+
155
+ $$
156
+ \arg \min _ {d} \left\{\sum_ {\left(\boldsymbol {\theta} _ {i}, \mathbf {x} _ {i}\right) \in \mathcal {D}} \left[ - \log d \left(\mathbf {x} _ {i}, \boldsymbol {\theta} _ {i}\right) \right] + \sum_ {\left(\boldsymbol {\theta} _ {i} ^ {\prime}, \mathbf {x} _ {i}\right) \in \mathcal {D} ^ {\prime}} \left[ - \log \left(1 - d \left(\mathbf {x} _ {i}, \boldsymbol {\theta} _ {i} ^ {\prime}\right)\right) \right] \right\}. \tag {4}
157
+ $$
158
+
159
+ We show that with the $\mathcal{D}$ and $\mathcal{D}'$ established in Algorithm 7, we have
160
+
161
+ $$
162
+ d ^ {*} (\pmb {\theta}, \mathbf {x}) = \frac {p (\pmb {\theta} | \mathbf {x})}{p (\pmb {\theta}) + p (\pmb {\theta} | \mathbf {x})}, r ^ {*} (\pmb {\theta}, \mathbf {x}) := \frac {d ^ {*} (\pmb {\theta} , \mathbf {x})}{1 - d ^ {*} (\pmb {\theta} , \mathbf {x})} = \frac {p (\pmb {\theta} | \mathbf {x})}{p (\pmb {\theta})}
163
+ $$
164
+
165
+ where the $*$ denotes the optimality. We have the following Proposition 1:
166
+
167
+ Proposition 1. Let $p_0(\mathbf{a})$ and $p_1(\mathbf{a})$ be two distributions for $d_a$ -dimension random variable $\mathbf{a}$ which takes value in the space of $\mathcal{A} = \mathbb{R}^{d_a}$ , and $d(\mathbf{a}) : \mathcal{A} \to [0,1]$ is a real-value function mapping any $\mathbf{a}$ to a positive real value number. Then the functional optimization problem
168
+
169
+ $$
170
+ \operatorname * {a r g m a x} _ {d: \mathcal {A} \to [ 0, 1 ]} \left\{\mathbb {E} _ {\mathbf {a} \sim p _ {0} (\mathbf {a})} [ \log d (\mathbf {a}) ] + \mathbb {E} _ {\mathbf {a} \sim p _ {1} (\mathbf {a})} [ \log (1 - d (\mathbf {a})) ] \right\}.
171
+ $$
172
+
173
+ will lead to the optimal solution $d^{*}(\mathbf{a}) = \frac{p_{0}(\mathbf{a})}{p_{0}(\mathbf{a}) + p_{1}(\mathbf{a})}$ .
174
+
175
+ See the proof in Section A.3 in Appendix. After training $d$ , SNR can obtain the posterior density value by $p(\boldsymbol{\theta}|\mathbf{x}) = r^{*}(\boldsymbol{\theta},\mathbf{x})p(\boldsymbol{\theta})$ . SNR mirrors SNL in that it samples the new proposal $p_{r + 1}(\boldsymbol{\theta})$ without explicitly modeling the posterior.
176
+
177
+ On the other hand, we propose a sequence design algorithm analogous to SNR and named Iterative Ratio (IR), which estimates the probability ratio $r(\mathbf{m}) = p(\mathbf{m}|\mathcal{E}) / p(\mathbf{m})$ for the purpose of posterior sampling. IR first builds two datasets $\mathcal{D}$ and $\mathcal{D}'$ , corresponding to two different distributions $p(\mathbf{m}|\mathcal{E})$ and $p(\mathbf{m})$ . We take a similar binary classification approach, whose training objective is $\min_d\left\{\sum_{\mathbf{m}\in \mathcal{D}}[-\log d(\mathbf{m})] + \sum_{\mathbf{m}\in \mathcal{D}'}[-\log (1 - d(\mathbf{m}))]\right\}$ . The desired ratio is then obtained by $r(\mathbf{m}) := d(\mathbf{m}) / (1 - d(\mathbf{m}))$ . Other components of IR follow the scheme of IS, and IR is schematized in Algorithm 8. We point out that IR does not have two variants as IS does, as the definition for $\mathcal{E}$ in Example B is not usable because of the unknown normalizing constant for probability $p(\mathcal{E}|\mathbf{m})$ . See Section A.3 in Appendix for more explanation.
178
+
179
+ Algorithm 7 Sequential Neural Ratio
180
+ $p_1(\boldsymbol{\theta}) \gets p(\boldsymbol{\theta})$ ;
181
+ for $r$ in 1 to $R$ do
182
+ repeat
183
+ sample $\boldsymbol{\theta}_i, \boldsymbol{\theta}_i' \sim p_r(\boldsymbol{\theta})$ ;
184
+ simulate $\mathbf{x}_i \sim p(\mathbf{x}|\boldsymbol{\theta}_i)$ ;
185
+ until $n$ samples are obtained
186
+ $\mathcal{D} \gets \mathcal{D} \cup \{(\boldsymbol{\theta}_i, \mathbf{x}_i)\}_{i=1}^n$ $\mathcal{D}' \gets \mathcal{D}' \cup \{(\boldsymbol{\theta}_i', \mathbf{x}_i)\}_{i=1}^n$
187
+ train $d_{\phi}(\boldsymbol{\theta}, \mathbf{x})$ classifying between $\mathcal{D}$ and $\mathcal{D}'$ with the loss in Eq. 4;
188
+ $r_{\phi}(\boldsymbol{\theta}, \mathbf{x}) \gets \frac{d_{\phi}(\boldsymbol{\theta}, \mathbf{x})}{1 - d_{\phi}(\boldsymbol{\theta}, \mathbf{x})}$ ;
189
+ $p_{r+1}(\boldsymbol{\theta}) \propto r_{\phi}(\boldsymbol{\theta}, \mathbf{x}) \cdot p(\boldsymbol{\theta})$ ;
190
+ end for
191
+ return $\hat{p}(\boldsymbol{\theta}|\mathbf{x}_o) = p_{R+1}(\boldsymbol{\theta})$
192
+
193
+ Algorithm 8 Iterative Ratio
194
+ $p_1(\mathbf{m}) \gets p(\mathbf{m})$ ;
195
+ for $r$ in 1 to $R$ do
196
+ repeat
197
+ sample $\mathbf{m}_i \sim p_r(\mathbf{m})$ ;
198
+ query the oracle: $s_i \gets f(\mathbf{m}_i)$ ;
199
+ until $n$ samples are obtained
200
+ $\mathcal{D} \gets \mathcal{D} \cup \{(\mathbf{m}_i, s_i)\}_{i=1}^n$ ;
201
+ construct $\tilde{\mathcal{D}}$ with $\mathbf{m}$ in $\mathcal{D}$ satisfying $\mathcal{E}$ ;
202
+ construct $\tilde{\mathcal{D}}'$ from $p(\mathbf{m})$ ;
203
+ train $d_{\phi}(\mathbf{m})$ classifying between $\tilde{\mathcal{D}}$ and $\tilde{\mathcal{D}}'$ ;
204
+ $r_{\phi}(\mathbf{m}) \gets \frac{d_{\phi}(\mathbf{m})}{1 - d_{\phi}(\mathbf{m})}$ ;
205
+ $p_{r+1}(\boldsymbol{\theta}) \propto r_{\phi}(\mathbf{m}) \cdot p(\mathbf{m})$ ;
206
+ end for
207
+ return $\{\mathbf{m} : (\mathbf{m}, s) \in \mathcal{D}\}$
208
+
209
+ Interestingly, a recent SNR-like work, EG-LF-MCMC (Begy & Schikuta, 2021), proposes to train the classifier on tuples of $(\theta ,\epsilon = \| \mathbf{x} - \mathbf{x}_o\|)$ instead of $(\theta ,\mathbf{x})$ . This algorithm can be also seen as a more precise analogy of our Iterative Ratio in the LFI context, as we have pointed out in Section 2.2 that a conceptual link could be drawn between $s$ and $-\| \mathbf{x} - \mathbf{x}_o\|$ .
210
+
211
+ # 3.4 COMPOSITE PROBABILISTIC METHODS
212
+
213
+ Building on the above analogies and framework, we move beyond the above algorithms in this subsection. The previous lines of approach – the direct posterior modeling methods in Section 3.1 and the indirect methods in Section 3.2 and 3.3 – both have their own advantages and disadvantages. The former methods may fail to get accurate inference result due to unmatched proposals, while the latter ones would need extra large amount of computation for the MCMC sampling process before obtaining accurate posterior samples, etc. Here we study composite algorithms that combine the aforementioned ingredients through the lens of our proposed unified framework. Our goal is to combine the strengths from both kinds of methods.
214
+
215
+ We first introduce Iterative Posterior Scoring (IPS) method illustrated in Algorithm 9. IPS also uses a neural network $\hat{f}_{\phi}(\mathbf{m})$ to model the forward mechanism as IS does, and again we use $\tilde{q}$ here to denote the target posterior $p(\mathbf{m}|\mathcal{E})$ . Instead of applying computational MCMC steps here, we train a second parametrized model $q_{\psi}$ to model $\tilde{q}$ by minimizing the KL divergence between them. Notice that the optimization of $q_{\psi}$ is restricted within a neural network parameterization family. As a result, in the next round, we can directly utilize $q_{\psi}(\mathbf{m})$ to serve as a flexible generative proposal of $p_{r+1}(\mathbf{m})$ . Like IS, the IPS algorithm also has two different variants with regard to different choices of $\mathcal{E}$ , we name them to be IPS-A and IPS-B. Two choices differ in the detailed construction of distribution $\tilde{q}(\mathbf{m})$ .
216
+
217
+ In a similar spirit, we propose the Iterative Posterior Ratio (IPR) algorithm (see Algorithm 10). IPR is close to the IR algorithm in many aspects, but also adopts a second neural network model $q_{\psi}(\mathbf{m})$ like IPS. IPR works similarly to IR, in that we also construct $\tilde{q} (\mathbf{m})$ , taking advantage of $r_{\phi}(\mathbf{m})$ and the prior $p(\mathbf{m})$ simply via $\tilde{q} (\mathbf{m})\gets r_{\phi}(\mathbf{m})\cdot p(\mathbf{m})$ . Note that the usage of two models in IPR is not exactly the same as in IPS: $q_{\psi}(\mathbf{m})$ is also achieved via minimizing KL divergence with $\tilde{q} (\mathbf{m})$ , but the training of model $d_{\phi}(\mathbf{m})$ is closer to that in IR rather than the $\hat{f}_{\phi}(\mathbf{m})$ in IS. Another similarity between IPR and IR is that IPR also only has one variant, since the Example B is not applicable for this ratio modeling approach (see Section A.4 in Appendix for more details).
218
+
219
+ Algorithm 9 Iterative Posterior Scoring
220
+ $p_1(\mathbf{m})\gets p(\mathbf{m})$
221
+ for $r$ in 1 to $R$ do repeat sample $\mathbf{m}_i\sim p_r(\mathbf{m})$ query the oracle: $s_i\gets f(\mathbf{m}_i)$ until $n$ samples are obtained $\mathcal{D}\leftarrow \mathcal{D}\cup \{(\mathbf{m}_i,s_i)\}_{i = 1}^n$ fit $\hat{f}_{\phi}(\mathbf{m})$ with $\mathcal{D}$ construct $\tilde{q} (\mathbf{m})$ with $\hat{f}_{\phi}(\cdot)$ and $p(\mathbf{m})$ $q_{\psi}\gets \arg \min_qD_{\mathrm{KL}}(\tilde{q} (\mathbf{m})\| q);$ $p_{r + 1}(\mathbf{m})\gets q_{\psi}(\mathbf{m})$
222
+ end for
223
+ return $\{\mathbf{m}:(\mathbf{m},s)\in \mathcal{D}\}$
224
+
225
+ Algorithm 10 Iterative Posterior Ratio
226
+ $p_1(\mathbf{m})\gets p(\mathbf{m})$
227
+ for $r$ in 1 to $R$ do repeat sample $\mathbf{m}_i\sim p_r(\mathbf{m})$ query the oracle: $s_i\gets f(\mathbf{m}_i)$ until $n$ samples are obtained $\mathcal{D}\gets \mathcal{D}\cup \{((\mathbf{m}_i,s_i)\}_{i = 1}^n$ construct $\tilde{\mathcal{D}}$ with $\mathbf{m}$ in $\mathcal{D}$ satisfying $\mathcal{E}$ construct $\tilde{\mathcal{D}}^\prime$ from $p(\mathbf{m})$ train $d_{\phi}(\mathbf{m})$ classifying between $\tilde{\mathcal{D}}$ and $\tilde{\mathcal{D}}^\prime$ $r_\phi (\mathbf{m})\leftarrow \frac{d_\phi(\mathbf{m})}{1 - d_\phi(\mathbf{m})};$ construct $\tilde{q} (\mathbf{m})$ with $r_{\phi}(\mathbf{m})$ and $p(\mathbf{m})$ $q_{\psi}\gets \arg \min_qD_{\mathrm{KL}}(\tilde{q} (\mathbf{m})\| q);$ $p_{r + 1}(\mathbf{m})\gets q_{\psi}(\mathbf{m});$
228
+ end for
229
+ return $\{\mathbf{m}:(\mathbf{m},s)\in \mathcal{D}\}$
230
+
231
+ # 4 EXPERIMENTS
232
+
233
+ # 4.1 SETUP
234
+
235
+ In this section, we systematically evaluate the proposed methods and baselines on four different in-silico biological sequence design benchmarks. In every round, we allow each algorithm to query the black-box oracle for a batch of $n$ sequences $\mathbf{m}_i$ to obtain their true scores $s_i$ , with $n = 100$ for all experiments. The total number of rounds differs across different tasks.
236
+
237
+ We experiment with our six proposed methods: Iterative Scoring (-A/B) from Section 3.2, Iterative Ratio from Section 3.3, Iterative Posterior Scoring (-A/B) and Iterative Posterior Ratio from Sec-
238
+
239
+ ![](images/bcc8c4986865f45e8fa3a1828c8e6b55fb66f6990a310679f95ed6d549fc9b91.jpg)
240
+ Figure 1: Top score (y-axis) curves of different methods on 3 TfBind problems (KLF11_R402Q_R1, PBX4_REF_R2 and CRX_E80A_R1) with regard to the number of rounds.
241
+
242
+ <table><tr><td></td><td>IS-A</td><td>IS-B</td><td>IR</td><td>IPS-A</td><td>IPS-B</td><td>IPR</td><td>RANDOM</td><td>EVOLUTION</td><td>DBAS</td><td>FB-VAE</td></tr><tr><td>TOP-10</td><td>8.43</td><td>6.93</td><td>4.79</td><td>6.21</td><td>8.36</td><td>7.00</td><td>1.14</td><td>4.36</td><td>5.07</td><td>2.71</td></tr><tr><td>TOP-100</td><td>9.57</td><td>7.93</td><td>4.07</td><td>6.71</td><td>7.64</td><td>6.00</td><td>1.00</td><td>5.50</td><td>4.57</td><td>2.00</td></tr></table>
243
+
244
+ Table 2: Mean rank of evaluated algorithms with regard to the area under the top score curve for TfBind problems. The rank ranges from 1 to 10. Higher rank is better.
245
+
246
+ tion 3.4. Apart from these proposed methods, we consider as baselines a battery of existing methods designed for batched black-box sequence design tasks: (1) Random, a method that randomly select proposal sequences at every round; (2) FB-VAE (Gupta & Zou, 2019) depicted in Section 3.1; (3) Evolution based (Brindle, 1980; Real et al., 2019) sequence design algorithm; and (4) DbAS (Brookes & Listgarten, 2018), described in Section 3.1.
247
+
248
+ We evaluate these sequence design algorithms by the average score of the top-10 and top-100 sequences in the resulting dataset $\mathcal{D}$ at each round. We plot the average score curves with regard to the number of rounds. We also use the area under the curve as a scalar metric for sample efficiency to compare the methods being evaluated. Specifically, since the area depends on the choice of x-axis, we simply cumulate the scores of all rounds to calculate the area. The result could be non-positive, since the score can take negative values.
249
+
250
+ # 4.2 RESULTS
251
+
252
+ Transcription factor binding sites (TfBind). Protein sequences that bind with DNA sequences to adjust their activity are called transcription factors. In Barrera et al. (2016), the authors measure the binding properties between a battery of transcription factors and all possible length-8 DNA sequences through biological experiments. Concretely, we choose 15 transcription factors to serve as 15 different tasks. For each transcription factor, the algorithm needs to search for sequences that maximize the corresponding binding activity score. The size of the search space is $|\mathcal{V}|^L = 4^8 = 65536$ . The number of total rounds is fixed to 10. For validation, we follow Angermüller et al. (2020b) and use one task (ZNF200_S265Y_R1) for hyperparameter selection. Then we test the algorithms' performance on the other 14 held-out tasks.
253
+
254
+ Figure 1 displays a comparison for all ten methods on three of the chosen binding affinity tasks. We can observe that after 10 rounds, our proposed methods perform consistently better than the
255
+
256
+ ![](images/647d4abdcc9b404e984fcce4c051dc2e6f3e99b2b94819a74ea4c0dfcf037d76.jpg)
257
+ Figure 2: Top score (y-axis) curves of different methods on 3 sequence design problems (left: UTR, middle: AMP, right: Fluo) with regard to the number of rounds.
258
+
259
+ <table><tr><td></td><td>IS-A</td><td>IS-B</td><td>IR</td><td>IPS-A</td><td>IPS-B</td><td>IPR</td><td>RANDOM</td><td>EVOLUTION</td><td>DBAS</td><td>FB-VAE</td></tr><tr><td>UTR</td><td>8.46</td><td>9.61</td><td>9.03</td><td>10.04</td><td>10.19</td><td>9.52</td><td>8.12</td><td>9.23</td><td>9.59</td><td>8.20</td></tr><tr><td>AMP</td><td>-5.67</td><td>-5.11</td><td>-5.37</td><td>-4.65</td><td>-4.39</td><td>-5.42</td><td>-5.96</td><td>-5.79</td><td>-5.39</td><td>-5.54</td></tr><tr><td>FLUO</td><td>32.76</td><td>33.33</td><td>32.95</td><td>44.51</td><td>43.13</td><td>42.42</td><td>31.64</td><td>35.44</td><td>41.40</td><td>32.52</td></tr></table>
260
+
261
+ Table 3: Comparison of the area under top-100 curves for UTR, AMP and Fluo benchmarks. Larger area means better sample efficiency.
262
+
263
+ backward modeling methods like DbAS and FB-VAE in terms of both Top-10 and Top-100 scores. Among all baselines, the evolution method is the strongest one, and it beats IR on some of the tasks (see complete results in Table 4 and 5 in Appendix). We also find that IS-A and IS-B increase top scores slightly faster than other methods, especially on PBX4_REF_R2 and CRX_E80A_R1. This indicates that composite methods' way of using parameterized models to replace computational procedures is not the optimal solution for small-scale tasks.
264
+
265
+ 5' untranslated regions (UTR). The translation efficiency is mainly determined by the sequence of 5' UTR (Alipanahi et al., 2015). In Sample et al. (2019), the authors create a library of gene sequences with ribosome loading level as labels. They further train a convolutional neural network with this library to predict the relationship between a 5' UTR sequence and the corresponding gene expression level. We use this neural network as an oracle for this benchmark. The length of the gene sequences is fixed to 50, and thus the size of the search space is $4^{50}$ . For this 5' UTR benchmark, we also allow each algorithm to explore for 10 rounds. Figure 2 (left) shows that our proposed composite methods significantly outperform other methods on the UTR task. Different from the results on the TfBind task, forward modeling methods do not achieve the best performance.
266
+
267
+ Antimicrobial peptides (AMP). Protein modeling has recently become a popular sub-area of machine learning research. We are tasked to generate AMP sequences, which are short protein sequences against multi-resistant pathogens. We train a binary classifier model to classify whether a short protein sequence belongs to AMP and defer the related details to Appendix. This is the only task we consider regarding sequence design with alterable lengths, where the length of sequences ranges from 12 to 60. Since each entry of protein sequence has $|\mathcal{V}| = 20$ different choices on amino acids, the size of search space is $\sum_{L=12}^{60} 20^L$ . We set the number of total rounds to be 15 for this task. Figure 2 (middle) clearly shows that the performances of IPS-A and IPS-B dominate the AMP generation task, which demonstrates the effectiveness of our composite strategy.
268
+
269
+ Fluorescence proteins (Fluo). As another protein engineering task, we consider the optimization over fluorescent proteins, which is a commonly used test bed of modern molecular biology. This task is similar to the AMP task introduced above, but its ground-truth measurement relies on a regressor. We use a pretrained model taken from Rao et al. (2019) to act as our task oracle, which is a regressor trained to predict log-fluorescence intensity value over approximately 52,000 protein sequences of length 238 (Sarkisyan et al., 2016). More concretely, the regressor is fit on a small neighborhood of parent green fluorescent protein, and is then evaluated on a more distant protein. The training data is derived from the naturally occurring GFP in Aequorea victoria. The task Fluo's search space is $20^{238}$ and we set the number of rounds to 20. We demonstrate the Fluo results in Figure 2 (right), where we can see both composite methods and DbAS achieve much better results than other approaches. This might signify that for long sequence design tasks, backward modeling is superior to other modeling methods, which is not consistent with LFI (Papamakarios et al., 2019). We also summarize the sample efficiency results for the latter 3 benchmarks in Table 3 and 6, from which we can see that our proposed three composite methods perform remarkably promising results.
270
+
271
+ # 5 CONCLUSION
272
+
273
+ We propose a probabilistic framework that unifies likelihood-free inference and black-box optimization for designing biological sequences. This unified perspective enables us to design a variety of novel composite probabilistic sequence design methods combining the best of both worlds. Extensive experiments have demonstrated the benefits of the unified perspective. While the composite probabilistic methods usually outperform other baseline methods in most sequence design tasks we consider in this work, the key contribution of our paper is not just about the superiority of those composite methods, as different specific tasks might prefer different algorithmic configurations due to no free lunch theorem (Wolpert & Macready, 1997). Actually, we would like to attribute the strong performance to the unified probabilistic framework, which enables us to develop a richer algorithm pool, based on which we can design performant algorithms for particular sequence design tasks.
274
+
275
+ # ACKNOWLEDGEMENT
276
+
277
+ The authors would like to thank Christof Angermueller, Yanzhi Chen, Michael Gutmann, and anonymous reviewers for helpful feedbacks. Jie Fu thanks Microsoft Research Montreal for funding his postdoctoral position at University of Montreal and Mila. Yoshua Bengio acknowledges the funding from CIFAR, Samsung, IBM and Microsoft. Aaron Courville thanks the support of Samsung, Hitachi and CIFAR.
278
+
279
+ # REFERENCES
280
+
281
+ Sungsoo Ahn, Junsu Kim, Hankook Lee, and Jinwoo Shin. Guiding deep molecular optimization with genetic exploration. *ArXiv*, abs/2007.04897, 2020.
282
+ Babak Alipanahi, Andrew Delong, Matthew T Weirauch, and Brendan J Frey. Predicting the sequence specificities of dna-and rna-binding proteins by deep learning. Nature biotechnology, 33 (8):831-838, 2015.
283
+ Christof Angermüller, David Belanger, Andreea Gane, Zelda E. Mariet, David Dohan, Kevin Murphy, Lucy J. Colwell, and D. Sculley. Population-based black-box optimization for biological sequence design. In ICML, 2020a.
284
+ Christof Angermüller, David Dohan, David Belanger, Ramya Deshpande, Kevin Murphy, and Lucy J. Colwell. Model-based reinforcement learning for biological sequence design. In *ICLR*, 2020b.
285
+ Luis A. Barrera, Anastasia Vedenko, Jesse V. Kurland, Julia M Rogers, Stephen S. Gisselbrecht, Elizabeth J Rossin, Jaie C. Woodard, Luca Mariani, Kian Hong Kock, Sachi Inukai, Trevor Siggers, Leila Shokri, Raluca Gordan, Nidhi Sahni, Chris Cotsapas, Tong Hao, S. Stephen Yi, Manolis Kellis, Mark J. Daly, Marc Vidal, David E. Hill, and Martha L. Bulyk. Survey of variation in human transcription factors reveals prevalent dna binding changes. Science, 351:1450 - 1454, 2016.
286
+
287
+ M. Beaumont, Wenyang Zhang, and D. Balding. Approximate bayesian computation in population genetics. Genetics, 162 4:2025-35, 2002.
288
+ M. Beaumont, J. Cornuet, J. Marin, and C. Robert. Adaptive approximate bayesian computation. Biometrika, 96:983-990, 2009.
289
+ Volodimir Begy and Erich Schikuta. Error-guided likelihood-free mcmc. 2021 International Joint Conference on Neural Networks (IJCNN), pp. 1-7, 2021.
290
+ Michael G. B. Blum. Approximate bayesian computation: A nonparametric perspective. Journal of the American Statistical Association, 105:1178 - 1187, 2009.
291
+ Johann Brehmer, Gilles Louppe, Juan Pavez, and Kyle Cranmer. Mining gold from implicit models to improve likelihood-free inference. Proceedings of the National Academy of Sciences, 117:5242 - 5249, 2020.
292
+ A. Brindle. Genetic algorithms for function optimization. 1980.
293
+ David H. Brookes and J. Listgarten. Design by adaptive sampling. ArXiv, abs/1810.03714, 2018.
294
+ David H. Brookes, Hahnbeom Park, and Jennifer Listgarten. Conditioning by adaptive sampling for robust design. In ICML, 2019.
295
+ Jeffrey Chan, Valerio Perrone, Jeffrey P. Spence, Paul A. Jenkins, Sara Mathieson, and Yun S. Song. A likelihood-free inference framework for population genetic data using exchangeable neural networks. bioRxiv, 2018.
296
+ K. Chen and F. Arnold. Enzyme engineering for nonaqueous solvents: Random mutagenesis to enhance activity of subtilisin e in polar organic media. Bio/Technology, 9:1073-1077, 1991.
297
+ Yanzhi Chen and Michael U. Gutmann. Adaptive gaussian copula abc. ArXiv, abs/1902.10704, 2019.
298
+ Yanzhi Chen, Dinghuai Zhang, M. Gutmann, Aaron C. Courville, and Zhanxing Zhu. Neural approximate sufficient statistics for implicit models. *ArXiv*, abs/2010.10079, 2021.
299
+ P. T. de Boer, Dirk P. Kroese, Shie Mannor, and Reuven Y. Rubinstein. A tutorial on the cross-entropy method. Annals of Operations Research, 134:19-67, 2005.
300
+ Christopher C. Drovandi, Clara Grazian, Kerrie L. Mengersen, and Christian P. Robert. Approximating the likelihood in approximate bayesian computation. arXiv: Computation, 2018.
301
+ Ahmed Elnaggar, Michael Heinzinger, Christian Dallago, Ghalia Rihawi, Yu Wang, Llion Jones, Tom Gibbs, Tamas Feher, Christoph Angerer, Martin Steinegger, et al. Prottrans: towards cracking the language of life's code through self-supervised deep learning and high performance computing. arXiv preprint arXiv:2007.06225, 2020.
302
+ Paul Fearnhead and Dennis Prangle. Constructing summary statistics for approximate bayesian computation: semi-automatic approximate bayesian computation (with discussion). 2012.
303
+ Rafael Gómez-Bombarelli, David Kristjanson Duvenaud, José Miguel Hernández-Lobato, Jorge Aguilera-Iparraguirre, Timothy D. Hirzel, Ryan P. Adams, and Alán Aspuru-Guzik. Automatic chemical design using a data-driven continuous representation of molecules. ACS Central Science, 4:268 - 276, 2018.
304
+ Sai Krishna Gottipati, Boris Sattarov, Sufeng Niu, Yashaswi Pathak, Haoran Wei, Shengchao Liu, Simon Blackburn, Karam Thomas, Connor Coley, Jian Tang, et al. Learning to navigate the synthetically accessible chemical space using reinforcement learning. In International Conference on Machine Learning, pp. 3668-3679. PMLR, 2020.
305
+ David S. Greenberg, M. Nonnenmacher, and J. Macke. Automatic posterior transformation for likelihood-free inference. ArXiv, abs/1905.07488, 2019.
306
+
307
+ Gabriel Lima Guimaraes, Benjamin Sánchez-Lengeling, Pedro Luis Cunha Farias, and Alán Aspuru-Guzik. Objective-reinforced generative adversarial networks (organ) for sequence generation models. ArXiv, abs/1705.10843, 2017.
308
+ Anvita Gupta and J. Zou. Feedback gan for dna optimizes protein functions. Nature Machine Intelligence, 1:105-111, 2019.
309
+ Michael U. Gutmann and Aapo Hyvarinen. Noise-contrastive estimation: A new estimation principle for unnormalized statistical models. In AISTATS, 2010.
310
+ Michael U. Gutmann, Ritabrata Dutta, Samuel Kaski, and Jukka Corander. Likelihood-free inference via classification. Statistics and Computing, 28:411 - 425, 2018.
311
+ Tatsunori B. Hashimoto, Steve Yadlowsky, and John C. Duchi. Derivative free optimization via repeated classification. In AISTATS, 2018.
312
+ J. Hermans, Volodimir Bemy, and Gilles Louppe. Likelihood-free mcmc with amortized approximate likelihood ratios. arXiv: Machine Learning, 2019.
313
+ Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. Neural Computation, 9:1735-1780, 1997.
314
+ Jp Hughes, S. Rees, SB Kalindjian, and KL Philpott. Principles of early drug discovery. British Journal of Pharmacology, 162, 2011.
315
+ Rafael Izbicki, Ann B. Lee, and Chad M. Schafer. High-dimensional density ratio estimation with extensions to approximate likelihood computation. In AISTATS, 2014.
316
+ Jan H Jensen. A graph-based genetic algorithm and generative model/monte carlo tree search for the exploration of chemical space. Chemical science, 10(12):3567-3572, 2019.
317
+ Diederik P. Kingma and M. Welling. Auto-encoding variational bayes. CoRR, abs/1312.6114, 2014.
318
+ Jian Ping Li, David J. Nott, Y. Fan, and Scott Anthony Sisson. Extending approximate bayesian computation methods to high dimensions via a gaussian copula model. Comput. Stat. Data Anal., 106:77-89, 2017.
319
+ Jarno Lintusaari, Michael U. Gutmann, Ritabrata Dutta, Samuel Kaski, and Jukka Corander. Fundamentals and recent developments in approximate bayesian computation. Systematic Biology, 66: e66 - e82, 2017.
320
+ Ge Liu, Haoyang Zeng, Jonas Mueller, Brandon Carter, Ziheng Wang, Jonas Schilz, Geraldine Horny, Michael E. Birnbaum, Stefan Ewert, and David Kenneth Gifford. Antibody complementarity determining region design using high-capacity machine learning. *bioRxiv*, 2020.
321
+ Jan-Matthis Lueckmann, Pedro J. Gonçalves, G. Bassetto, Kaan Öcal, M. Nonnenmacher, and J. Macke. Flexible statistical inference for mechanistic models of neural dynamics. In NIPS, 2017.
322
+ Jan-Matthis Lueckmann, Giacomo Bassetto, Theofanis Karaletsos, and Jakob H. Macke. Likelihood-free inference with emulator networks. ArXiv, abs/1805.09294, 2018.
323
+ Jean-Michel Marin, Pierre Pudlo, Christian P. Robert, and Robin J. Ryder. Approximate bayesian computational methods. Statistics and Computing, 22:1167-1180, 2012.
324
+ Kerrie L. Mengersen, Pierre Pudlo, and Christian P. Robert. Approximate bayesian computation via empirical likelihood. 2012.
325
+ Daniel Neil, Marwin H. S. Segler, Laura Guasch, Mohamed Ahmed, Dean Plumbley, Matthew Sellwood, and Nathan Brown. Exploring deep recurrent models with reinforcement learning for molecule design. In ICLR, 2018.
326
+ AkshitKumar Nigam, Pascal Friederich, Mario Krenn, and Alán Aspuru-Guzik. Augmenting genetic algorithms with deep neural networks for exploring the chemical space. arXiv preprint arXiv:1909.11655, 2019.
327
+
328
+ George Papamakarios and Iain Murray. Fast $\epsilon$ -free inference of simulation models with bayesian conditional density estimation. In NIPS, 2016.
329
+ George Papamakarios, Iain Murray, and Theo Pavlakou. Masked autoregressive flow for density estimation. ArXiv, abs/1705.07057, 2017.
330
+ George Papamakarios, D. Terratt, and Iain Murray. Sequential neural likelihood: Fast likelihood-free inference with autoregressive flows. In AISTATS, 2019.
331
+ Roshan Rao, Nicholas Bhattacharya, Neil Thomas, Yan Duan, Xi Chen, John Canny, Pieter Abbeel, and Yun S Song. Evaluating protein transfer learning with tape. In Advances in Neural Information Processing Systems, 2019.
332
+ Esteban Real, Alok Aggarwal, Yanping Huang, and Quoc V. Le. Regularized evolution for image classifier architecture search. In AAAI, 2019.
333
+ Reuven Y. Rubinstein and Dirk P. Kroese. The cross-entropy method. In Information Science and Statistics, 2004.
334
+ Tim Salimans, Jonathan Ho, Xi Chen, and Ilya Sutskever. Evolution strategies as a scalable alternative to reinforcement learning. *ArXiv*, abs/1703.03864, 2017.
335
+ Paul Sample, Ban Wang, David W. Reid, Vladimir Presnyak, Iain J Mcfadyen, David R. Morris, and Georg Seelig. Human 5utr design and variant effect prediction from a massively parallel translation assay. Nature Biotechnology, 37:803-809, 2019.
336
+ Karen S Sarkisyan, Dmitry A Bolotin, Margarita V Meer, Dinara R Usmanova, Alexander S Mishin, George V Sharonov, Dmitry N Ivankov, Nina G Bozhanova, Mikhail S Baranov, Onuralp Soylemez, et al. Local fitness landscape of the green fluorescent protein. Nature, 533(7603):397-401, 2016.
337
+ Bobak Shahriari, Kevin Swersky, Ziyun Wang, Ryan P. Adams, and Nando de Freitas. Taking the human out of the loop: A review of bayesian optimization. Proceedings of the IEEE, 104:148-175, 2016.
338
+ Chence Shi, Minkai Xu, Zhaocheng Zhu, Weinan Zhang, Ming Zhang, and Jian Tang. Graphaf: a flow-based autoregressive model for molecular graph generation. ArXiv, abs/2001.09382, 2020.
339
+ Nitish Srivastava, Geoffrey E. Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. Dropout: a simple way to prevent neural networks from overfitting. J. Mach. Learn. Res., 15: 1929-1958, 2014.
340
+ Owen Thomas, Ritabrata Dutta, Jukka Corander, Samuel Kaski, and Michael U. Gutmann. Likelihood-free inference by ratio estimation. arXiv: Machine Learning, 2016.
341
+ Minh-Ngoc Tran, David J. Nott, and Robert Kohn. Variational bayes with intractable likelihood. Journal of Computational and Graphical Statistics, 26:873 - 882, 2015.
342
+ Laurens van der Maaten and Geoffrey E. Hinton. Visualizing data using t-sne. Journal of Machine Learning Research, 9:2579-2605, 2008.
343
+ Daan Wierstra, Tom Schaul, Jan Peters, and Juergen Schmidhuber. Natural evolution strategies. 2008 IEEE Congress on Evolutionary Computation (IEEE World Congress on Computational Intelligence), pp. 3381-3387, 2008.
344
+ Jacob Witten and Zack Witten. Deep learning regression model for antimicrobial peptide design. BioRxiv, pp. 692681, 2019.
345
+ David H. Wolpert and William G. Macready. No free lunch theorems for optimization. IEEE Trans. Evol. Comput., 1:67-82, 1997.
346
+ Simon N. Wood. Statistical inference for noisy nonlinear ecological dynamic systems. Nature, 466: 1102-1104, 2010.
347
+
348
+ Zachary Wu, S B Jennifer Kan, Russell D Lewis, Bruce J. Wittmann, and Frances H. Arnold. Machine learning-assisted directed protein evolution with combinatorial libraries. Proceedings of the National Academy of Sciences, 116:8852 - 8858, 2019.
349
+ Kevin K. Yang, Zachary Wu, and Frances H. Arnold. Machine-learning-guided directed evolution for protein engineering. Nature Methods, pp. 1-8, 2019.
350
+ Naruki Yoshikawa, Kei Terayama, Masato Sumita, Teruki Homma, Kenta Oono, and Koji Tsuda. Population-based de novo molecule generation, using grammatical evolution. Chemistry Letters, 47(11):1431-1434, 2018.
351
+ Zhenpeng Zhou, Steven M. Kearnes, Li Li, Richard N. Zare, and Patrick F. Riley. Optimization of molecules via deep reinforcement learning. *Scientific Reports*, 9, 2019.
352
+
353
+ # A MORE ABOUT METHODOLOGY
354
+
355
+ # A.1 BACKWARD MODELING OF THE MECHANISM
356
+
357
+ About SMC-ABC. In Algorithm 1, when we pick the top- $m$ $\theta$ at the $r$ -th round, the picked parameters actually follow such a distribution
358
+
359
+ $$
360
+ p (\boldsymbol {\theta} \mid \boldsymbol {x} _ {o}) \propto \sum_ {l = 1} ^ {r} p _ {l} (\boldsymbol {\theta}) \cdot p (\| \boldsymbol {x} - \boldsymbol {x} _ {o} \| < \epsilon \mid \boldsymbol {\theta}) = \left(\sum_ {l = 1} ^ {r} p _ {l} (\boldsymbol {\theta})\right) \cdot p (\| \boldsymbol {x} - \boldsymbol {x} _ {o} \| < \epsilon \mid \boldsymbol {\theta}) \tag {5}
361
+ $$
362
+
363
+ where the $\epsilon$ here is implicitly defined by how "top" the selection process is, namely the ratio $\frac{m}{nr}$ . As a result, we point out that in Algorithm 1, another more complicated form of the last step $p_{r+1}(\pmb{\theta}) \gets q_{\phi}(\pmb{\theta})$ is $p_{r+1}(\pmb{\theta}) \propto q_{\phi}(\pmb{\theta}) p(\pmb{\theta}) / \sum_{l}^{r} p_{l}(\pmb{\theta})$ , where an additional renormalizing term is involved. We ignore this term and used the simpler alternative in order to keep our main text clean. We refer interested readers to Beaumont et al. (2009) for more details.
364
+
365
+ About Sequential Neural Posterior. Define $p(\mathbf{x}) = \int p(\mathbf{x}|\pmb{\theta})p(\pmb{\theta})d\pmb{\theta}$ and $\tilde{p} (\mathbf{x}) = \int p(\mathbf{x}|\pmb {\theta})\tilde{p} (\pmb {\theta})d\pmb{\theta}$ for any arbitrary proposal distribution $\tilde{p} (\pmb {\theta})$ which is not necessary to be the prior $p(\pmb {\theta})$ . What's more, we define $p(\pmb {\theta}|\mathbf{x}) = p(\mathbf{x}|\pmb {\theta})p(\pmb {\theta}) / p(\mathbf{x})$ and $\tilde{p} (\pmb {\theta}|\mathbf{x}) = p(\mathbf{x}|\pmb {\theta})\tilde{p} (\pmb {\theta}) / \tilde{p} (\mathbf{x})$ to be the true posterior and the proposal posterior.
366
+
367
+ Starting from the goal of approximating the true posterior,
368
+
369
+ $$
370
+ \begin{array}{l} \underset {q} {\arg \min } \mathbb {E} _ {p (\mathbf {x})} [ D _ {\mathrm {K L}} (p (\boldsymbol {\theta} | \mathbf {x}) \| q (\boldsymbol {\theta} | \mathbf {x})) ] = \underset {q} {\arg \max } \int p (\mathbf {x}) d \mathbf {x} \int p (\boldsymbol {\theta} | \mathbf {x}) \log q (\boldsymbol {\theta} | \mathbf {x}) d \boldsymbol {\theta} \\ = \arg \max _ {q} \int p (\boldsymbol {\theta}, \mathbf {x}) \log q (\boldsymbol {\theta} | \mathbf {x}) d \boldsymbol {\theta} \mathbf {x} \\ = \underset {q} {\arg \max} \mathbb {E} _ {p (\boldsymbol {\theta}, \mathbf {x})} [ \log q (\boldsymbol {\theta} | \mathbf {x}) ]. \\ \end{array}
371
+ $$
372
+
373
+ It seems that we can directly train the parameterized neural density estimator $q_{\phi}$ in a data driven manner via $\max_{\phi}\sum_{i}\log q_{\phi}(\pmb{\theta}_{i}|\mathbf{x}_{i})$ where $i$ is the index for data sample. When the number of training samples as well as the parameterization family of $\phi$ are large enough, the obtained $q_{\phi}$ would be close enough to the true posterior. This would require the data samples to follow $(\pmb{\theta}_i,\mathbf{x}_i)\sim p(\pmb {\theta},\mathbf{x}) = p(\pmb {\theta})p(\mathbf{x}|\pmb {\theta})$ . However, practically one uses a proposal $\tilde{p} (\pmb {\theta})$ to first generate some $\{\pmb {\theta}_i\}_i$ and then generate $\{\mathbf{x}_i\}_i$ by simulation. When the proposal distribution $\tilde{p} (\pmb {\theta})$ is not exactly the prior distribution $p(\pmb {\theta})$ , the resulting $q_{\phi}(\cdot |\cdot)$ would be:
374
+
375
+ $$
376
+ \tilde {p} (\boldsymbol {\theta} | \mathbf {x}) = p (\boldsymbol {\theta} | \mathbf {x}) \frac {\tilde {p} (\boldsymbol {\theta}) p (\mathbf {x})}{p (\boldsymbol {\theta}) \tilde {p} (\mathbf {x})} \propto p (\boldsymbol {\theta} | \mathbf {x}) \frac {\tilde {p} (\boldsymbol {\theta})}{p (\boldsymbol {\theta})}, \tag {6}
377
+ $$
378
+
379
+ which is a biased estimation and is not what we want.
380
+
381
+ Three variants of SNP take different approaches to try to fix this bias. SNP-A (Papamakarios & Murray, 2016) first fits the biased proposal posterior $\tilde{p}(\boldsymbol{\theta}|\mathbf{x})$ in the aforementioned way and utilize the relation in Eq. 6 to solve for an unbiased estimation. This approach is restricted to a mixture of Gaussian distribution family and thus has limited expressiveness. SNP-B (Lueckmann et al., 2017) uses importance sampling to address this issue via $\max_{\boldsymbol{\phi}} \mathbb{E}_{(\mathbf{x},\boldsymbol{\theta}) \sim p(\mathbf{x}|\boldsymbol{\theta})\tilde{p}(\boldsymbol{\theta})}\left[\frac{p(\boldsymbol{\theta})}{\tilde{p}(\boldsymbol{\theta})}\log q_{\boldsymbol{\phi}}(\boldsymbol{\theta}|\mathbf{x})\right]$ . One downside of this approach is the high variance involved by the importance weights $p(\boldsymbol{\theta}) / \tilde{p}(\boldsymbol{\theta})$ . SNP-C (Greenberg et al., 2019) proposes to use reparameterize the proposal posterior by setting $\tilde{q}_{\boldsymbol{\phi}}(\boldsymbol{\theta}|\mathbf{x}) = q_{\boldsymbol{\phi}}(\boldsymbol{\theta}|\mathbf{x})\frac{\tilde{p}(\boldsymbol{\theta})}{p(\boldsymbol{\theta})}\frac{1}{Z_{\boldsymbol{\phi}}(\mathbf{x})}$ where $Z_{\boldsymbol{\phi}}(\mathbf{x}) = \int q_{\boldsymbol{\phi}}(\boldsymbol{\theta}|\mathbf{x})\frac{\tilde{p}(\boldsymbol{\theta})}{p(\boldsymbol{\theta})}d\boldsymbol{\theta}$ is the corresponding normalizing factor for $\mathbf{x}$ . SNP-C then maximizes $\mathbb{E}_{(\mathbf{x},\boldsymbol{\theta}) \sim p(\mathbf{x}|\boldsymbol{\theta})\tilde{p}(\boldsymbol{\theta})}\left[\log \tilde{q}_{\boldsymbol{\phi}}(\boldsymbol{\theta}|\mathbf{x})\right]$ .
382
+
383
+ About Design by Adaptive Sampling. We aim to approximate the posterior via minimizing the KL divergence:
384
+
385
+ $$
386
+ \begin{array}{l} \arg \min _ {q} D _ {\mathrm {K L}} (p (\mathbf {m} | \mathcal {E}) \| q (\mathbf {m})) = \arg \max _ {q} \int p (\mathbf {m} | \mathcal {E}) \log q (\mathbf {m}) d \mathbf {m} \\ = \arg \max _ {q} \int p (\mathcal {E} | \mathbf {m}) p (\mathbf {m}) \log q (\mathbf {m}) d \mathbf {m} \\ = \arg \max _ {q} \mathbb {E} _ {\tilde {q} (\mathbf {m})} \left[ \frac {p (\mathbf {m})}{\tilde {q} (\mathbf {m})} p (\mathcal {E} | \mathbf {m}) \log q (\mathbf {m}) \right], \\ \end{array}
387
+ $$
388
+
389
+ where $\tilde{q} (\mathbf{m})$ could be any distribution of $\mathbf{m}$ . Brookes et al. (2019) takes this formulation. Brookes & Listgarten (2018) only differs in the place that it ignores the denominator term. According to Angermuller et al. (2020b), we choose the latter variant as one of our baselines because it is more stable in practice. We refer interested readers to Brookes & Listgarten (2018) for more details.
390
+
391
+ Notice that we are not doing exactly the same things for LFI and black-box sequence design. Since LFI models flexible posterior $p(\theta | \mathbf{x})$ which is a distribution for arbitrary $\mathbf{x}$ , we can also choose to model $p(\mathbf{m}|s)$ for arbitrary $s$ . Nevertheless, in the neural network modeling, conditioning by a scalar value is not an effective approach as the effect of low dimensional scalar value conditioning may be covered by other high dimensional input. Therefore, we choose to directly model the target posterior $p(\mathbf{m}|\mathcal{E})$ with a single neural network.
392
+
393
+ # A.2 FORWARD MODELING OF THE MECHANISM
394
+
395
+ We still use $\tilde{p}(\boldsymbol{\theta})$ to denote an arbitrary proposal distribution and $\tilde{p}(\boldsymbol{\theta}, \mathbf{x}) := p(\mathbf{x} | \boldsymbol{\theta}) \tilde{p}(\boldsymbol{\theta})$ . Then we have
396
+
397
+ $$
398
+ \begin{array}{l} \arg \min _ {q} \mathbb {E} _ {\tilde {p} (\boldsymbol {\theta})} \left[ D _ {\mathrm {K L}} \left(p (\mathbf {x} | \boldsymbol {\theta}) \| q (\mathbf {x} | \boldsymbol {\theta})\right) \right] = \arg \max _ {q} \int \tilde {p} (\boldsymbol {\theta}) d \boldsymbol {\theta} \int p (\mathbf {x} | \boldsymbol {\theta}) \log q (\mathbf {x} | \boldsymbol {\theta}) d \mathbf {x} \\ = \operatorname * {a r g m a x} _ {q} \mathbb {E} _ {\tilde {p} (\boldsymbol {\theta}, \mathbf {x})} \left[ \log q (\mathbf {x} | \boldsymbol {\theta}) \right]. \\ \end{array}
399
+ $$
400
+
401
+ We point out that with much enough data and large enough expressiveness of the neural density estimator parameterization family, no matter what proposal $\tilde{p}(\boldsymbol{\theta})$ is used to provide training samples $\{(\boldsymbol{\theta}_i, \mathbf{x}_i)\}_{i} \sim \tilde{p}(\boldsymbol{\theta}, \mathbf{x})$ , we have the resulting $q_{\hat{\phi}}(\boldsymbol{\theta}|\mathbf{x})$ equals true likelihood $p(\mathbf{x}|\boldsymbol{\theta})$ in the support of the proposal. What SNL gives is an unbiased estimation and thus does not have the same problem as SNP.
402
+
403
+ Now we elaborate the construction of $\tilde{q}(\mathbf{m})$ in Iterative Scoring algorithm. Here we use the notation $\tilde{q}(\mathbf{m})$ to denote our approximation of the posterior $p(\mathbf{m}|\mathcal{E})$ . Notice that we want $\tilde{q}(\mathbf{m}) \propto p(\mathbf{m}) \cdot p(\mathcal{E}|\mathbf{m})$ . If we choose Example A to serve as the definition of event $\mathcal{E}$ , then the samples of $\tilde{q}(\mathbf{m})$ can be obtained in this way: (1) sample $\mathbf{m}$ from prior $p(\mathbf{m})$ and (2) accept this sample if $\hat{f}_{\phi}(\mathbf{m})$ is larger than threshold $s$ , or otherwise reject it. Alternatively, if we choose Example B, we have $\tilde{q}(\mathbf{m}) \propto p(\mathbf{m}) \cdot \exp(\hat{f}_{\phi}(\mathbf{m}) / \tau)$ . Similar to SNL, we do MCMC sampling from this unnormalized probability function.
404
+
405
+ # A.3 MODELING A PROBABILITY RATIO
406
+
407
+ About Sequential Neural Ratio. Dataset $\mathcal{D}$ is generated in the way that (1) first sample $\pmb{\theta} \sim p(\pmb{\theta})$ and (2) simulate $\mathbf{x} \sim p(\mathbf{x}|\pmb{\theta})$ . Consequently, $\mathcal{D}$ follows the distribution $p(\pmb{\theta})p(\mathbf{x}|\pmb{\theta}) = p(\pmb{\theta},\mathbf{x})$ . On the other hand, the other dataset $\mathcal{D}'$ generates $\pmb{\theta}$ and $\mathbf{x}$ in parallel and independent manner. Notice here $\pmb{\theta} \sim p(\pmb{\theta})$ and $\mathbf{x}$ follows the marginal distribution: $\mathbf{x} \sim p(\mathbf{x}) = \int p(\pmb{\theta})p(\mathbf{x}|\pmb{\theta})d\pmb{\theta}$ .
408
+
409
+ # Proof of Proposition 1.
410
+
411
+ Proof. We define a functional $\mathcal{F}$ to be the optimization objective:
412
+
413
+ $$
414
+ \mathcal {F} [ d ] = \mathbb {E} _ {\mathbf {a} \sim p _ {0} (\mathbf {a})} [ \log d (\mathbf {a}) ] + \mathbb {E} _ {\mathbf {a} \sim p _ {1} (\mathbf {a})} [ \log (1 - d (\mathbf {a})) ]
415
+ $$
416
+
417
+ We calculate its functional derivative. For arbitrary function $u$ and infinite small $\epsilon$
418
+
419
+ $$
420
+ \begin{array}{l} \mathcal {F} [ d + \epsilon u ] - \mathcal {F} [ d ] = \mathbb {E} _ {p _ {0}} \left[ \log \left(1 + \epsilon \frac {u}{d}\right) \right] + \mathbb {E} _ {p _ {1}} \left[ \log \left(1 + \epsilon \frac {- u}{1 - d}\right) \right] \\ = \epsilon \int u \cdot \left(\frac {p _ {0}}{d} + \frac {- p _ {1}}{1 - d}\right) + \mathcal {O} (\epsilon) \\ \Rightarrow \lim _ {\epsilon \rightarrow 0} \frac {\mathcal {F} [ d + \epsilon u ] - \mathcal {F} [ d ]}{\epsilon} = \int u \cdot \left(\frac {p _ {0}}{d} + \frac {- p _ {1}}{1 - d}\right) = \int u \cdot \delta \mathcal {F}. \\ \end{array}
421
+ $$
422
+
423
+ We set the functional derivative to zero:
424
+
425
+ $$
426
+ \begin{array}{l} \delta \mathcal {F} = 0 \Rightarrow \frac {p _ {0}}{p _ {1}} = \frac {d}{1 - d} \\ \Rightarrow d (\mathbf {a}) = \frac {p _ {0} (\mathbf {a})}{p _ {0} (\mathbf {a}) + p _ {1} (\mathbf {a})}. \\ \end{array}
427
+ $$
428
+
429
+ This optimal function $d^{*}$ apparently takes value in $[0,1]$ .
430
+
431
+ ![](images/c84969772229d9b90e61a709ac63d0db9e3f80b91664b27407678fe2b41eca17.jpg)
432
+
433
+ About Iterative Ratio. Notice that in Algorithm 8 we construct two datasets: $\tilde{\mathcal{D}}$ and $\tilde{\mathcal{D}}'$ . To generate $\tilde{\mathcal{D}}$ , we need to be able to pick some sequence samples $\mathbf{m}$ from $\mathcal{D}$ and make the selected ones follow the posterior $p(\mathbf{m}|\mathcal{E})$ . This procedure will depend on our choice of event $\mathcal{E}$ . For Example A this is easy, since we just need to filter out the sequences whose oracle value is smaller than the threshold. However, for Example B, it is hard to do similar things, since given score value from $\mathcal{D}$ we only know the unnormalized value of posterior probability, and cannot determine which sequence should be filtered out. The construction of $\tilde{\mathcal{D}}'$ which follows prior distribution $p(\mathbf{m})$ is trivial.
434
+
435
+ # A.4 COMPOSITE PROBABILISTIC METHODS
436
+
437
+ For IPS, the optimization with regard to the second parameterized model $q_{\psi}(\mathbf{m})$ is
438
+
439
+ $$
440
+ \begin{array}{l} q _ {\psi} = \underset {q} {\arg \min } D _ {\mathrm {K L}} (\tilde {q} (\mathbf {m}) \| q) = \underset {q} {\arg \max } \int \tilde {q} (\mathbf {m}) \log q (\mathbf {m}) d \mathbf {m} \\ = \arg \max _ {q} \int p (\mathbf {m} | \mathcal {E}) \log q (\mathbf {m}) d \mathbf {m} = \arg \max _ {q} \int p (\mathcal {E} | \mathbf {m}) p (\mathbf {m}) \log q (\mathbf {m}) d \mathbf {m}. \\ \end{array}
441
+ $$
442
+
443
+ The exact value of $p(\mathcal{E}|\mathbf{m})$ depends on different choices of configuration feature $\mathcal{E}$ in Section 2.2. On the other hand, IPR, like IR, also only has one variant, which is with Example A:
444
+
445
+ $$
446
+ q _ {\psi} = \underset {q} {\arg \min} D _ {\mathrm {K L}} (\tilde {q} ({\bf m}) \| q) = \underset {q} {\arg \max} \int r _ {\phi} ({\bf m}) p ({\bf m}) \log q ({\bf m}) d {\bf m},
447
+ $$
448
+
449
+ which is a tractable optimization problem. Both IPR and IR are not fit for Example B since it cannot provide an exact probability value and thus cannot be adopted to construct $\tilde{\mathcal{D}}$ .
450
+
451
+ # B MORE ABOUT EXPERIMENTS
452
+
453
+ Random method uses no neural network model. FB-VAE uses a VAE model. The encoder of the VAE first linearly transform one-hot input into a hidden feature which is 64 dimension, and then separately linearly transform to a 64-dimension mean output and 64-dimension variance output. The decoder contains a $64 \times 64$ linear layer and a linear layer that maps the hidden feature to categorical output. All other methods utilize bi-directional long short-term memory model (BiLSTM) (Hochreiter & Schmidhuber, 1997) with a linear embedding layer. Both the embedding dimension and the hidden size of LSTM is set to 32. For composite methods that use two models, we use one-layer LSTM for each of them. For the other algorithms that only use one LSTM, we set its number of
454
+
455
+ ![](images/4577801813f5178080ade68865d5547ca30d25af0d618e378e147921a2a4194f.jpg)
456
+ Figure 3: Diversity visualization results for two TfBind tasks.
457
+
458
+ <table><tr><td></td><td>IS-A</td><td>IS-B</td><td>IR</td><td>IPS-A</td><td>IPS-B</td><td>IPR</td><td>RANDOM</td><td>EVO.</td><td>DBAS</td><td>FB-VAE</td></tr><tr><td>POU6F2_REF_R1</td><td>9</td><td>7</td><td>3</td><td>5</td><td>10</td><td>8</td><td>1</td><td>4</td><td>6</td><td>2</td></tr><tr><td>KLF11_R402Q_R1</td><td>8</td><td>6</td><td>5</td><td>7</td><td>9</td><td>10</td><td>1</td><td>4</td><td>2</td><td>3</td></tr><tr><td>EGR2_R359W_R1</td><td>4</td><td>5</td><td>8</td><td>9</td><td>7</td><td>6</td><td>1</td><td>2</td><td>10</td><td>3</td></tr><tr><td>HOXD13_S316C_R1</td><td>8</td><td>10</td><td>3</td><td>4</td><td>7</td><td>9</td><td>1</td><td>5</td><td>6</td><td>2</td></tr><tr><td>HOXB7_K191R_R1</td><td>10</td><td>8</td><td>6</td><td>4</td><td>9</td><td>3</td><td>1</td><td>5</td><td>7</td><td>2</td></tr><tr><td>PBX4_REF_R2</td><td>10</td><td>9</td><td>8</td><td>7</td><td>5</td><td>4</td><td>1</td><td>6</td><td>2</td><td>3</td></tr><tr><td>GFI1B_A204T_R1</td><td>8</td><td>7</td><td>3</td><td>4</td><td>9</td><td>10</td><td>1</td><td>6</td><td>5</td><td>2</td></tr><tr><td>FOXC1_REF_R1</td><td>10</td><td>8</td><td>3</td><td>5</td><td>7</td><td>9</td><td>1</td><td>4</td><td>6</td><td>2</td></tr><tr><td>KLF1_REF_R1</td><td>6</td><td>4</td><td>7</td><td>9</td><td>8</td><td>10</td><td>3</td><td>1</td><td>2</td><td>5</td></tr><tr><td>SIX6_REF_R1</td><td>8</td><td>7</td><td>3</td><td>10</td><td>9</td><td>6</td><td>1</td><td>5</td><td>2</td><td>4</td></tr><tr><td>ARX_L343Q_R2</td><td>10</td><td>3</td><td>4</td><td>7</td><td>9</td><td>5</td><td>1</td><td>6</td><td>8</td><td>2</td></tr><tr><td>CRX_E80A_R1</td><td>9</td><td>10</td><td>7</td><td>5</td><td>8</td><td>2</td><td>1</td><td>6</td><td>3</td><td>4</td></tr><tr><td>ESX1_K193R_R1</td><td>9</td><td>6</td><td>3</td><td>5</td><td>10</td><td>8</td><td>1</td><td>4</td><td>7</td><td>2</td></tr><tr><td>VSX1_G160D_R1</td><td>9</td><td>7</td><td>4</td><td>6</td><td>10</td><td>8</td><td>1</td><td>3</td><td>5</td><td>2</td></tr><tr><td>AVERAGE</td><td>8.43</td><td>6.93</td><td>4.79</td><td>6.21</td><td>8.36</td><td>7.00</td><td>1.14</td><td>4.36</td><td>5.07</td><td>2.71</td></tr></table>
459
+
460
+ Table 4: Top-10 score ranking for the TfBind instances that we adopt. "Evo." stands for the evolution algorithm.
461
+
462
+ layers to be two. No Dropout (Srivastava et al., 2014) is used in LSTM models. In this way, the number of parameters of the VAE is slightly larger than that of the two layer BiLSTM, and all methods (except Random) share similar model parameter size.
463
+
464
+ All the experiments are repeated with fifty random seeds and report the mean value (and also standard deviation in the figure plots). We set $p(\mathbf{m})$ to be uniform prior for all tasks for simplicity, which uniformly samples from the dictionary $\mathcal{V}$ for each entry of the sequence. For length alterable task, we first uniformly sample the length between minimum length and maximum length and then sample each entry.
465
+
466
+ We explain details about evolution based method mentioned in the main text, which can be seen as a substantial example of directed evolution (Chen & Arnold, 1991). Like other model based methods, Evolution also trains an LSTM regressor to predict the score of a sequence, which is further used to assist in the reproduce procedure. The Evolution algorithm maintains a generation list through the whole exploration process. In each round, the method mutates and reproduces the sequences to enlarge the generation list, and then utilizes the learned regressor to select top sequences for the next generation.
467
+
468
+ For validation, we follow (Angermüller et al., 2020b) and sweep each algorithm for fifty trials and pick the best configuration. We tune learning rate and whether to re-initialize the optimizer for each new round for all methods. We tune threshold for DbAS, FB-VAE and the methods that is with Example A. For the other choice of $\mathcal{E}$ , we tune the temperature. For evolution, we tune the number of offsprings for each sequence in generation list, the probability of substitution, insertion and deletion. For TfBind we use ZNF200_S265Y_R1 for validation. For UTR, AMP and Fluo, since we only have one oracle instance for each benchmark, we do not use a hold-out validation method.
469
+
470
+ <table><tr><td></td><td>IS-A</td><td>IS-B</td><td>IR</td><td>IPS-A</td><td>IPS-B</td><td>IPR</td><td>RANDOM</td><td>EVO.</td><td>DBAS</td><td>FB-VAE</td></tr><tr><td>POU6F2_REF_R1</td><td>10</td><td>8</td><td>3</td><td>5</td><td>9</td><td>6</td><td>1</td><td>7</td><td>4</td><td>2</td></tr><tr><td>KLF11_R402Q_R1</td><td>10</td><td>7</td><td>4</td><td>8</td><td>9</td><td>6</td><td>1</td><td>5</td><td>3</td><td>2</td></tr><tr><td>EGR2_R359W_R1</td><td>7</td><td>8</td><td>4</td><td>10</td><td>5</td><td>9</td><td>1</td><td>3</td><td>6</td><td>2</td></tr><tr><td>HOXD13_S316C_R1</td><td>10</td><td>9</td><td>3</td><td>4</td><td>7</td><td>6</td><td>1</td><td>5</td><td>8</td><td>2</td></tr><tr><td>HOXB7_K191R_R1</td><td>10</td><td>9</td><td>3</td><td>6</td><td>8</td><td>4</td><td>1</td><td>5</td><td>7</td><td>2</td></tr><tr><td>PBX4_REF_R2</td><td>10</td><td>9</td><td>7</td><td>5</td><td>6</td><td>4</td><td>1</td><td>8</td><td>3</td><td>2</td></tr><tr><td>GFI1B_A204T_R1</td><td>10</td><td>7</td><td>4</td><td>5</td><td>9</td><td>6</td><td>1</td><td>8</td><td>3</td><td>2</td></tr><tr><td>FOXC1_REF_R1</td><td>10</td><td>7</td><td>4</td><td>8</td><td>6</td><td>9</td><td>1</td><td>5</td><td>3</td><td>2</td></tr><tr><td>KLF1_REF_R1</td><td>8</td><td>6</td><td>5</td><td>9</td><td>7</td><td>10</td><td>1</td><td>4</td><td>3</td><td>2</td></tr><tr><td>SIX6_REF_R1</td><td>9</td><td>7</td><td>5</td><td>10</td><td>8</td><td>4</td><td>1</td><td>6</td><td>3</td><td>2</td></tr><tr><td>ARX_L343Q_R2</td><td>10</td><td>7</td><td>4</td><td>8</td><td>9</td><td>3</td><td>1</td><td>6</td><td>5</td><td>2</td></tr><tr><td>CRX_E80A_R1</td><td>10</td><td>9</td><td>5</td><td>7</td><td>8</td><td>4</td><td>1</td><td>6</td><td>3</td><td>2</td></tr><tr><td>ESX1_K193R_R1</td><td>10</td><td>9</td><td>3</td><td>4</td><td>8</td><td>6</td><td>1</td><td>5</td><td>7</td><td>2</td></tr><tr><td>VSX1_G160D_R1</td><td>10</td><td>9</td><td>3</td><td>5</td><td>8</td><td>7</td><td>1</td><td>4</td><td>6</td><td>2</td></tr><tr><td>AVERAGE</td><td>9.57</td><td>7.93</td><td>4.07</td><td>6.71</td><td>7.64</td><td>6.00</td><td>1.00</td><td>5.50</td><td>4.57</td><td>2.00</td></tr></table>
471
+
472
+ Table 5: Top-100 score ranking for the TfBind instances that we adopt. "Evo." stands for the evolution algorithm.
473
+
474
+ <table><tr><td></td><td>IS-A</td><td>IS-B</td><td>IR</td><td>IPS-A</td><td>IPS-B</td><td>IPR</td><td>RANDOM</td><td>EVOLUTION</td><td>DBAS</td><td>FB-VAE</td></tr><tr><td>UTR</td><td>10.87</td><td>11.71</td><td>11.43</td><td>12.06</td><td>12.15</td><td>11.94</td><td>10.60</td><td>11.20</td><td>11.89</td><td>10.65</td></tr><tr><td>AMP</td><td>-2.98</td><td>-2.67</td><td>-2.84</td><td>-2.54</td><td>-2.16</td><td>-2.74</td><td>-3.36</td><td>-3.09</td><td>-2.73</td><td>-2.80</td></tr><tr><td>FLUO</td><td>35.31</td><td>35.82</td><td>35.59</td><td>46.19</td><td>44.28</td><td>43.88</td><td>34.33</td><td>37.40</td><td>43.45</td><td>34.78</td></tr></table>
475
+
476
+ Table 6: Comparison of the area under top-10 curves for UTR, AMP and Fluo benchmarks. Larger area means better sample efficiency.
477
+
478
+ For TfBind benchmark, we use the following transcription factor instances and treat them as different black-box optimization tasks: ZNF200_S265Y_R1, POU6F2_REF_R1_8, KLF11_R402Q_R1, EGR2_R359W_R1, HOXD13_S316C_R1, HOXB7_K191R_R1, PBX4_REF_R2, GFI1B_A204T_R1, FOXC1_REF_R1, KLF1_REF_R1, SIX6_REF_R1, ARX_L343Q_R2, CRX_E80A_R1, ESX1_K193R_R1 and VSX1_G160D_R1. We do not do post-processing such as score normalization whitening for the data for simplicity. We first calculate the area under curve to summarize the performance in a scalar output, and put the ranking result for each algorithm in Table 4 and Table 5, which provide more details for Table 2. To further investigate the diversity of different algorithms, we choose two TfBind instances (POU6F2_REF_R1 and KLF11_R402Q_R1) and visualize the resulting sequences with T-SNE (van der Maaten & Hinton, 2008) in Figure 3. We provide two visualization views for both task instances: (1) we uniformly sample 20 sequences from the whole $n \cdot R$ sequences for each algorithm and visualize them; (2) for each algorithm, we visualize 20 sequences uniformly sampled from the last batch (i.e., at the last round). This is notated with "final sequences" in the figure. We do not visualize all the sequences for simplicity. We use Hamming distance in the computation of T-SNE. From Figure 3, we can see that there is no obvious difference for the evaluated methods. This indicates that our proposed methods can achieve better performance while maintaining on-par diversity level with the baselines. This is not exactly consistent to the findings of Angermüller et al. (2020a), which claims some algorithms such as DbAS achieve very limited diversity. We do not use the "optima fraction" metric in Angermüller et al. (2020a;b), since this metric may not deal with multimode oracle landscape well and needs extra unstable computation such as clustering. Besides, this metric cannot generalize to other benchmarks.
479
+
480
+ We elaborate the construction of our AMP oracle. We use the AMP dataset from (Witten & Witten, 2019) which contains 6,760 AMP sequences. A multilayer perceptron classifier is trained to predict if a protein sequence can prohibit the growth of a particular pathogen in that AMP dataset. This classifier operates on the features extracted by ProtAlbert (Elnaggar et al., 2020) model. Following the setup in (Angermüller et al., 2020b), we treat the predicted logits as the ground-truth measurement. Moreover, we demonstrate the area under Top-10 curves for UTR, AMP and Fluo benchmarks in Table 6, which is a good complement for Table 3 but is missing due to limited space in the main text.
481
+
482
+ # C RELATED WORKS AND DISCUSSION
483
+
484
+ Likelihood-free inference. We have already introduced the main classes of likelihood-free inference algorithms in the main text: (1) Approximate Bayesian Computation (ABC) method (Beaumont et al., 2009; Blum, 2009; Marin et al., 2012; Lintusaari et al., 2017) in Section 3.1; (2) Posterior modeling method that is also stated in Section 3.1, including classical ones (Tran et al., 2015; Li et al., 2017; Chen & Gutmann, 2019) and modern SNP methods (Papamakarios & Murray, 2016; Lueckmann et al., 2017; Greenberg et al., 2019); (3) Likelihood modeling method described in Section 3.2, also containing various classical algorithms (Wood, 2010; Mengersen et al., 2012; Drovandi et al., 2018) and modern SNL variants (Lueckmann et al., 2018; Papamakarios et al., 2019); and (4) Probability ratio modeling methods mentioned in Section 3.3 diverge in estimating likelihood ratio (Gutmann & Hyvarinen, 2010; Gutmann et al., 2018; Brehmer et al., 2020) or likelihood-to-evidence ratio (Thomas et al., 2016; Izbicki et al., 2014), where the latter paradigm is a good fit for LFI problem (Hermans et al., 2019). Besides, there are also works about how to construct low-dimensional summary statistics for LFI (Fearnhead & Prangle, 2012; Chan et al., 2018; Chen et al., 2021).
485
+
486
+ Machine learning based drug design. Generative modeling and discriminative modeling are two basic ways of thinking in machine learning. In literature for sequence design, generative modeling is also known as cross entropy method. This is a famous kind of design method that is close to our "backward modeling of the mechanism" approach. Cross entropy methods seek to solve an expectation maximization problem (i.e., $\max_p\mathbb{E}_{p(\mathbf{m})}[f(\mathbf{m})]$ ) where the sequences follow a distribution $p$ . This can also be related to simulated annealing, a large family of black-box optimization algorithms - the sequential neural posterior could be thought to maintain a distribution which is gradually becoming sharper to a delta distribution at the optimal value. On the other hand, we think of this as a way for modeling the posterior $p(\mathbf{m}|\mathcal{E})$ and develop corresponding analysis under the probabilistic framework, which is like a more accurate version of cross entropy method. Many related methods (including the ones stated in Section 3.1) train the distribution by likelihood maximization for sequences with large scores, or use some sort of reweighting to achieve similar effects (Rubinstein & Kroese, 2004; de Boer et al., 2005; Neil et al., 2018; Gupta & Zou, 2019; Brookes et al., 2019).
487
+
488
+ Discriminative modeling usually goes in a "model-based optimization" way (terminology from Angermüller et al. (2020a)), i.e., use a discriminative model $\hat{f}(\mathbf{m})$ to fit the real oracle $f(\mathbf{m})$ and act as a surrogate for it. The surrogate model can replace the true oracle $f(\mathbf{m})$ which involves costly biological experiments. This corresponds to our "forward modeling of the mechanism" in Section 3.2. Bayesian optimization (Shahriari et al., 2016) is a classical example, which utilizes $\hat{f}$ (typically a Gaussian process model) to define an acquisition function to guide the exploration and exploitation. Many modern biochemical methods also belong to this category (Gómez-Bombarelli et al., 2018; Hashimoto et al., 2018; Yang et al., 2019; Wu et al., 2019; Sample et al., 2019; Liu et al., 2020).
489
+
490
+ There seems not much related literature about probability ratio estimation based method in this topic. On the other hand, Hashimoto et al. (2018) shares a classification based approach with IR but they differ on how to use the classifier. This algorithm utilizes the learned classifier to update the proposal with multiplicative weights algorithm, making the proposal to have large probability where the classifier logit is small. Other categories of drug design methods include evolution algorithms (Brindle, 1980; Wierstra et al., 2008; Salimans et al., 2017; Yoshikawa et al., 2018; Jensen, 2019; Real et al., 2019; Ahn et al., 2020) that search over the target space with genetic operators like insert, mutation, and crossover, and reinforcement learning (Guimaraes et al., 2017; Neil et al., 2018; Zhou et al., 2019; Shi et al., 2020; Angermüller et al., 2020b) which see the formation of a drug as a Markov decision process and train the policy to learn highly-rewarding drugs. We do not find other work that is similar to our probability ratio modeling approach (Section 3.3) from the literature, which we take as a novel contribution.
unifyinglikelihoodfreeinferencewithblackboxoptimizationandbeyond/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ebfdacb7e493ec8f9bfdbce47ebd6faa4ed3dd1e0fe444c7af25535179822ef
3
+ size 620664
unifyinglikelihoodfreeinferencewithblackboxoptimizationandbeyond/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c58fb1e863fcd3b7006fa4e94c4bb27c5f1909b4aa26bb54f375e84b4bb712ca
3
+ size 822225
universalapproximationunderconstraintsispossiblewithtransformers/73cdadad-7133-44f3-93c2-e97d9e3a6b1e_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:910a89422db6dd7e50dfa18e3326e2248299ead9078b96b5adf5f754c85b6483
3
+ size 100166
universalapproximationunderconstraintsispossiblewithtransformers/73cdadad-7133-44f3-93c2-e97d9e3a6b1e_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b552d4041ed1817a01b4724a05fbc07297be6fb569dc3242d5c262a3b3efae8a
3
+ size 134695
universalapproximationunderconstraintsispossiblewithtransformers/73cdadad-7133-44f3-93c2-e97d9e3a6b1e_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a6a3c4e5a844c528761b0a280f533fda25cd32156368401bbda504c87b52575a
3
+ size 1018253
universalapproximationunderconstraintsispossiblewithtransformers/full.md ADDED
@@ -0,0 +1,435 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # UNIVERSAL APPROXIMATION UNDER CONSTRAINTS IS POSSIBLE WITH TRANSFORMERS
2
+
3
+ Anastasis Kratsios\*Tianlin Liu & Ivan Dokmanic
4
+ Universitat Basel,
5
+ Departement Mathematik und Informatik
6
+ {firstname.lastname}@unibas.ch
7
+
8
+ Behnoosh Zamanlooy*
9
+ Universität Zürich,
10
+ Department of Informatics
11
+ bzamanlooy@ifi.uzh.ch
12
+
13
+ # ABSTRACT
14
+
15
+ Many practical problems need the output of a machine learning model to satisfy a set of constraints, $K$ . There are, however, no known guarantees that classical neural networks can exactly encode constraints while simultaneously achieving universality. We provide a quantitative constrained universal approximation theorem which guarantees that for any convex or non-convex compact set $K$ and any continuous function $f: \mathbb{R}^n \to K$ , there is a probabilistic transformer $\hat{F}$ whose randomized outputs all lie in $K$ and whose expected output uniformly approximates $f$ . Our second main result is a "deep neural version" of Berge (1963)'s Maximum Theorem. The result guarantees that given an objective function $L$ , a constraint set $K$ , and a family of soft constraint sets, there is a probabilistic transformer $\hat{F}$ that approximately minimizes $L$ and whose outputs belong to $K$ ; moreover, $\hat{F}$ approximately satisfies the soft constraints. Our results imply the first universal approximation theorem for classical transformers with exact convex constraint satisfaction, and a chart-free universal approximation theorem for Riemannian manifold-valued functions subject to geodesically-convex constraints.
16
+
17
+ Keywords: Constrained Universal Approximation, Probabilistic Attention, Transformer Networks, Geometric Deep Learning, Measurable Maximum Theorem, Non-Affine Random Projections.
18
+
19
+ # 1 INTRODUCTION
20
+
21
+ In supervised learning, we select a parameterized model $\hat{f}:\mathbb{R}^n\to \mathbb{R}^m$ by optimizing a real-valued loss function $L$ over training data from an input-output domain $\mathcal{X}\times \mathcal{Y}\subseteq \mathbb{R}^n\times \mathbb{R}^m$ . A necessary property for a model class to produce asymptotically optimal results, for any continuous loss $L$ , is the universal approximation property. However, often more structure (beyond vectorial $\mathbb{R}^m$ ) is present in a learning problem and this structure must be encoded into the trained model $\hat{f}$ to obtain meaningful or feasible predictions. This additional structure is typically described by a constraint set $K\subseteq \mathbb{R}^{m}$ and the condition $\hat{f} (\mathcal{X})\subseteq K$ . For example, in classification $K = \{y\in [0,1]^m:\sum_{i = 1}^m y_i = 1\}$ (Shalev-Shwartz & Ben-David, 2014), in Stackelberg games (Holters et al., 2018; Jin et al., 2020; Li et al., 2021) $K$ is the set of utility-maximizing actions of an opponent, in integer programming $K$ is the integer lattice $\mathbb{Z}^m$ (Conforti et al., 2014), in financial risk-management $K$ is a set of positions meeting the minimum solvency requirements imposed by international regularity bodies (Basel Committee on Banking Supervision, 2015; 2019; McNeil et al., 2015), in covariance matrix prediction $K\subseteq \mathbb{R}^{m\times m}$ is the set of $m\times m$ matrices which are symmetric and positive semidefinite (Bonnabel et al., 2013; Bonnabel & Sepulchre, 2009; Baes et al., 2021), in geometric deep learning $K$ is typically a manifold (e.g. a pose manifold in computer vision and robotics (Ding & Fan, 2014) or a manifold of distance matrices (Dokmanic et al., 2015)), a graph, or an orbit of a group action (Bronstein et al., 2017; 2021; Kratsios & Bilokopytov, 2020). Therefore, we ask:
22
+
23
+ Is exact constraint satisfaction possible with universal deep learning models?
24
+
25
+ The answer to this question begins by examining the classical universal approximation theorems for deep feedforward networks. If $L$ and $K$ are mildly regular, the universal approximation theorems of Hornik et al. (1989); Cybenko (1989); Pinkus (1999); Guhring et al. (2020); Kidger & Lyons (2020); Park et al. (2021) guarantee that for any "good activation function $\sigma$ " and for every tolerance level $\epsilon > 0$ , there is a deep feedforward network with activation function $\sigma$ , such that $\inf_{y \in K} L(x, y)$ and $L(x, \hat{f}(x))$ are uniformly at most $\epsilon$ apart. Written in terms of the optimality set,
26
+
27
+ $$
28
+ \sup _ {x \in \mathcal {X}} \| \hat {f} (x) - \underset {y \in K} {\operatorname {a r g m i n}} L (x, y) \| \leq \epsilon , \tag {1}
29
+ $$
30
+
31
+ where the distance of a point $y \in \mathbb{R}^m$ to a set $A \subseteq \mathbb{R}^m$ is defined by $\| y - A\| \triangleq \inf_{a \in A} \| y - a\|$ . Since $\operatorname{argmin}_{y \in K} L(x, y) \subseteq K$ , then (1) only implies that $\| \hat{f}(x) - K\| \leq \epsilon$ and there is no reason to believe that the constraint $\hat{f}(x) \in K$ is exactly satisfied, for every $x \in \mathcal{X}$ .
32
+
33
+ This kind of approximate constraint satisfaction is not always appropriate. In the following examples constraint violation causes either practical or theoretical concerns:
34
+
35
+ (i) In post-financial crisis risk management, international regulatory bodies mandate that any financial actor should maintain solubility proportional to the risk of their investments (Basel Committee on Banking Supervision, 2015; 2019). To prevent future financial crises, any violation of these risk constraints, no matter the size, incurs large and immediate fines.
36
+ (ii) In geometric deep learning, we often need to encode complicated non-vectorial structure present in a dataset, by viewing it as a $K$ valued function (Fletcher, 2013; Bonnabel & Sepulchre, 2009; Baes et al., 2021). However, if $K$ is non-convex then Motzkin (1935) confirms that there is no unique way to map predictions $\hat{f}(x) \notin K$ to a closest point in $K$ . Thus, we are faced with the dilemma: either make an ad-hoc choice of a $k$ in $K$ with $k \approx \hat{f}(x)$ (ex.: an arbitrary choice scheme when $K = \mathbb{Z}^m$ ) or have meaningless predictions (ex: non-integer values to integer programs, or symmetry breaking (Weinberg, 1976)<sup>2</sup>).
37
+
38
+ Constrained learning was recognized as an effective framework for fairness and robustness by Chamon & Ribeiro (2020) who study empirical risk minimization under constraints. Many emerging topics in machine learning lead to constrained learning formulations. A case in point is model-based domain generalization (Robey et al., 2021). Despite the importance of (deep) learning with constraints, there are no related approximation-theoretic results to the best of our knowledge.
39
+
40
+ In this paper, we bridge this theoretical gap by showing that universal approximation with exact constraint satisfaction is always possible for deep (probabilistic) transformer networks with a single attention mechanism as output layer. Our contribution is three-fold:
41
+
42
+ 1. We derive the first universal approximation theorem with exact constraint satisfaction;
43
+ 2. Our transformer network's encoder and decoder adapt to the dimension of the constraint set and thus beat the curse of dimensionality for low-dimensional constraints;
44
+ 3. Our models leverage a probabilistic attention mechanism that can encode non-convex constraints. This probabilistic approach is key to bypass the topological obstructions to non-Euclidean universal approximation (Kratsios & Papon, 2021).
45
+
46
+ Our analysis provides perspective on the empirical success of attention and adds to the recent line of work on approximation theory for transformer networks, (Yun et al., 2020a;b), which roughly considers the unconstrained case (with $K$ in (1) replaced by $\mathbb{R}^m$ ) in the special case of $L(x,y) = \| f(x) - y\|$ for a suitable target function $f:\mathbb{R}^n\to \mathbb{R}^m$ . Our probabilistic perspective on transformer networks fits with the representations of Vuckovic et al. (2021) and of Kratsios (2021).
47
+
48
+ Our results can be regarded as an approximation-theoretic counterpart to the constrained statistical learning theory of Chamon & Ribeiro (2020). Further, they put forward a perspective on randomness in neural networks that is complementary to the work of Louart et al. (2018); Gonon et al. (2020a;b). We look at the same problem focusing on constraint satisfaction instead of training efficiency. Finally, our proof methods are novel, and build on contemporary tools from metric geometry (Ambrosio & Puglisi, 2020; Brue et al., 2021).
49
+
50
+ # 1.1 THE PROBABILISTIC ATTENTION MECHANISM
51
+
52
+ We now give a high-level explanation of our results; the detailed formulations are in Section 2.
53
+
54
+ Introduced in (Bahdanau et al., 2015) and later used to define the transformer architecture (Vaswani et al., 2017), in the NLP context, attention maps a matrix of queries $Q$ , a matrix of keys $K$ , and a matrix of values $V$ to the quantity $\mathrm{Softmax}(QK^{\top})V$ , where the softmax function (defined below) is applied row-wise to $QK^{\top}$ . Just as the authors of (Petersen & Voigtlaender, 2020; Zhou, 2020) focus on the simplified versions of practically implementable ConvNets in the study of approximation theory of deep ConvNets (e.g. omitting pooling layers), we find it sufficient to study the following simplified attention mechanism to obtain universal approximation results:
55
+
56
+ $$
57
+ \operatorname {A t t e n t i o n} (w, Y) \triangleq \operatorname {S o f t m a x} _ {N} (w) ^ {\top} Y = \sum_ {n = 1} ^ {N} [ \operatorname {S o f t m a x} _ {N} (w) _ {n} ] Y _ {n}, \tag {2}
58
+ $$
59
+
60
+ where $w \in \mathbb{R}^N$ , $\operatorname{Softmax}_N: \mathbb{R}^N \ni w \mapsto \left( \frac{e^{w_k}}{\sum_{j=1}^N e^{w_j}} \right)_{k=1}^N$ , and $Y$ is an $N \times m$ matrix. The attention mechanism (2) can be interpreted as "paying attention" to a set of particles $Y_1, \ldots, Y_N \in \mathbb{R}^m$ defined by $Y$ 's rows. This simplified form of attention is sufficient to demonstrate that transformer networks can approximate a function while respecting a constraint set, $K$ , whether convex or non-convex.
61
+
62
+ Informal Theorem 1.1 (Deep Maximum Theorem for Transformers). If $K$ is convex and the quantities defining (1) are regular then, for any $\epsilon \in (0,1]$ , there is a feedforward network $\hat{f}$ , an $\mathcal{X}_{\epsilon} \subset \mathbb{R}^{n}$ of probability 1- $\epsilon$ , and a matrix $Y$ such that the transformer Attention $(\hat{f}(x),Y)$ satisfies:
63
+
64
+ (i) Exact Constraint Satisfaction: For each $x\in \mathbb{R}^n$ , Attention $(\hat{f} (x),Y)\in K$
65
+ (ii) Universal Approximation: $\sup_{x\in \mathcal{X}_{\epsilon}}\| \mathrm{Attention}(\hat{f} (x),Y) - \underset {y^{\star}\in K}{\mathrm{argmin}}L(x,y^{\star})\| \leq \epsilon$
66
+
67
+ Informal Theorem 1.1 guarantees that simple transformer networks can minimize any loss function while exactly satisfying the set of convex constraints. As illustrated by Figure 1 and Figure 2, $K$ 's convexity is critical here, since without it the transformer's prediction may fail to lie in $K$ . This is because any transformer network's output is a convex combinations of the particles $Y_{1}, Y_{2}, Y_{3}$ ; thus, any transformer network's predictions must belong to these particles' convex hull.
68
+
69
+ ![](images/3c6bf05f78772b679d5ab3278a8b71364941294994b0137859cca7401e3a5b25.jpg)
70
+ Figure 1: Convex Constraints
71
+
72
+ ![](images/c57d0ef09118de26a7089d58a16bdc0547c5889000eda2fdac12a5f628fa862e.jpg)
73
+ Figure 2: Non-Convex Constraints
74
+
75
+ In Figures 1 and 2, $Y$ 's columns, i.e. the particles $Y_{1}, Y_{2}$ , and $Y_{3}$ , are each illustrated by a $\bullet$ at the constraint set $(K)$ vertices. The bubble around each each $Y_{i}$ illustrates the predicted probability, for a given input, that $f(x)$ is nearest to that $Y_{i}$ . The $\times$ is the transformer's prediction which is, by construction, a convex combination of the $Y_{i}$ weighted by the aforementioned probabilities and therefore they lie in the $K$ if it is convex (Figure 1) but not if $K$ is non-convex (Figure 2).
76
+
77
+ Naturally, we arrive at the question: How can (i) and (ii) simultaneously hold when $K$ is non-convex?
78
+
79
+ Returning to Vaswani et al. (2017) and using the introduced terminology, we note that the role of the $\mathrm{Softmax}_N$ layer is to rank the importance of the particles $\{Y_n\}_{n=1}^N$ when optimizing $L$ , at any given input: the weights $[\mathrm{Softmax}_N(w)]_n$ in (2) can be interpreted as charging their respective point masses $\{\delta_{Y_n}\}_{n=1}^N$ with probabilities of being optimal for $L$ (relative to the other particles)<sup>3</sup>. This suggests the following probabilistic reinterpretation of attention (which we denote by p-attention):
80
+
81
+ $$
82
+ \operatorname {P} \text {- a t t e n t i o n} (w, Y) \triangleq \sum_ {n = 1} ^ {N} \left[ \operatorname {S o f t m a x} _ {N} (w) \right] _ {n} \delta_ {Y _ {n}}. \tag {3}
83
+ $$
84
+
85
+ Crudely put, P-attention $(\cdot ,Y)$ "pays relative attention to the particles" $Y_{1},\ldots ,Y_{n}\in \mathbb{R}^{m}$
86
+
87
+ A simple computation shows that the mean prediction of our probabilistic attention mechanism, exactly implements "classical" Attention of Vaswani et al. (2017), as defined in (2),
88
+
89
+ $$
90
+ \operatorname {A t t e n t i o n} (w, Y) = \mathbb {E} _ {X \sim \mathrm {P - a t t e n t i o n} (w, Y)} [ X ], \tag {4}
91
+ $$
92
+
93
+ where $\mathbb{E}_{X\sim \mathrm{P - attention}(w,Y)}[X]$ denotes the (vector-valued) expectation of a random-vector $X$ distributed according to $\mathrm{P - attention}(w,Y)$ . Hence, (3) is no less general than (2). The advantage of (3) is that, if each particle $Y_{n}$ belongs to $K$ (even if $K$ is non-convex) then, any sample drawn from the probability measure $\mathrm{P - attention}(w,Y)$ necessarily belongs to $K$ .
94
+
95
+ # 1.2 QUALITATIVE RESULTS: DEEP MAXIMUM THEOREM
96
+
97
+ Probabilistic attention (3) yields the following non-convex generalization of Informal Theorem 1.1. The result is a qualitative universal approximation theorem as well as a deep neural version of the Maximum Theorem<sup>4</sup> (Berge, 1963), which states that under mild regularity conditions, given any well-behaved family of input dependent "soft constraint sets" $\{C_x\}_{x \in \mathbb{R}^n}$ compatible with $K$ , there is a measurable function mapping each $x \in \mathbb{R}^n$ to a minimizer of $L(x, y)$ on $K \cap C_x$ .
98
+
99
+ We use $\mathcal{W}_1$ to denote the Wasserstein-1 distance between probability measures on $K$ . The results also give the flexibility to the user to enforce an input-dependent family of "soft constraints" $\{C_x\}_{x\in \mathbb{R}^n}$ which only need to hold approximately; definitions are provided in Section 1.4.
100
+
101
+ Informal Theorem 1.2 (Deep Maximum Theorem: Non-Convex Case). If the quantities defining $\mathcal{I}$ are regular, $K$ is a compact set of "exact constraints", and $\{C_x\}_{x \in \mathbb{R}^n}$ a set of "soft constraints", then, for any approximation quality $0 < \epsilon \leq 1$ , there is a deep feedforward network $\hat{f}$ and a matrix $Y$ satisfying:
102
+
103
+ (i) Exact Constraint Satisfaction: For each $x \in \mathbb{R}^n$ , P-attention $(\hat{f}(x), Y)$ is supported in $K$ ; (ii) Universal Approximation: $\mathbb{P}(\mathcal{W}_1(\mathrm{P - attention}(\hat{f}(x), Y), \operatorname*{argmin}_{y^\star \in C_x \cap K} L(x, y^\star)) \leq \epsilon) \geq 1 - \epsilon$ ; where for a probability measure $\mathbb{P}$ on $\mathbb{R}^m$ and a $B \subseteq \mathbb{R}^m$ we define $\mathcal{W}_1(\mathbb{P}, B) \triangleq \inf_{b \in B} \mathcal{W}_1(\mathbb{P}, \delta_b)$ .
104
+
105
+ Example 1.3 (Reduction to Classical Point-to-Set Distance). In particular, when $\mathbb{P}$ is a point-mass $\mathbb{P} = \delta_y$ for some $y\in \mathbb{R}^m$ , then one recovers the familiar Euclidean distance to the set $B$ via:
106
+
107
+ $$
108
+ \mathcal {W} _ {1} (\delta_ {y}, B) \stackrel {\mathrm {(d e f)}} {=} \inf _ {b \in B} \mathcal {W} _ {1} (\delta_ {y}, \delta_ {b}) = \inf _ {b \in B} \| y - b \| \stackrel {\mathrm {(d e f)}} {=} \| y - B \|;
109
+ $$
110
+
111
+ where the first and second equality follows from (Villani, 2009, (5) - page 99), and the last equality is the definition of $\| y - B \|$ (as in (Aubin & Frankowska, 2009, Definition 1.1.1)).
112
+
113
+ Another important class of non-convex constraints arising from geometric deep learning where $K$ is a non-Euclidean ball in a Riemannian submanifold of $\mathbb{R}^m$ . In this broad case, we may extract mean predictions from P-attention $(\hat{f}, Y)$ , by applying the Fréchet mean introduced in Fréchet (1948). Such "geometric means" are well-understood theoretically (Bhattacharya & Patrangenaru, 2003) and easily handled numerically Miolane et al. (2020); Lou et al. (2020).
114
+
115
+ # 1.3 QUANTITATIVE RESULTS: CONSTRAINED UNIVERSAL APPROXIMATION THEOREM
116
+
117
+ In its current form, the objective function $L$ is too general to derive quantitative approximation rates. Nevertheless, as with most universal approximation theorems (Hornik et al., 1989; Pinkus, 1999; Kidger & Lyons, 2020), if each soft constraint $C_x$ is set to $\mathbb{R}^m$ and $L$ quantifies the uniform distance to an unknown continuous function $f: \mathbb{R}^n \to K$ in the Euclidean sense,
118
+
119
+ $$
120
+ L (x, y) \triangleq \| f (x) - y \|,
121
+ $$
122
+
123
+ then, Informal Theorem 1.2 reduces to a (qualitative) universal approximation for transformer networks with exact constraint satisfaction. In fact, this additional structure is enough for us to derive quantitative versions of the aforementioned results. We permit ourselves the general situation, where
124
+
125
+ $K$ is contained in an unknown $d$ -dimensional submanifold (where $d \in \Theta(m^{\frac{1}{s}})$ for some $s > 0$ ). Our approximation rates scale favourably in the ratio $s \approx \frac{\log(m)}{\log(d)}$ ; i.e., we avoid the curse of dimensionality for low-dimensional constraint sets. This additional structure translates into the familiar encoder-decoder structure deployed in most transformer network implementations.
126
+
127
+ ![](images/6ac651f56839d843852a58a1c3f5d9aa2f4ff0581801dba8ca1e13bb761ecb9a.jpg)
128
+ Figure 3: Encoder : $\approx f$
129
+
130
+ ![](images/45ae1deb9aa5c526639e6a470417648adc672c0be4856cd8dedb5c638154ce86.jpg)
131
+ Figure 4: Decoder : ≈ Random Projection to $K$
132
+
133
+ Figure 3 illustrates the encoder network $\hat{\mathcal{E}}: \mathbb{R}^n \to \mathbb{R}^m$ , whose role is to perform a (classical) unconstrained approximation of the target function, $f$ . Since $\hat{\mathcal{E}}$ is a classical feedforward network then its approximation of the target function can be arbitrarily close to the constraint set $K$ but it need not lie in it. The next step is to "map the encoder network's output onto $K$ with low distortion." The role of the decoder network $\hat{\mathcal{D}}$ is to correct any constraint violation made by encoder network by "projecting them back on to $K$ ". However, such a projection does not exist if $K$ is not convex since there must be more than one closest point in $K$ to some $y \in \mathbb{R}^m$ (Motzkin, 1935). Nevertheless, if the "projection" were capable of mapping any $y \in \mathbb{R}^m$ to multiple points on $K$ , ranked by their proximity to $y$ , then there would be no trouble. The decoder network accomplishes precisely this, as illustrated in Figure 4, where the bubbles illustrate the probability of any particle in $K$ being closest to $y$ , illustrated by the size of the bubbles in Figure 4. Mathematically, ${}^6\hat{\mathcal{D}}: \mathbb{R}^m \to \mathcal{P}_1(K)$ approximates a (non-affine) random projection, in the sense of Ohta (2009); Ambrosio & Puglisi (2020); Bruè et al. (2021); i.e.: a 1-Lipschitz map $\Pi: \mathbb{R}^m \to \mathcal{P}_1(K)$ satisfying the random projection property: for all $y \in K$
134
+
135
+ $$
136
+ \Pi_ {y} = \delta_ {y}.
137
+ $$
138
+
139
+ Thus, $\Pi$ 's random projection property means that it fixes any output already satisfying the constraint $K$ , and its Lipschitz regularity implies that it is stable. Thus, sampling from $\Pi(y_1)$ is similar to sampling from $\Pi(y_2)$ whenever the points $y_1, y_2 \in \mathbb{R}^m$ are near to one another.
140
+
141
+ Remark 1.4. Random projections are closely tied to the (random) partitions of unity of Lee & Naor (2005) (see (Ambrosio & Puglisi, 2020, Theorem 2.8)). These random projections generalize the random projections of Johnson & Lindenstrauss (1984), beyond the case where $K$ is affine.
142
+
143
+ Remark 1.5. The special case of random projections onto affine spaces has recently been used when constructing universal neural models (Cuchiero et al., 2021; Puthawala et al., 2020).
144
+
145
+ We record the complexity of both the decoder and encoder networks constructed in our quantitative results in Table 1. Here $A, B, C, D \geq 0$ are constants independent of $\epsilon$ and $k$ , where $k \in \mathbb{N}_{+}$ is the number of continuous derivatives which $f$ admits (when viewed as a function into $\mathbb{R}^m$ ). From
146
+
147
+ <table><tr><td>Network</td><td>ˆ</td><td>ˆ</td></tr><tr><td>Depth</td><td>O(m1/s(1+ε23(kn+1)-2n/kn+1))</td><td>O((N3/2(A+2ε)(4-ε-1)2)/s)</td></tr><tr><td>Width</td><td>m1/s(4n+10)</td><td>m1/s+N+2</td></tr><tr><td>N</td><td>-</td><td>O((ε-1A+B)m/2)</td></tr><tr><td>Q</td><td>-</td><td>O(ε-m/s)</td></tr></table>
148
+
149
+ Table 1: Complexity of simple transformer network $\widehat{f} = \widehat{\mathcal{D}} \circ \widehat{\mathcal{E}}$ approximating $f$ .
150
+
151
+ Table 1, we see that if $m^{\frac{1}{s}} \ll m$ then, $s > 0$ is large; hence, $\epsilon^{\frac{m}{s}}, (1 - 4\epsilon^{-1})^{\frac{2m}{s}}$ , and $N^{\frac{m}{s}}$ are small.
152
+
153
+ # 1.4 NOTATION AND BACKGROUND
154
+
155
+ Optimal Transportd Given any non-empty subset $K \subseteq \mathbb{R}^m$ , the set of all Borel probability measures $\mathbb{P}$ on $K$ with a finite mean; i.e.: $\mathbb{E}_{X \sim \mathbb{P}}[||X||] < \infty$ , is denoted by $\mathcal{P}_1(K)$ . Wasserstein
156
+
157
+ distance $\mathcal{W}_1$ is defined for any $\mathbb{P},\mathbb{Q}\in \mathcal{P}_1(K)$ by the minimal energy needed to transport all mass from $\mathbb{P}$ to $\mathbb{Q}$ . Following Villani (2009), $\mathcal{W}_1(\mathbb{P},\mathbb{Q})$ is defined by:
158
+
159
+ $$
160
+ \mathcal {W} _ {1} (\mathbb {P}, \mathbb {Q}) \triangleq \inf _ {\pi} \mathbb {E} _ {(X _ {1}, X _ {2}) \sim \pi} [ \| X _ {1} - X _ {2} \| ],
161
+ $$
162
+
163
+ where the infimum is taken over all Borel probability measures $\pi$ on $K^2$ with marginals $\mathbb{P}$ and $\mathbb{Q}$ . The metric space $(\mathcal{P}_1(K),\mathcal{W}_1)$ is named the Wasserstein space over $K$ ; we abbreviate it by $\mathcal{P}_1(K)$ .
164
+
165
+ Smooth Function Spaces The set of real-valued continuous functions on $\mathbb{R}^n$ is denoted by $C(\mathbb{R}^n)$ . Let $k\in \mathbb{N}_{+}$ and $\mathcal{X}\subseteq [0,1]^n$ be non-empty. The set of functions $f:\mathcal{X}\to K$ for which there is a $k$ -times continuously differentiable $\pmb {f}:\mathbb{R}^n\rightarrow \mathbb{R}^m$ extending $f$ ; i.e.: $\pmb {f}|_{\mathcal{X}} = f$ , is denoted by $C_{tr}^{k}(\mathcal{X},K)$ . Our interest in $C_{tr}^{k}(\mathcal{X},K)$ does not stem from the fact that it contains all smooth functions mapping $[0,1]^n$ to $K$ , but rather that it allows us to speak about the uniform approximation of discontinuous $K$ -valued functions on regions in $[0,1]^n$ where they are "regular". This is noteworthy for pathological constraint sets, such as integer constraints<sup>7</sup>. For details on $C_{tr}^{k}(\mathcal{X},K)$ , see (Brudnyi & Brudnyi, 2012a;b) and the extension theorems of Whitney (1934); Fefferman (2005).
166
+
167
+ Neural Networks It has recently been observed that deep feedforward networks with multiple activation functions, or more generally parametric families of activation functions, achieved significantly more efficient approximation rates than classical feedforward networks with a single activation function (Yarotsky & Zhevnerchuk, 2020; Yarotsky, 2021; Shen et al., 2021a,b). Practically deployed examples of parametric activation functions are the PReLU activation function of He et al. (2015), the Sigmoid-weighted Linear Unit (SiLU) of Elfwing et al. (2018), and the Swish activation function of Ramachandran et al. (2018). We also observe a similar phenomenon, and therefore our quantitative results consider deep feedforward networks whose activation functions belong to a 1-parameter family $\sigma_{\star} \triangleq \{\sigma_t\}_{t \in [0,1]} \subseteq C(\mathbb{R})$ . The set of all such networks is denoted by $\mathcal{N}\mathcal{N}_{n,N}^{\sigma_{\star}}$ and it includes all $\hat{f}: \mathbb{R}^n \to \mathbb{R}^N$ with iterative representation:
168
+
169
+ $$
170
+ \hat {f} (x) \triangleq A ^ {(J)} x ^ {(J)}, \quad x _ {i _ {j}} ^ {(j + 1)} \triangleq \sigma_ {t _ {i _ {j}}} \left(\left(A ^ {(j)} x\right) _ {i _ {j}} + b _ {i _ {j}} ^ {(j)}\right), \quad x ^ {(0)} \triangleq x, \tag {5}
171
+ $$
172
+
173
+ where $x \in \mathbb{R}^n$ , $j = 1, \ldots, J - 1$ , each $A^{(j)}$ is a $d_j \times d_{j + 1}$ -matrix, each $b^{(j)} \in \mathbb{R}^{d_{j + 1}}$ , $d_{J + 1} = N$ , $d_1 = 0, t_{1,1}, \ldots, t_{J,N_J} \in [0,1]$ , for each $j$ . The integer $J$ is $\hat{f}$ 's depth and $\max_{j = 1,\dots,J + 1} d_j$ is $\hat{f}$ 's width.
174
+
175
+ Example 1.6 (Networks with Untrainable Nonlinearity). Denote $\sigma \triangleq \sigma_0$ . The subset of classical feedforward networks consisting of all $\hat{f} \in \mathcal{N}\mathcal{N}_{n,N}^{\sigma_\star}$ with each $\sigma_{t_{i_j}} = \sigma$ in (5) is denoted $\mathcal{N}\mathcal{N}_{n,N}^{\sigma}$ .
176
+
177
+ It is approximation theoretically advantageous to generalize the proposed definition of probabilistic attention in the introduction (3) by replacing $Y$ with a 3-dimensional array (elementary 3-tensor).
178
+
179
+ Definition 1.7 (Probabilistic Attention). Let $N, Q, m \in \mathbb{N}_{+}$ , and $Y$ be an $N \times Q \times m$ -array with $Y_{n,q} \in K$ for $n = 1, \ldots, N$ , $q = 1, \ldots, Q$ . Probabilistic attention is the function:
180
+
181
+ $$
182
+ \mathbb {R} ^ {n} \ni w \mapsto \operatorname {P - a t t e n t i o n} (w, Y) \triangleq \frac {1}{Q} \sum_ {n = 1} ^ {N} \sum_ {q = 1} ^ {Q} \operatorname {S o f t m a x} _ {N} (w) _ {n} \delta_ {Y _ {n, q}} \in \mathcal {P} _ {1} (K).
183
+ $$
184
+
185
+ If $Y$ is an $N \times m$ -matrix, as in (3), then we identify $Y$ as the $N \times m \times 1$ -array in the obvious manner.
186
+
187
+ Set-Valued Analysis: A family of non-empty subsets $\{C_x\}_{x \in \mathbb{R}^n}$ of $K$ is said to be a weakly measurable correspondence, denoted $C: \mathbb{R}^n \Rightarrow \mathbb{R}^m$ , if for every open subset $U \subseteq K$ , $\{x \in \mathbb{R}^n: C_x \cap U \neq \emptyset\}$ is a non-empty Borel subset of $\mathbb{R}^n$ (Aliprantis & Border, 2006, pages 557, 592).
188
+
189
+ # 2 MAIN RESULTS
190
+
191
+ We now present our main results in detail. All proofs are relegated to the paper's appendix.
192
+
193
+ # 2.1 QUALITATIVE APPROXIMATION: DEEP MAXIMUM THEOREM
194
+
195
+ Our main qualitative result is the following deep neural version of Berge (1963)'s Maximum Theorem where, the measurable selector is approximately implemented by a probabilistic transformer
196
+
197
+ network. We first present the general qualitative result which gives a concrete description of a measurable selector of (1), with high-probability, which has the key property that all its predictions satisfy the required constraints defined by $K$ .
198
+
199
+ Assumption 2.1 (Kidger & Lyons (2020)). $\sigma : \mathbb{R} \to \mathbb{R}$ is continuous, $\sigma$ is differentiable at some $x_0 \in \mathbb{R}$ , and its derivative satisfies $\sigma'(x_0) \neq 0$ .
200
+
201
+ Theorem 2.2 (Deep Maximum Theorem). Let $\sigma$ satisfy Assumption 2.1. Let $K\subseteq \mathbb{R}^n$ be a nonempty compact set, $C:\mathbb{R}^n\Rightarrow \mathbb{R}^m$ be a weakly-measurable correspondence with closed values such that $C_x\cap K\neq \emptyset$ for each $x\in \mathbb{R}^n$ , $L\in C(\mathbb{R}^m)$ , and $\mathbb{P}$ be a Borel probability measure on $\mathbb{R}^n$ .
202
+
203
+ For each $0 < \epsilon \leq 1$ , there is an $N \in \mathbb{N}_+$ , an $\hat{f} \in \mathcal{NN}_{n,N}^{\sigma}$ of width at most $2 + n + N$ , and an $N \times m$ -matrix $Y$ such that:
204
+
205
+ $$
206
+ \hat {F}: \mathbb {R} ^ {n} \ni x \mapsto \operatorname {P - a t t e n t i o n} (\hat {f} (x), Y) \in \mathcal {P} _ {1} (\mathbb {R} ^ {m}), \tag {6}
207
+ $$
208
+
209
+ satisfies the following:
210
+
211
+ (i) Exact Constrain Satisfaction: $\cup_{x\in \mathbb{R}^n}\operatorname {supp}(\hat{F} (x))\subseteq K,$
212
+
213
+ (ii) Probably Approximately Optimality: There is a compact $\mathcal{X}_{\epsilon} \subseteq \mathbb{R}^{n}$ satisfying:
214
+
215
+ (a) $\max_{x\in \mathcal{X}_{\epsilon}}\mathcal{W}_1(\hat{F} (x),\underset {y\in C_x\cap K}{\arg \min}L(x,y))\leq \epsilon ,$
216
+ (b) $1 - \mathbb{P}(\mathcal{X}_{\epsilon})\leq \epsilon$
217
+
218
+ Theorem 2.2 implies that for any random field $(Y^{x})_{x\in \mathbb{R}^{n}}$ on $\mathbb{R}^m$ (i.e. a family of $\mathbb{R}^m$ -valued random vectors indexed by $\mathbb{R}^n$ ) with $Y^{x}\sim \hat{F} (x)$ : 1. samples drawn from $Y^{x}$ are in $K$ (by (i)) and 2. samples drawn from each $Y^{x}$ are near to the optimality set $\mathrm{argmin}_{y\in C_x\cap K}L(x,y)$ (by (ii)).
219
+
220
+ Corollary 2.3 ( $\hat{F}$ 's Mean Prediction). Assume the setting of Theorem 2.2. Let $\{Y^x\}_{x \in \mathbb{R}^n}$ be a $K$ -valued random field with $Y^x \sim \hat{F}(x)$ for each $x \in \mathbb{R}^n$ then, $1 - \mathbb{P}(\mathcal{X}_\epsilon) \leq \epsilon$ and
221
+
222
+ $$
223
+ \max _ {x \in \mathcal {X} _ {\epsilon}} \mathbb {E} \big [ \| Y ^ {x} - \operatorname * {a r g m i n} _ {y ^ {\star} \in C _ {x} \cap K} L (x, y ^ {\star}) \| \big ] \leq \epsilon .
224
+ $$
225
+
226
+ Appendix 8 contains additional consequences of the Deep Maximum Theorem, such as the special case of classical transformers when $K$ is convex. Next, we complement our qualitative results by their quantitative analogues, within the context of universal approximation under constraints.
227
+
228
+ # 2.2 QUANTITATIVE APPROXIMATION: CONSTRAINED UNIVERSAL APPROXIMATION
229
+
230
+ In order to derive a quantitative constrained universal approximation theorem, we require the loss function to be tied to the Euclidean norm in the following manner.
231
+
232
+ Assumption 2.4 (Norm-Controllable Loss). There is a continuous $f: \mathbb{R}^n \to \mathbb{R}^m$ with $f(\mathbb{R}^n) \subseteq K$ and a continuous $l: [0, \infty) \to [0, \infty)$ with $l(0) = 0$ , satisfying: $L(x, y) \leq l(\|f(x) - y\|)$ .
233
+
234
+ Just as with transformer networks, our "constrained universal approximation theorem" approximates a suitably regular function $f: \mathbb{R}^n \to K \subseteq \mathbb{R}^m$ while exactly respecting the constraints $K$ by implementing an encoder-decoder network architecture. Thus, our model is a composition of an encoder network $\hat{\mathcal{E}}: \mathbb{R}^n \to \mathbb{R}^d$ whose role is to approximate $f$ in a classical "unconstrained fashion" and a decoder network (with probabilistic attention layers at its output) $\hat{\mathcal{D}}: \mathbb{R}^d \to \mathcal{P}_1(K)$ whose role is to enforce the constraints $K$ while preserving the approximation performed by $\hat{\mathcal{E}}$ , where $d \ll m$ .
235
+
236
+ To take advantage of the encoder-decoder framework present in most transformer networks, we formalize what is often called a "latent low-dimensional manifold" hypothesis. Briefly, this means that, the hard constraints in set $K$ are contained in a "low dimensional" subspace.
237
+
238
+ Assumption 2.5 (Low-Dimensional Manifold). There is an $0 < s$ and a smooth bijection $\Phi$ from $\mathbb{R}^n$ to itself with smooth inverse, such that $\Phi(K) \subseteq \mathbb{R}^d$ ; where $2 \leq d$ and $d \in \Theta(m^{\frac{1}{s}})$ .
239
+
240
+ Assumption 2.5 does not postulate that $K$ is itself a single-chart low-dimensional manifold, or even a manifold. Rather, $K$ need only be contained in a low-dimensional manifold. For the fast rates we use activation functions generalizing the swish function (Ramachandran et al., 2018) as follows.
241
+
242
+ Assumption 2.6 (Swish-Like Activation Function). The map $\sigma : [0,1] \times \mathbb{R} \ni (\alpha, t) \mapsto \sigma_{\alpha}(t) \in \mathbb{R}$ is continuous; $\sigma_0$ is non-affine and piecewise-linear; and $\sigma_1$ is smooth<sup>10</sup> and non-polynomial.
243
+
244
+ Theorem 2.7 (Constrained Universal Approximation). Let $k \in \mathbb{N}_{+}$ and $\mathcal{X} \subseteq [0,1]^n$ be non-empty. Suppose that $\sigma$ satisfies 2.6, $L$ satisfies Assumption 2.4, $K \subseteq \mathbb{R}^n$ is non-empty, compact and satisfies Assumption 2.5. For any $f \in C_{tr}^{k}(\mathcal{X},K)$ , every constraining quality $\epsilon_K > 0$ , and every approximation error $\epsilon_f > 0$ , there exist $N, Q \in \mathbb{N}_{+}$ , an encoder $\hat{\mathcal{E}} \in \mathcal{NN}_{n,d}^{\sigma}$ , and a decoder:
245
+
246
+ $$
247
+ \hat {\mathcal {D}}: \mathbb {R} ^ {d} \ni x \mapsto \sum_ {k = 1} ^ {N} \text {P - a t t e n t i o n} (\hat {D} (x), Y) \in \mathcal {P} _ {1} (K) \tag {7}
248
+ $$
249
+
250
+ where $\hat{D} \in \mathcal{N}\mathcal{N}_{d,N}^{\sigma}$ and $Y$ is an $N \times Q \times m$ -array with $Y_{1,1}, \ldots, Y_{N,Q} \in K$ such that:
251
+
252
+ (i) Exact Constrain Satisfaction: For each $x \in \mathbb{R}^n$ : $\operatorname{supp}(\hat{\mathcal{D}} \circ \hat{\mathcal{E}}(x)) \subseteq K$
253
+ (ii) Universal Approximation: The estimate holds $^{11}$ :
254
+
255
+ $$
256
+ \sup_{x\in [0,1]^{n}}\mathcal{W}_{1}(\hat{\mathcal{D}}\circ \hat{\mathcal{E}} (x),\operatorname *{argmin}_{y\in K}L(x,y))\leq \epsilon_{K} + k \mathrm{Lip}(\Phi^{-1})d\epsilon_{f};
257
+ $$
258
+
259
+ where, $0 < k$ is an absolute constant independent of $n$ , $m$ , $d$ , $f$ , and of $\epsilon$ and $\mathrm{Lip}(\Phi^{-1})$ denotes the Lipschitz constant of $\Phi^{-1}$ on the compact set $\{z \in \mathbb{R}^d : \| z - \Phi(K) \| \leq \epsilon_f\}$ .
260
+
261
+ Furthermore, the "complexities" of $\hat{\mathcal{D}}$ and $\hat{\mathcal{E}}$ are recorded in Table12 1 for $\frac{\epsilon}{2} = \epsilon_{k} = \epsilon_{f}$
262
+
263
+ In practice, we can only sample from each measure $\hat{\mathcal{D}}\circ \hat{\mathcal{E}} (x)$ . In this case, we may ask how the typical sample drawn from a random-vector $Y^{x}$ distributed according to our learned measure $\hat{\mathcal{D}}\circ \hat{\mathcal{E}} (x)$ performs when minimizing $L(x,y)$ . The next result relates the estimates in Theorem 2.7 (ii) to the typical (in $Y^{x}$ ) worst-case (in $x$ ) gap between a sample from $Y^{x}$ and $f(x)$ , as quantified by $L(x,\cdot)$ .
264
+
265
+ Corollary 2.8 (Average Worst-Case Loss). Assume the setting of Theorem 2.7 and suppose that the "modulus" $l$ in Assumption 2.4 is strictly increasing and concave. Let $\hat{\mathcal{D}}$ and $\hat{\mathcal{E}}$ be as in Theorem 2.7 and let $\{Y^x\}_{x \in \mathcal{X}}$ be an $\mathbb{R}^m$ -valued random field with $Y^x \sim \hat{\mathcal{D}} \circ \hat{\mathcal{E}}(x)$ , for each $x \in \mathbb{R}^n$ . Then:
266
+
267
+ $$
268
+ \max _ {x \in \mathcal {X}} \mathbb {E} _ {Y ^ {x} \sim \hat {\mathcal {D}} \circ \hat {\mathcal {E}} (x)} [ L (x, Y ^ {x}) ] \leq l \left(\epsilon_ {K} + k \operatorname {L i p} \left(\Phi^ {- 1}\right) d \epsilon_ {f}\right).
269
+ $$
270
+
271
+ Corollary 2.8 quantifies the expected performance of a sample from our probabilistic transformer model, as expressed by $L$ , whereas Theorem 2.7 (ii) quantifies the difference from the transformer's prediction to the optimal prediction value. Next, we consider implications of our main results.
272
+
273
+ # 2.3 APPLICATIONS
274
+
275
+ We apply our theory to obtain a universal approximation theorem for classical transformer networks with exact convex constraint satisfaction and to derive a version of the non-Euclidean universal approximation theorems of Kratsios & Bilokopytov (2020); Kratsios & Papon (2021) for Riemannian-manifold valued functions which does not need explicit charts. As with most quantitative (uniform) universal approximation theorems (Guhring et al., 2020; Kidger & Lyons, 2020; Shen et al., 2021a), we henceforth consider $L(x,y) = \| f(x) - y\|$ . We also fix $f\in C_{tr}^{k}([0,1]^{n},K)$ .
276
+
277
+ # 2.3.1 TRANSFORMERS ARE CONVEX-CONSTRAINED UNIVERSAL APPROXIMATORS
278
+
279
+ We return to the familiar transformer networks of Vaswani et al. (2017). The next result shows that transformer networks can balance universal approximation and exact convex constraint satisfaction. This is because when $K$ is convex, then the mean of the random field $\{Y^x\}_{x \in \mathbb{R}^n}$ of Corollary 2.3 must belong to $K$ . Consequently, the identity (4) implies that $\text{Attention}(\hat{\mathcal{D}} \circ \hat{\mathcal{E}}(\cdot), Y) \approx f$ .
280
+
281
+ Corollary 2.9 (Constrained Universal Approximation: Convex Constraints). Consider the setting and notation of Corollary 2.8. Suppose that $K$ is convex and let $L(x,y) = \| f(x) - y\|$ . Then:
282
+
283
+ $$
284
+ \mathbb {R} ^ {n} \ni x \mapsto \mathbb {E} \left[ Y ^ {x} \right] = \operatorname {A t t e n t i o n} \left(\hat {\mathcal {D}} \circ \hat {\mathcal {E}} (x), Y\right) \in K; \tag {8}
285
+ $$
286
+
287
+ (i) Exact Constraint Satisfaction: $\mathbb{E}_{Y^x\sim \hat{\mathcal{D}}_0\hat{\mathcal{E}} (x)}[Y^x ]\in K,$ for each $x\in \mathbb{R}^n$
288
+ (ii) Universal Approximation: $\sup_{[0,1]^n}\| f(x) - \mathbb{E}_{Y^x\sim \hat{\mathcal{D}}\circ \hat{\mathcal{E}} (x)}[Y^x ]\| < \epsilon_K + kd\epsilon_f.$
289
+
290
+ The "complexities" of the networks $\hat{\mathcal{D}}$ and $\hat{\mathcal{E}}$ are recorded in Table 13 $I$ for $\frac{\epsilon}{2} = \epsilon_{k} = \epsilon_{f}$
291
+
292
+ <sup>11</sup>In fact, we actually prove that the slightly stronger statement: $\sup_{x\in [0,1]^n}\mathcal{W}_1\left(\hat{\mathcal{D}}\circ \hat{\mathcal{E}} (x),\delta_{f(x)}\right)\leq \epsilon_K + k\operatorname {Lip}(\Phi^{-1})d\epsilon_f$ . Both formulations align when $l$ has a unique minimum at 0, as is the case when $L(x,y) = \| f(x) - y\|_{\star}$ and $\| \cdot \|_{\star}$ is any norm on $\mathbb{R}^m$ .
293
+ 12 Explicit constants are recorded in Table 2 within the paper's appendix; there, $\epsilon_{K}$ and $\epsilon_{f}$ may differ.
294
+ 13 Explicit constants are recorded in Table 2 within the paper's appendix; there, $\epsilon_{K}$ and $\epsilon_{f}$ may differ.
295
+
296
+ # 2.3.2 CHART-FREE RIEMANNIAN MANIFOLD-VALUED UNIVERSAL APPROXIMATION
297
+
298
+ We explore how additional non-convex structure of the constraint set $K$ can be encoded by the probabilistic transformer networks of Theorems 2.2 and 2.7 and be used to build new types of (deterministic) transformer networks. These results highlight that the standard transformer networks of (8) are specialized for convex constraints and that by instead using an intrinsic variant of expectation, we build can new types of "geometric transformer networks" customized to $K$ 's geometry. This section makes use of Riemannian geometry; for an overview see Jost (2017).
299
+
300
+ Let $(M,g)$ be a connected $d$ -dimensional Riemannian submanifold of $\mathbb{R}^m$ with distance function by $d_g$ . We only require the following mild assumption introduced in Afsari (2011). We recall that the injectivity radius at $y_0$ , denoted by $\inf_g(y_0)$ , (see (Jost, 2017, Definition 1.4.6)) is the minimum length of a geodesic (or minimal length curve) in $M$ with starting point $y_0$ . We also recall that the sectional curvature (see (Jost, 2017, Definition 4.3.2) for a formal statement) quantifies the curvature of $(M,g)$ as compared the geometry of its flat counterpart $\mathbb{R}^d$ . We focus on a broad class of nonconvex constraints, namely geodesically convex constraints, which generalize convex constraint and have received recent attention in the optimization literature (Zhang & Sra, 2016; Liu et al., 2017).
301
+
302
+ Assumption 2.10 (Geodesically Convex Constraints). The Riemannian manifold $(M,g)$ is connected, it is complete as a metric space, and all its sectional curvatures of $(M,g)$ are all bounded above by a constant $C\geq 0$ . The non-empty constrain set $K$ satisfies:
303
+
304
+ 1. $K$ is contained in the geodesic ball $B(y_0, \rho) \triangleq \{y \in M : d_g(y_0, y) < \rho\}$ for some point $y_0 \in M$ and some radius $\rho$ satisfying<sup>14</sup>: $0 < \rho < 2^{-1} \min \{\mathrm{inj}_g(y_0), \frac{\pi}{\sqrt{C}}\}$ ,
305
+ 2. For each $y_0, y_1 \in K$ there exists a unique geodesic $\gamma : [0,1] \to K$ joining $y_0$ to $y_1$ .
306
+
307
+ Our latent probabilistic representation grants us the flexibility of replacing the usual "extrinsic mean" used in (8) to extract deterministic predictions from our probabilistic transformer networks via an additional Fréchet mean layer at their readout. This intrinsic notion of a mean, was introduced independently in Fréchet (1948) and in Karcher (1977), and is defined on any $\mathbb{P} \in \mathcal{P}_1(K)$ by:
308
+
309
+ $$
310
+ \bar {\mathbb {P}} \triangleq \underset {k \in K} {\operatorname {a r g m i n}} \int d _ {g} ^ {2} (k, u) \mathbb {P} (d u). \tag {9}
311
+ $$
312
+
313
+ With this "geometric readout layer" added to our model, we obtain the following variants of our main results in this non-convex, but geometrically regular, setting.
314
+
315
+ Corollary 2.11 (Constrained Universal Approximation: Riemannian Case). Consider the setting and notation of Corollary 2.8. Let $L(x,y) = \| f(x) - y\|$ . If Assumption 2.10 holds then:
316
+
317
+ $$
318
+ \mathbb {R} ^ {n} \ni x \mapsto \widehat {\mathcal {D}} \circ \widehat {\mathcal {E}} (x) \in K, \tag {10}
319
+ $$
320
+
321
+ is a well-defined Lipschitz-continuous function, and the following hold:
322
+
323
+ (i) Exact Constraint Satisfaction: $\overline{\hat{D} \circ \hat{\mathcal{E}}(x)} \in K$ , for each $x \in \mathcal{X}$ ,
324
+ (ii) Universal Approximation: $\sup_{\mathcal{X}}d_g(f(x),\hat{\mathcal{D}}\circ \hat{\mathcal{E}} (x)) < \epsilon_K + kd\epsilon_f$
325
+
326
+ The "complexities" of $\hat{\mathcal{D}}$ and $\hat{\mathcal{E}}$ are recorded in Table<sup>15</sup> 1 for $\frac{\epsilon}{2} = \epsilon_{k} = \epsilon_{f}$ .
327
+
328
+ # 3 DISCUSSION
329
+
330
+ In this paper, we derived the first constrained universal approximation theorems using probabilistic reformation of Vaswani et al. (2017)'s transformer networks. The results assumed both a quantitative form (Theorem 2.7) and a qualitative form in the more general case of an arbitrary loss functions $L$ and additional compatible soft constraints in (Theorem 2.2). Our results provide (generic) direction to end-users designing deep learning models processing non-vectorial structures and constraints.
331
+
332
+ As this is the first approximation theoretic result in this direction, there are naturally as many questions raised as have been answered. In particular, it is natural to ask: "Are the probabilistic transformer networks trainable in practice; especially when $K$ is non-convex?" In Appendix 5, we show that the answer is indeed: "Yes!", by proposing a training algorithm in that direction and showing that we outperform an MLP model and a classical transformer network in terms of a joint MSE and distance to the constraint set. The evaluation is performed on a large number of randomly generated experiments, whose objective is to reduce the MSE to a randomly generated function mapping a high-dimensional Euclidean space to there sphere $\mathbb{R}^3$ with outputs constrained to the sphere.
333
+
334
+ # ACKNOWLEDGMENTS
335
+
336
+ Anastasis Kratsios and Ivan Dokmanić were supported by the European Research Council (ERC) Starting Grant 852821—SWING. The authors thank Wahid Khosrawi-Sardroudi, Phillip Casgrain, and Hanna Sophia Wutte from ETH Zürich, Valentin Debarnot from the University of Basel for their helpful feedback, and Sven Seuken from the University of Zürich for his helpful feedback in the rebuttal phase.
337
+
338
+ # REFERENCES
339
+
340
+ Bijan Afsari. Riemannian $L^p$ center of mass: existence, uniqueness, and convexity. Proceedings of the American Mathematical Society, 139(2):655-673, 2011.
341
+ Charalambos D. Aliprantis and Kim C. Border. Infinite dimensional analysis: A hitchhiker's guide. Springer, Berlin, third edition, 2006.
342
+ Luigi Ambrosio and Daniele Puglisi. Linear extension operators between spaces of Lipschitz maps and optimal transport. Journal für die Reine und Angewandte Mathematik, 764:1-21, 2020.
343
+ Anonymized. Pytorch implementation of attend-to-constraints, 2021. URL https://drive.google.com/file/d/1vryYsUmHt0fok3Mrje6oN9Tjs2UmpgkA/view.
344
+ Jean-Pierre Aubin and Hélène Frankowska. Set-valued analysis. Modern Birkhäuser Classics. Birkhäuser Boston, Inc., Boston, MA, 2009.
345
+ Michel Baes, Calypso Herrera, Ariel Neufeld, and Pierre Ruyssen. Low-rank plus sparse decomposition of covariance matrices using neural network parametrization. IEEE Transaction on Neural Networks and Learning Systems, 2021.
346
+ Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly learning to align and translate. In Proceedings of the International Conference on Learning Representations (ICLR), 2015.
347
+ Yair Bartal. On approximating arbitrary metrics by tree metrics. In Proceedings of the Thirtieth Annual ACM Symposium on the Theory of Computing, pp. 161-168. ACM, New York, 1999.
348
+ Basel Committee on Banking Supervision. Fundamental review of the trading book: outstanding issues, February 2015. https://www.bis.org/bcbs/publ/d305.pdf.
349
+ Basel Committee on Banking Supervision. Minimum capital requirements for market risk, February 2019. https://www.bis.org/bcbs/publ/d457.pdf.
350
+ Heinz H. Bauschke and Patrick L. Combettes. Convex analysis and monotone operator theory in Hilbert spaces. CMS Books in Mathematics/Ouvrages de Mathématiques de la SMC. Springer, New York, 2011. ISBN 978-1-4419-9466-0. doi: 10.1007/978-1-4419-9467-7. URL https://doi.org/10.1007/978-1-4419-9467-7. With a foreword by Hédy Attouch.
351
+ Claude Berge. Espaces Topologiques (Topological Spaces). Dunod, 1963.
352
+ Rabi Bhattacharya and Vic Patrangenaru. Large sample theory of intrinsic and extrinsic sample means on manifolds. The Annals of Statistics, 31(1):1-29, 2003.
353
+ Silvère Bonnabel and Rodolphe Sepulchre. Riemannian metric and geometric mean for positive semidefinite matrices of fixed rank. SIAM Journal on Matrix Analysis and Applications, 31(3): 1055-1070, 2009.
354
+ Silvère Bonnabel, Anne Collard, and Rodolphe Sepulchre. Rank-preserving geometric means of positive semi-definite matrices. Linear Algebra and its Applications, 438(8):3202-3216, 2013.
355
+ Michael M Bronstein, Joan Bruna, Yann LeCun, Arthur Szlam, and Pierre Vandergheynst. Geometric deep learning: going beyond Euclidean data. IEEE Signal Processing Magazine, 34(4):18-42, 2017.
356
+
357
+ Michael M Bronstein, Joan Bruna, Taco Cohen, and Petar Velicković. Geometric deep learning: Grids, Groups, Graphs, Geodesics, and Gauges. arXiv:2104.08708, 2021. URL http://arxiv.org/abs/2104.13478.
358
+ Bernard Bru, Henri Heinich, and Jean-Claude Lootgieter. Distances de Lévy et extensions des théorèmes de la limite centrale et de Glivenko-Cantelli. Publ. Inst. Statist. Univ. Paris, 37(3-4): 29-42, 1993.
359
+ Alexander Brudnyi and Yuri Brudnyi. Methods of geometric analysis in extension and trace problems. Volume 1, volume 102 of Monographs in Mathematics. Birkhäuser/Springer Basel AG, Basel, 2012a.
360
+ Alexander Brudnyi and Yuri Brudnyi. Methods of geometric analysis in extension and trace problems. Volume 2, volume 103 of Monographs in Mathematics. Birkhäuser/Springer Basel AG, Basel, 2012b.
361
+ Elia Brue, Simone Di Marino, and Federico Stra. Linear Lipschitz and $C^1$ extension operators through random projection. Journal of Functional Analysis, 280(4):108868, 2021.
362
+ Luiz Chamon and Alejandro Ribeiro. Probably approximately correct constrained learning. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS), 2020.
363
+ Michele Conforti, Gérard Cornuéjols, and Giacomo Zambelli. *Integer Programming*, volume 271 of Graduate Texts in Mathematics. Springer, Cham, 2014.
364
+ Christa Cuchiero, Lukas Gonon, Lyudmila Grigoryeva, Juan-Pablo Ortega, and Josef Teichmann. Discrete-time signatures and randomness in reservoir computing. IEEE Transactions on Neural Networks and Learning Systems, pp. 1-10, 2021.
365
+ Marco Cuturi. Sinkhorn distances: Lightspeed computation of optimal transport. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS), pp. 2292-2300, 2013.
366
+ George Cybenko. Approximation by superpositions of a sigmoidal function. Mathematics of Control, Signals, and Systems, 2(4):303-314, 1989.
367
+ Meng Ding and Guoliang Fan. Multilayer joint gait-posed manifolds for human gait motion modeling. IEEE Transactions on Cybernetics, 45(11):2413-2424, 2014.
368
+ Ivan Dokmanic, Reza Parhizkar, Juri Ranieri, and Martin Vetterli. Euclidean distance matrices: Essential theory, algorithms, and applications. IEEE Signal Processing Magazine, 32(6):12-30, 2015. doi: 10.1109/MSP.2015.2398954.
369
+ Richard M. Dudley. Real analysis and probability, volume 74 of Cambridge Studies in Advanced Mathematics. Cambridge University Press, Cambridge, 2002.
370
+ Stefan Elfwing, Eiji Uchibe, and Kenji Doya. Sigmoid-weighted linear units for neural network function approximation in reinforcement learning. *Neural Networks*, 107:3-11, 2018.
371
+ Charles L. Fefferman. A sharp form of Whitney's extension theorem. Annals of Mathematics, 161 (1):509-577, 2005.
372
+ Thomas Fletcher. Geodesic regression and the theory of least squares on Riemannian manifolds. International Journal of Computer Vision, 105(2):171-185, 2013.
373
+ Maurice Fréchet. Les éléments aléatoires de nature quelconque dans un espace distancié. Annales de l'Institut Henri Poincaré, 10:215-310, 1948.
374
+ Lukas Gonon, Lyudmila Grigoryeva, and Juan-Pablo Ortega. Risk bounds for reservoir computing. Journal of Machine Learning Research, 21(240):1-61, 2020a. URL http://jmlr.org/papers/v21/19-902.html.
375
+ Lukas Gonon, Lyudmila Grigoryeva, and Juan-Pablo Ortega. Approximation bounds for random neural networks and reservoir systems. arXiv preprint arXiv:2002.05933, 2020b.
376
+
377
+ Lyudmila Grigoryeva and Juan-Pablo Ortega. Universal discrete-time reservoir computers with stochastic inputs and linear readouts using non-homogeneous state-affine systems. J. Mach. Learn. Res., 19:Paper No. 24, 40, 2018.
378
+ Lyudmila Grigoryeva and Juan-Pablo Ortega. Differentiable reservoir computing. J. Mach. Learn. Res., 20:Paper No. 179, 62, 2019.
379
+ Ingo Guhring, Gitta Kutyniok, and Philipp Petersen. Error bounds for approximations with deep ReLU neural networks in $W^{s,p}$ norms. Analysis and Applications, 18(5):803-859, 2020.
380
+ Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Delving deep into rectifiers: Surpassing human-level performance on ImageNet classification. In Proceedings of the IEEE international conference on computer vision, pp. 1026-1034, 2015.
381
+ Juha Heinonen. Lectures on analysis on metric spaces. Universitext. Springer-Verlag, New York, 2001.
382
+ Ludger Holters, Björn Bahl, Maike Hennen, and André Bardow. Playing Stackelberg games for minimal cost for production and utilities. In ECOS 2018-Proceedings of the 31st International Conference on Efficiency, Cost, Optimisation, Simulation and Environmental Impact of Energy Systems, pp. 36-36. University of Minho, 2018.
383
+ Kurt Hornik, Maxwell Stinchcombe, and Halbert White. Multilayer feedforward networks are universal approximators. Neural Network, 2(5):359-366, July 1989.
384
+ Chi Jin, Praneeth Netrapalli, and Michael Jordan. What is local optimality in nonconvex-nonconcave minimax optimization? In Proceedings of the International Conference on Machine Learning (ICML), 2020.
385
+ William B. Johnson and Joram Lindenstrauss. Extensions of Lipschitz mappings into a Hilbert space. In Conference in modern analysis and probability, volume 26 of Contemp. Math., pp. 189-206. American Mathematical Society, RI, 1984.
386
+ Jürgen Jost. Riemannian geometry and geometric analysis. Universitext. Springer, Heidelberg, seventh edition, 2017.
387
+ Heinrich W. E. Jung. Über die Cremonasche Transformation der Ebene. J. Reine Angew. Math., 138:255-318, 1910. ISSN 0075-4102. doi: 10.1515/crll.1910.138.255.
388
+ Olav Kallenberg. Foundations of modern probability, volume 99 of Probability Theory and Stochastic Modelling. Springer, Cham, third edition, 2021.
389
+ Hermann Karcher. Riemannian center of mass and mollifier smoothing. Communications on Pure and Applied Mathematics, 30(5):509-541, 1977.
390
+ Patrick Kidger and Terry Lyons. Universal approximation with deep narrow networks. In Jacob Abernethy and Shivani Agarwal (eds.), Proceedings of Machine Learning Research, volume 125, pp. 2306-2327. PMLR, 09-12 Jul 2020.
391
+ Achim Klenke. Probability theory: A comprehensive course. Universitext. Springer, London, second edition, 2014.
392
+ Soheil Kolouri, Kimia Nadjahi, Umut Simsekli, Roland Badeau, and Gustavo Rohde. Generalized sliced Wasserstein distances. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS), 2019.
393
+ Anastasis Kratsios. Universal regular conditional distributions. arXiv preprint:2105.07743, 2021. URL https://arxiv.org/abs/2105.07743.
394
+ Anastasis Kratsios and Eugene Bilokopytov. Non-Euclidean universal approximation. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS), 2020.
395
+ Anastasis Kratsios and Leonie Papon. Universal approximation theorems for differentiable geometric deep learning, 2021. URL https://arxiv.org/abs/2101.05390.
396
+
397
+ James R. Lee and Assaf Naor. Extending Lipschitz functions via random metric partitions. Inventiones Mathematicae, 160(1):59-95, 2005.
398
+ Haochuan Li, Yi Tian, Jingzhao Zhang, and Ali Jabbabaie. Complexity lower bounds for nonconvex-strongly-concave min-max optimization. arXiv:2104.08708, 2021. URL https://arxiv.org/abs/2104.08708.
399
+ Yuanyuan Liu, Fanhua Shang, James Cheng, Hong Cheng, and Licheng Jiao. Accelerated first-order methods for geodesically convex optimization on riemannian manifolds. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS), 2017.
400
+ Aaron Lou, Isay Katsman, Qingxuan Jiang, Serge Belongie, Ser-Nam Lim, and Christopher De Sa. Differentiating through the Fréchet mean. In Proceedings of the International Conference on Machine Learning (ICML), 2020.
401
+ Cosme Louart, Zhenyu Liao, and Romain Couillet. A random matrix approach to neural networks. Ann. Appl. Probab., 28(2):1190-1248, 2018. ISSN 1050-5164. doi: 10.1214/17-AAP1328. URL https://doi.org/10.1214/17-AAP1328.
402
+ Mantas Lukosovicius and Herbert Jaeger. Reservoir computing approaches to recurrent neural network training. Computer Science Review, 3(3):127-149, 2009. ISSN 1574-0137.
403
+ Alexander J. McNeil, Rüdiger Frey, and Paul Embrechts. Quantitative Risk Management: Concepts, Techniques and Tools. Princeton Series in Finance. Princeton University Press, Princeton, NJ, 2015.
404
+ Nina Miolane, Nicolas Guigui, Alice Le Brigant, Johan Mathe, Benjamin Hou, Yann Thanwerdas, Stefan Heyder, Olivier Peltre, Niklas Koep, Hadi Zaatiti, Hatem Hajri, Yann Cabanes, Thomas Gerald, Paul Chauchat, Christian Shewmake, Daniel Brooks, Bernhard Kainz, Claire Donnat, Susan Holmes, and Xavier Pennec. Geomstats: A python package for riemannian geometry in machine learning. Journal of Machine Learning Research, 21(223):1-9, 2020.
405
+ Theodore Samuel Motzkin. Sur quelques propriétés caractéristiques des ensembles bornés non convexes. Bardi, 1935.
406
+ James R. Munkres. Topology. Prentice Hall, Inc., Upper Saddle River, NJ, 2000. Second edition.
407
+ Shin-ichi Ohta. Extending Lipschitz and Hölder maps between metric spaces. Positivity, 13(2): 407-425, 2009.
408
+ Sejun Park, Chulhee Yun, Jaeho Lee, and Jinwoo Shin. Minimum width for universal approximation. International Conference on Learning Representations (ICLR), 2021.
409
+ Ofir Pele and Michael Werman. Fast and robust Earth Mover's distances. In Proceedings of the 12th IEEE International Conference on Computer Vision (ICCV), pp. 460-467, 2009.
410
+ Philipp Petersen and Felix Voigtlaender. Equivalence of approximation by convolutional neural networks and fully-connected networks. Proceedings of the American Mathematical Society, 148 (4):1567-1581, 2020.
411
+ Allan Pinkus. Approximation theory of the MLP model in neural networks. Acta Numerica, 1999, 8:143-195, 1999.
412
+ Chayne Planiden and Xianfu Wang. Most convex functions have unique minimizers. Journal of Convex Analysis, 23(3):877-892, 2016.
413
+ Pakize Simin Pulat. On the relation of max-flow to min-cut for generalized networks. European Journal of Operational Research, 39(1):103-107, 1989.
414
+ Michael Puthawala, Konik Kothari, Matti Lassas, Ivan Dokmanić, and Maarten de Hoop. Globally injective ReLU networks. arXiv:2006.08464, 2020. URL https://arxiv.org/abs/2105.07743.
415
+ Prajit Ramachandran, Barret Zoph, and Quoc Le. Searching for activation functions. In Proceedings of the International Conference of Learning Representations (ICLR), 2018.
416
+
417
+ Alexander Robey, George J Pappas, and Hamed Hassani. Model-based domain generalization. arXiv:2102.11436, 2021. URL https://arxiv.org/abs/2102.11436.
418
+ James C. Robinson. *Dimensions, embeddings, and attractors*, volume 186 of Cambridge Tracts in Mathematics. Cambridge University Press, Cambridge, 2011.
419
+ Denis Rosset, Felipe Montealegre-Mora, and Jean-Daniel Bancal. RepLAB: A computational/numerical approach to representation theory. In Quantum Theory and Symmetries, pp. 643-653. Springer, 2021.
420
+ Shai Shalev-Shwartz and Shai Ben-David. Understanding Machine Learning: From Theory to Algorithms. Cambridge University Press, USA, 2014.
421
+ Zuowei Shen, Haizhao Yang, and Shijun Zhang. Neural network approximation: Three hidden layers are enough. Neural Networks, 141:160-173, 2021a.
422
+ Zuowei Shen, Haizhao Yang, and Shijun Zhang. Deep network with approximation error being reciprocal of width to power of square root of depth. Neural Computation, 33(4):1005-1036, 03 2021b.
423
+ Max Sommerfeld, Jörn Schrieber, Yoav Zemel, and Axel Munk. Optimal transport: Fast probabilistic approximation with exact solvers. Journal of Machine Learning Research, 20(105):1-23, 2019.
424
+ Karl-Theodor Sturm. Probability measures on metric spaces of nonpositive curvature. In Heat kernels and analysis on manifolds, graphs, and metric spaces, volume 338 of Contemp. Math., pp. 357-390. Amer. Math. Soc., Providence, RI, 2003.
425
+ Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention is all you need. In Proceedings of Advances in Neural Information Processing Systems, pp. 5998-6008, 2017.
426
+ Cédric Villani. Optimal Transport: Old and New, volume 338. Springer, 2009.
427
+ James Vuckovic, Aristide Baratin, and Remi Tachet des Combes. On the regularity of attention. arXiv:2102.05628, 2021. URL https://arxiv.org/abs/2102.05628.
428
+ Steven Weinberg. Implications of dynamical symmetry breaking. Physical Review D, 13(4):974, 1976.
429
+ Hassler Whitney. Analytic extensions of differentiable functions defined in closed sets. Transactions of the American Mathematical Society, 36(1):63-89, 1934.
430
+ Dmitry Yarotsky. Elementary superexpressive activations. In Proceedings of the 38th International Conference on Machine Learning (ICML), 2021.
431
+ Dmitry Yarotsky and Anton Zhevnerchuk. The phase diagram of approximation rates for deep neural networks. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS), volume 33, 2020.
432
+ Chulhee Yun, Srinadh Bhojanapalli, Ankit Singh Rawat, Sashank Reddi, and Sanjiv Kumar. Are transformers universal approximators of sequence-to-sequence functions? In Proceedings of the International Conference on Learning Representations (ICLR), 2020a.
433
+ Chulhee Yun, Yin-Wen Chang, Srinadh Bhojanapalli, Ankit Singh Rawat, Sashank Reddi, and Sanjiv Kumar. $O(n)$ connections are expressive enough: Universal approximability of sparse transformers. In Proceedings of Advances in Neural Information Processing Systems (NeurIPS), 2020b.
434
+ Hongyi Zhang and Suvrit Sra. First-order methods for geodesically convex optimization. In Proceedings of the 29th Conference on Learning Theory (COLT), 2016.
435
+ Ding-Xuan Zhou. Universality of deep convolutional neural networks. Applied and Computational Harmonic Analysis, 48(2):787-794, 2020.
universalapproximationunderconstraintsispossiblewithtransformers/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bec3c58fa42fe1641ac717fa016d16b611ff9faeeda7ea664f09396e47891a8c
3
+ size 147539
universalapproximationunderconstraintsispossiblewithtransformers/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5367bd6a111df5489e11dda79f8725f3211f6b6061dd02dacd06a03233bf67e4
3
+ size 841605
vaeapproximationerrorelboandexponentialfamilies/59188a09-537b-42ec-af57-2e24f01fd95a_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5445622c58b181a5eb246d53ca88bf33a8ac48f4180fcd646cf168844112061
3
+ size 126081
vaeapproximationerrorelboandexponentialfamilies/59188a09-537b-42ec-af57-2e24f01fd95a_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e203610836ab5a891008ca5cc1ffa67b15cc3f726457bbf925c47b6fbcd11279
3
+ size 148105
vaeapproximationerrorelboandexponentialfamilies/59188a09-537b-42ec-af57-2e24f01fd95a_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8e2e48d1e5c73c75e5b5414907ffd114b3bbf37301abc4151e516ca9c16e46b0
3
+ size 1669589
vaeapproximationerrorelboandexponentialfamilies/full.md ADDED
@@ -0,0 +1,657 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # VAE APPROXIMATION ERROR: ELBO AND EXPONENTIAL FAMILIES
2
+
3
+ # Alexander Shekhovtsov
4
+
5
+ Czech Technical University in Prague
6
+ shekhole@fel(cvut.cz
7
+
8
+ # Dmitrij Schlesinger
9
+
10
+ Dresden University of Technology Dmytro.Shlezinger@tu-dresden.de
11
+
12
+ # Boris Flach
13
+
14
+ Czech Technical University in Prague flachbor@fel.cyut.cz
15
+
16
+ # ABSTRACT
17
+
18
+ The importance of Variational Autoencoders reaches far beyond standalone generative models — the approach is also used for learning latent representations and can be generalized to semi-supervised learning. This requires a thorough analysis of their commonly known shortcomings: posterior collapse and approximation errors. This paper analyzes VAE approximation errors caused by the combination of the ELBO objective and encoder models from conditional exponential families, including, but not limited to, commonly used conditionally independent discrete and continuous models. We characterize subclasses of generative models consistent with these encoder families. We show that the ELBO optimizer is pulled away from the likelihood optimizer towards the consistent subset and study this effect experimentally. Importantly, this subset can not be enlarged, and the respective error cannot be decreased, by considering deeper encoder/decoder networks.
19
+
20
+ # 1 INTRODUCTION
21
+
22
+ Variational autoencoders (VAE, Kingma & Welling, 2014; Rezende et al., 2014) strive at learning complex data distributions $p_d(x)$ , $x \in \mathcal{X}$ in a generative way. They introduce latent variables $z \in \mathcal{Z}$ and model the joint distribution as $p_{\theta}(x|z)p(z)$ , where $p(z)$ is a simple distribution which is usually assumed to be known. The conditional distribution $p_{\theta}(x|z)$ , called decoder, is modeled in terms of a deep network parametrized by $\theta \in \Theta$ . Models defined in this way allow to sample from $p_{\theta}(x) = \mathbb{E}_{p(z)}p_{\theta}(x|z)$ easily, however at the price that computing the posterior $p_{\theta}(z|x) = p_{\theta}(x|z)p(z) / p_{\theta}(x)$ is usually intractable. To handle this problem, VAE approximates the posterior $p_{\theta}(z|x)$ by an amortized inference encoder $q_{\phi}(z|x)$ parametrized by $\phi \in \Phi$ . Given the empirical data distribution $p_d(x)$ , the model is learned by maximizing the evidence lower bound (ELBO) of the data log-likelihood $L(\theta) = \mathbb{E}_{p_d}\log p_\theta (x)$ . It can be expressed in the following two equivalent forms:
23
+
24
+ $$
25
+ \begin{array}{l} L _ {B} (\theta , \phi) = \mathbb {E} _ {p _ {d}} \left[ \mathbb {E} _ {q _ {\phi}} \log p _ {\theta} (x | z) - D _ {\mathrm {K L}} \left(q _ {\phi} (z | x) \| p (z)\right) \right] (1a) \\ = L (\theta) - \mathbb {E} _ {p _ {d}} \left[ D _ {\mathrm {K L}} \left(q _ {\phi} (z | x) \| p _ {\theta} (z | x)\right) \right]. (1b) \\ \end{array}
26
+ $$
27
+
28
+ The first form allows for stochastic optimization of ELBO while the second form shows that the gap between log-likelihood and ELBO is exactly the mismatch between the encoder and the posterior.
29
+
30
+ VAEs constitute a powerful deep learning extension of the expectation-maximization (EM) approach to handle latent variables. They are useful not only as generative models but also, e.g., in semi-supervised learning (Kingma et al., 2014; Mattei & Frellsen, 2019). Furthermore the encoder part constructs an efficient embedding of the data in the latent space, useful in many applications. The outreach of the VAE approach requires therefore a careful empirical and theoretical analysis of the problems and trade offs involved. The most important ones are (i) posterior collapse (He et al., 2019; Lucas et al., 2019; Dai et al., 2018; Dai & Wipf, 2019; Dai et al., 2020) and (ii) approximation errors caused by an inappropriate choice of the encoder family.
31
+
32
+ ![](images/3b2226b6e012269263318af0d1b32ce07ca648dfea15eac0ab34b6688a21818e.jpg)
33
+ Figure 1: Diagram of the VAE trade-off. The optimal solution $\theta_{\mathrm{VAE}}$ is "in between" the maximum likelihood solution $\theta_{\mathrm{ML}}$ and the best solution in the class $\Theta_{\Phi}$ of consistent VAEs, where the posterior approximation error function $F(\theta)$ vanishes. We give an explicit characterization of this consistent set. At $\theta_{\mathrm{VAE}}$ there is a balance between the gradient of $-F$ (blue arrow) and the gradient of the data log-likelihood (black arrow).
34
+
35
+ The VAE approximation error has been studied (e.g., Cremer et al. 2018; Hjelm et al. 2016; Kim et al. 2018) so far mainly empirically. The problem also occurs and is well-recognized in the context of variational inference and variational Bayesian inference, where the target posterior distribution is expected to be complex. It is commonly understood, that the mean field approximation of $p_{\theta}(z|x)$ by $q_{\phi}(z|x)$ in (1b) significantly limits variational Bayesian inference. In contrast, in VAEs, the decoder may adopt to compensate for the chosen encoder family. The effect of this coupling, we believe, is not fully understood. The phenomenon of decoder adopting to the posterior was experimentally observed, e.g., by Cremer et al. (2018, Section 5.4), noting that the approximation error is often dominated by the amortization error. Turner & Sahani (2011, Sec. 1.4) analytically show for linear state space models that simpler variational approximations (such a mean-field) can lead to less bias in parameter estimation than more complicated structured approximations. Similarly, Shu et al. (2018) view the VAE objective as providing a regularization and show that making the amortized inference model smoother, while increasing the amortization gap, leads to a better generalization.
36
+
37
+ The common (empirical) understanding of the importance of the gap between the approximate and the true posterior has led to many generalizations of standard VAEs, which achieve impressive practical results, notably, tighter bounds using importance weighting (Burda et al., 2016; Nowozin, 2018), encoders employing normalizing flows (Rezende & Mohamed, 2015; Kingma et al., 2016), hierarchical and autoregressive encoders (Vahdat & Kautz, 2020; Sønderby et al., 2016; Ranganath et al., 2016), MRF encoders (Vahdat et al., 2020) and more. While these extensions mitigate the posterior mismatch problem, they often come at a price of a more difficult training and more expensive inference. Furthermore, simpler encoders may be of practical interest. Burda et al. (2016, Appendix C) illustrates that IWAE approximate posteriors are less regular and more spread out. In contrast, factorized encoders provide simple embeddings useful for downstream tasks such as semantic hashing (Chaidaroon & Fang, 2017).
38
+
39
+ The aim of this paper is to study the approximation error of VAEs and its impact on the learned decoder. We consider a setting that generalizes many common VAEs, in particular popular models where encoder and decoder are conditionally independent Bernoulli or Gaussian distributions: we assume that both decoder and encoder are conditional exponential families. We identify the subclass of generative models where the encoder can model the posterior exactly, referred to as consistent VAEs. We give a characterization of consistent VAEs revealing that this set in fact does not depend on the complexity of the involved neural networks. We further show that the ELBO optimizer is pulled towards this set away from the likelihood optimizer. Specializing the characterization to several common VAE models, we show that the respective consistent models turn out to be RBM-like in many cases. We experimentally investigate the detrimental effect in one case and show that a simpler but more consistent VAE can perform better in the other.
40
+
41
+ # 2 PROBLEM STATEMENT
42
+
43
+ We adopt the following notion of approximation error. Consider a generative model class $\mathcal{P}_{\Theta} = \{p_{\theta}(x,z) \mid \theta \in \Theta\}$ , the encoder class $\mathcal{Q}_{\Phi} = \{q_{\phi}(z|x) \mid \phi \in \Phi\}$ and the data distribution $p_d(x)$ . The maximum likelihood generative model is given by $\theta_{\mathrm{ML}} \in \operatorname{argmax}_{\theta \in \Theta} \mathbb{E}_{p_d(x)} \log p_{\theta}(x)$ . For a decoder with parameters $\theta$ we define its approximation error as the likelihood difference $L(\theta_{\mathrm{ML}}) -$
44
+
45
+ $L(\theta)$ . Respectively, the VAE approximation error is defined for a given $\theta$ as:
46
+
47
+ $$
48
+ L \left(\theta_ {\mathrm {M L}}\right) - \max _ {\phi} L _ {B} (\theta , \phi) \geq L \left(\theta_ {\mathrm {M L}}\right) - L (\theta). \tag {2}
49
+ $$
50
+
51
+ In order for this error to become zero, two conditions are necessary and sufficient:
52
+
53
+ - Parameters $(\theta, \phi)$ must be optimal for the ELBO objective.
54
+ - ELBO must be tight at $(\theta, \phi)$ , i.e., $L_B(\theta, \phi) = L(\theta)$ .
55
+
56
+ Assuming that the optimality can be achieved, we study the non-tightness gap $L(\theta) - L_B(\theta, \phi)$ . From (1b) it expresses as $\mathbb{E}_{p_d}\left[D_{\mathrm{KL}}(q_\phi(z|x) \| p_\theta(z|x))\right]$ . It follows that ELBO is tight at $(\theta, \phi)$ iff $q_\phi(z|x) \equiv p_\theta(z|x)$ . Hence, we define the consistent set $\Theta_\Phi \subseteq \Theta$ as the subset of distributions $p_\theta(x,z)$ whose posteriors are in $\mathcal{Q}_\Phi$ , i.e.,
57
+
58
+ $$
59
+ \Theta_ {\Phi} = \left\{\theta \in \Theta \mid \exists \phi \in \Phi : q _ {\phi} (z | x) \equiv p _ {\theta} (z | x) \right\}. \tag {3}
60
+ $$
61
+
62
+ The KL-divergence in the ELBO objective (1b) can vanish only if $\theta \in \Theta_{\Phi}$ . If the likelihood maximizer $\theta_{\mathrm{ML}}$ is not contained in $\Theta_{\Phi}$ , then this KL-divergence pulls the optimizer towards $\Theta_{\Phi}$ and away from $\theta_{\mathrm{ML}}$ as illustrated in Fig. 1.
63
+
64
+ We characterize the consistent set $\Theta_{\Phi}$ , on which the bound is tight, and show that this set is quite narrow and does not depend on the complexity of the encoder and decoder networks beyond simple 1-layer linear mappings of sufficient statistics.
65
+
66
+ # 3 THEORETICAL ANALYSIS
67
+
68
+ We consider a general class of VAEs, where both encoder and decoder are defined as exponential families. This class includes many common models, in particular Gaussian VAEs and Bernoulli VAEs with conditional independence assumptions, but also more complex ones, e.g., where the encoder is a conditional random field (Vahdat et al., 2020) $^1$ .
69
+
70
+ Assumption 1 (Exponential family VAE). Let $\mathcal{X}$ and $\mathcal{Z}$ be sets of observations and latent variables, respectively. We consider VAE models defined by
71
+
72
+ $$
73
+ p _ {\theta} (x \mid z) = h (x) \exp \left[ \langle \nu (x), f _ {\theta} (z) \rangle - A \left(f _ {\theta} (z)\right) \right] \tag {4a}
74
+ $$
75
+
76
+ $$
77
+ q _ {\phi} (z \mid x) = h ^ {\prime} (z) \exp \left[ \langle \psi (z), g _ {\phi} (x) \rangle - B \left(g _ {\phi} (x)\right) \right], \tag {4b}
78
+ $$
79
+
80
+ where $\nu \colon \mathcal{X} \to \mathbb{R}^n$ and $\psi \colon \mathcal{Z} \to \mathbb{R}^m$ are fixed sufficient statistics of dimensionality $n$ and $m$ ; $f_{\theta} \colon \mathcal{Z} \to \mathbb{R}^n$ and $g_{\phi} \colon \mathcal{X} \to \mathbb{R}^m$ are the decoder, resp., encoder, networks with learnable parameters $\theta$ , resp. $\phi$ ; $h \colon \mathcal{X} \to \mathbb{R}_+$ , $h' \colon \mathcal{Z} \to \mathbb{R}_+$ are strictly positive base measures and $A$ , $B$ denote the respective log-partition functions.
81
+
82
+ Notice that this assumption imposes no restrictions on the nature of random variables $x$ and $z$ . They can be discrete or continuous, univariate or multivariate. Similarly, it imposes no restrictions on the complexity of the decoder and encoder networks $f_{\theta}(z)$ and $g_{\phi}(x)$ .
83
+
84
+ Characterization of the consistent set. In the first step of our analysis, we investigate the conditions under which the approximation error of an exponential family VAE can be made exactly zero. As discussed above, a tight VAE $(\theta ,\phi)$ must satisfy $\forall (x,z)q_{\phi}(z|x) = p_{\theta}(z|x)$ , which leads to the following theorem.
85
+
86
+ Theorem 1. The consistent set $\Theta_{\Phi}$ of an exponential family VAE is given by decoders of the form
87
+
88
+ $$
89
+ p (x \mid z) = h (x) \exp \left[ \langle \nu (x), W \psi (z) \rangle + \langle \nu (x), u \rangle - A (z) \right], \tag {5}
90
+ $$
91
+
92
+ where $W$ is a $n \times m$ matrix and $u \in \mathbb{R}^n$ . Moreover, the corresponding encoders have the form
93
+
94
+ $$
95
+ q (z | x) = h ^ {\prime} (z) \exp \left[ \left\langle \psi (z), W ^ {T} \nu (x) \right\rangle + \left\langle \psi (z), v \right\rangle - B (x) \right], \tag {6}
96
+ $$
97
+
98
+ where $v\in \mathbb{R}^m$
99
+
100
+ This is a direct consequence of a theorem by Arnold & Strauss (1991) (see Appendix A.1 for more details). For a tight VAE, Theorem 1 states that the decoder and encoder are generalized linear models (GLMs) (5) and (6) with the interaction between $x$ and $z$ parametrized by a matrix $W$ and two vectors $u, v$ instead of the (complex) neural networks with parameters $\theta, \phi$ . The corresponding joint probability distribution takes the form of an EF Harmonium (Welling et al., 2005):
101
+
102
+ $$
103
+ p (x, z) = h (x) h ^ {\prime} (z) \exp \big (\langle \nu (x), W \psi (z) \rangle + \langle \nu (x), u \rangle + \langle \psi (z), v \rangle - A \big). \tag {7}
104
+ $$
105
+
106
+ Corollary 1. The subset $\Theta_{\Phi}$ of consistent models can not be enlarged by considering more complex encoder networks $g(x)$ , provided that the affine family $W^{\top} \nu(x)$ can already be represented.
107
+
108
+ Corollary 2. Let the decoder network family be affine in $\psi (z)$ , i.e., $f(z) = W\psi (z) + a$ and let the encoder network family $g(x)$ include at least all affine maps $V\nu (x) + b$ . Then any global optimum of ELBO attains a zero approximation error.
109
+
110
+ VAE can escape consistency when it degenerates to a flow. In practice, VAE models with rich decoders are almost never tight. It is therefore natural to ask, whether a small VAE posterior mismatch error implies closeness of the optimal decoder to some decoder in the consistent set.
111
+
112
+ Definition 1. A VAE $(p_{\theta},q_{\phi})$ is $\varepsilon$ -tight for some $\varepsilon >0$ if $\mathbb{E}_{p_d(x)}[D_{\mathrm{KL}}(q_\phi (z|x)\| p_\theta (z|x))]\leq \varepsilon$ .
113
+
114
+ It turns out that this definition allows a VAE to approach tightness while not approaching consistency. In the continuous case an example satisfying $\varepsilon$ -tightness with non-linear decoder follows from Dai & Wipf (2019, Theorem 2). They show, for a class of Gaussian VAEs with general neural networks $f_{\theta}$ , $g_{\phi}$ , that it is possible to build a sequence of network parameters $\theta_t$ , $\phi_t$ with the following properties: i) the target distribution is approximated arbitrary well, ii) the posterior mismatch $D_{\mathrm{KL}}(q_{\phi_t}(z|x)\| p_{\theta_t}(z|x))$ approaches zero and iii) both the encoder and decoder approach deterministic mappings. The VAE thus approaches a flow model (or invertible neural network) between the data manifold and a subspace of the latent space (Dai & Wipf, 2019). Clearly, in a general case the flow must be non-linear. A similar case can be made for discrete variables, see Example A.1.
115
+
116
+ Non-deterministic nearly-tight VAEs approach consistency. We would however argue that the mode where the decoder and encoder are nearly-deterministic is not a natural VAE solution. By making additional assumptions, excluding such deterministic solutions, and restricting ourselves to the finite space in order to simplify the analysis, we can show that an $\varepsilon$ -tight VAE does indeed approach an EF-Harmonium.
117
+
118
+ Theorem 2. Let $(p_{\theta}, q_{\phi})$ be an exponential family VAE (Assumption 1) on a discrete space $\mathcal{X} \times \mathcal{Z}$ with encoder $q_{\phi}(z|x)$ and decoder posterior $p_{\theta}(z|x)$ both bounded from below by $\alpha > 0$ . If the VAE is $\varepsilon$ -tight, then there exists a matrix $W \in \mathbb{R}^{n,m}$ and vectors $u \in \mathbb{R}^n$ , $v \in \mathbb{R}^m$ such that the joint model implied by the decoder $p_{\theta}(x,z) = p_{\theta}(x|z)p(z)$ can be approximated by an unnormalized EF Harmonium
119
+
120
+ $$
121
+ \tilde {p} (x, z) = h (x) h ^ {\prime} (z) \exp (\langle \nu (x), W \psi (z) \rangle + \langle \nu (x), u \rangle + \langle v, \psi (z) \rangle + c) \tag {8}
122
+ $$
123
+
124
+ with the error bound
125
+
126
+ $$
127
+ \mathbb {E} _ {p _ {d} (x)} \left[ \left(\log p _ {\theta} (x, z) - \log \tilde {p} (x, z)\right) ^ {2} \right] \leq \frac {\varepsilon}{2 \alpha^ {2}} + o (\varepsilon) \quad \forall z \in \mathcal {Z}. \tag {9}
128
+ $$
129
+
130
+ The proof is given in Appendix A.3. In this theorem the function $\tilde{p}(x, z)$ is non-negative but does not necessarily satisfy the normalization constraint of a density. Re-normalizing it by adjusting $c$ in (8) may break the approximation guarantee. Nevertheless, if $\varepsilon$ is small enough and, e.g., the data distribution is non-negative on the whole $\mathcal{X}$ , we expect it to approach a density, in particular to recover the result in Theorem 1 in the limit. Note that the theorem does not make any assumptions about optimality of $(\theta, \phi)$ , i.e., it describes all models in the vicinity of the consistent set in Fig. 1.
131
+
132
+ # 3.1 CASES ANALYSIS
133
+
134
+ This subsection gives a detailed analysis of consistent VAE models in several concrete cases of practical interest.
135
+
136
+ Diagonal Gaussian VAE Let us consider a Gaussian VAE, as commonly applied to image generation (e.g., Dai & Wipf (2019)). Let $\mathcal{X} = \mathbb{R}^n$ , $\mathcal{Z} = \mathbb{R}^m$ , $p(x|z) = \mathcal{N}(x|\mu_d(z), \sigma_d^2 I)$ ,
137
+
138
+ $q(z|x) = \mathcal{N}(z|\mu_e(x),\mathrm{diag}(\sigma_e^2 (x)))$ , where $\mu_{d},\mu_{e}$ and $\sigma_{e}$ are neural networks and $\sigma_{d}$ is a common pixel observation noise parameter. The decoder has minimal sufficient statistics $\nu (x) = x$ and base measure $h(x) = \mathcal{N}(x|0,\sigma_d^2 I)$ . The encoder has minimal sufficient statistics $\psi (z) = (z,z^2)$ , where the square is coordinate-wise. Theorem 1 implies that a tight optimal VAE has the joint model
139
+
140
+ $$
141
+ p (x, z) \propto h (x) \exp \left[ \left\langle x, W z + V z ^ {2} + a \right\rangle + \left\langle b, z \right\rangle + \left\langle c, z ^ {2} \right\rangle \right] \tag {10}
142
+ $$
143
+
144
+ for some matrices $W$ , $V$ and vectors $a, b, c$ . Furthermore, the integral over $z$ must be finite for all $x$ and therefore $x^{\mathsf{T}}V + c < 0$ must hold for all $x \in \mathbb{R}^n$ . This is possible only if $V = 0$ and $c < 0$ . The joint distribution is therefore a multivariate Gaussian and the same holds for its marginal $p(x)$ . The neural network $\mu_d(z)$ must degenerate to $\mu_d(z) = \sigma_d^2 \cdot (Wz + a)$ and the two neural networks for the encoder to $\sigma_e^2(x) = -1/2c$ and $\mu_e(x) = -(W^{\mathsf{T}}x + b)/2c$ , where divisions are coordinate-wise. VAEs with such simplified, linear Gaussian encoder-decoder pairs, called "linear VAEs" (Lucas et al., 2019) are known to be consistent and to match the probabilistic PCA model (Dai et al., 2018; Lucas et al., 2019). In this context, our Corollary 2 is a generalization of (Lucas et al., 2019, Lemma 1) showing consistency of linear VAEs, to decoders in any exponential family with natural parameters being a linear mapping of any fixed lifted latent representation $\psi(z)$ .
145
+
146
+ We argue that a joint Gaussian model is too simplistic to generate complex data such as realistic images and that in this case the VAE error is detrimental. In Section 4.2 we experimentally confirm that optimizing ELBO for a general decoder network $\mu_{d}$ causes qualitative and quantitative degradation relative to the ML decoder. Note that if we allowed $\sigma_{d}$ to be dependent on $z$ , the resulting joint statistics in $\nu \otimes \psi$ would include terms $x^{2}z$ , $x^{2}z^{2}$ . The joint distribution would not be Gaussian and may be in fact multi-modal (see Anil Bhattacharayya's distribution in Arnold et al. 2001).
147
+
148
+ Bernoulli-MRF VAE Vahdat et al. (2020) proposed to consider encoders in the Markov Random Field (MRF) family, in particular encoders of the form $q(z|x) \propto \exp(\langle z^1, V(x)z^2 \rangle + \langle b^1(x), z^1 \rangle + \langle b^2(x), z_2 \rangle)$ , where $z^1, z^2$ are two groups of latent variables and interaction weights $V, b^1, b^2$ are computed by the encoder network. In this case $q(z|x)$ is itself a (conditional) RBM. While evaluating $q(z|x)$ is difficult, MCMC sampling is efficient. We assume binary observations $x$ and a conditionally independent Bernoulli decoder family as above. The decoder thus has sufficient statistics $\nu = x$ and the encoder has $\psi = (z^1, z^2, z^1 \otimes z^2)$ . Introducing homogeneous constant components $x_0 = z_0^1 = z_0^2 = 1$ , the family of consistent joint distributions can be compactly described as
149
+
150
+ $$
151
+ p (x, z) = \exp \left[ \sum_ {i, j, k} W _ {i, j, k} x _ {i} z _ {j} ^ {1} z _ {k} ^ {2} \right], \tag {11}
152
+ $$
153
+
154
+ where the summation in all indices starts from 0 and $-W_{0,0,0}$ is the log-partition function. This joint model is a higher order MRF with the highest order potentials given by cubic monomials.
155
+
156
+ Standard Bernoulli VAEs are a special case of the Bernoulli-MRF model, obtained when the interaction weights $V$ are zero. The joint distribution of such tight optimal VAEs takes the form
157
+
158
+ $$
159
+ p (x, z) = \frac {1}{c} \exp \left(x ^ {\mathsf {T}} W z + u ^ {\mathsf {T}} x + v ^ {\mathsf {T}} z\right), \tag {12}
160
+ $$
161
+
162
+ which is a restricted Boltzmann machine (RBM). Since RBMs are well known for being useful in many applications (dimensionality reduction, collaborative filtering, feature learning, topic modeling), we hypothesize that they can make a good baseline for Bernoulli VAEs and furthermore that the effect of pulling the VAE solution towards an RBM may be benign in case of insufficient data. For example IwAE test likelihood in (Burda et al., 2016) is worse than that of an RBM (Burda et al., 2015) on the Omniglot dataset. Furthermore, debiasing of IwAE (Nowozin, 2018) does not improve test likelihood in many cases.
163
+
164
+ Bernoulli VAE for Semantic Hashing One important application of Bernoulli VAEs is the semantic hashing problem, initially proposed and modeled with RBMs (Salakhutdinov & Hinton, 2009). The problem is to assign to each document / image a compact binary latent code that can be used for quick retrieval by the nearest neighbor search. We will detail now a more recent VAE model for text documents (Chaidaroon & Fang, 2017; Shen et al., 2018) and show that it can be tight only in a full posterior collapse. We correct the encoder so as to allow a larger consistent set and observe that the resulting consistent joint distribution forms a multinomial-Bernoulli RBM.
165
+
166
+ Let $x \in \mathbb{N}^K$ be word counts in a document with words from a dictionary of size $K$ . Let $z \in \{0,1\}^m$ be a binary latent code. Let $l = \sum_{k} x_k$ denote the document's length. We assume that the document
167
+
168
+ length is independent of the latent topic and its distribution $p(l)$ can be learned separately (e.g., a log-normal distribution is a good fit). The decoder is defined using the multinomial distribution model (words in the document are drawn from the same categorical distribution corresponding to its topic):
169
+
170
+ $$
171
+ p (x, l \mid z) = p (l) h (x \mid l) \exp (f (z) ^ {\top} x - l A (f (z))), \tag {13}
172
+ $$
173
+
174
+ where $f(z)$ is a neural network mapping the latent code to the logits of word occurrence probabilities, $A(\eta) = \log \sum_{k} \exp(\eta_{k})$ and $h(x|l) = \mathbb{I}\left[\sum_{k} x_{k} = l\right] \left( \frac{l!}{\prod_{k} x_{k}} \right)$ is the base measure<sup>2</sup>. The sufficient statistics are the word counts $x$ . The prior $p(z)$ is assumed uniform Bernoulli.
175
+
176
+ The encoder is the conditionally independent Bernoulli model, expressed as
177
+
178
+ $$
179
+ q (z | x, l) \propto \exp (g (x) ^ {\mathsf {T}} z), \tag {14}
180
+ $$
181
+
182
+ where $g(x)$ is the encoder network. Chaidaroon & Fang (2017) experimented with the encoder and decoder design and recommended using TFIDF features instead of raw counts. First, we note that the inverse document frequency (IDF) is not relevant, since it can be learned by the first linear transform in the encoder. Effectively, the term frequency (TF), given by $x / l$ , is used. This choice is adopted in later works (Shen et al., 2018; Zamani Dadaneh et al., 2020; Nanculef et al., 2020). It might seem reasonable that the latent code modeling the document topic should not depend on the document length, only on the distribution of words in the document. However, we will argue that this rationale is misleading for stochastic encoders.
183
+
184
+ We apply Theorem 1 to two groups of variables: observed $(x, l)$ and latent $z$ with $h(x, l) = h(x|l)p(l), \nu(x, l) = x$ and $\psi(z) = z$ . It follows that the consistent joint family is
185
+
186
+ $$
187
+ p (x, l, z) = h (x, l) \exp \left(x ^ {\mathsf {T}} W z + a ^ {\mathsf {T}} x + b ^ {\mathsf {T}} z + c\right). \tag {15}
188
+ $$
189
+
190
+ This however implies that $g(x) = Wx + b$ , i.e. the encoder network must be linear in $x$ . Consequently, it cannot match a function of word frequencies $x / l$ (as chosen by design) unless $W = 0$ , i.e. a completely trivial model with an encoder not depending on $x$ . Such an encoder would imply full posterior collapse. The corresponding consistent set $\Theta_{\Phi}$ coincides with the set of collapsed VAEs where the decoder does not depend on the latent variable $z$ in Fig. 1. We conjecture that the inherent inconsistency of this VAE has a detrimental effect on learning.
191
+
192
+ If instead, we let the encoder network to access word counts $x$ directly, we obtain that $g(x) = Wx + b$ can form a consistent VAE. Inspecting this encoder model in more detail, we see that it builds up topic confidence in proportion to the evidence (total word counts), as the true posterior would. Indeed, the true posterior $p(z|x,l)$ satisfies the factorization by Bayes's theorem: $p(z|x,l) = p(x|z,l)p(z) / p(x|l)$ . The prior $p(z)$ is constant by design, $p(x|l)$ does not vary with $z$ and $p(x|z,l)$ factors over all word instances according to (13). In other words, the coupling between $x$ and $z$ in $\log p(z|x,l)$ is linear in $x$ .
193
+
194
+ In Section 4 we study the proposed correction experimentally and show that it enables learning better models under a variety of settings.
195
+
196
+ # 4 EXPERIMENTS
197
+
198
+ # 4.1 ARTIFICIAL EXAMPLE
199
+
200
+ To start with, we illustrate our findings on a toy example. We consider a simple Gaussian mixture model for which we can easily generate samples and compute all necessary quantities including the ELBO objective. We define the ground truth model to be $p^*(x,z) = p^*(z)p^*(x|z)$ , with $z \in \{1\ldots 4\}$ , $p^*(z) \equiv 0.25$ , $x \in \mathbb{R}^2$ , $p^*(x|z) = \mathcal{N}(x|\mu(z), \sigma^2I)$ , i.e., a mixture of four 2D Gaussians. Fig. 2(a) shows the color-coded posterior distribution $p^*(z|x)$ . We assign a color to each component and represent $p^*(z|x)$ for each pixel $x \in \mathbb{R}^2$ by the corresponding mixture of the component colors. For better interpretability, we illustrate further results by decision maps $\arg \max_z p(z|x)$ . Fig. 2(b) shows the decision map for $p^*(z|x)$ .
201
+
202
+ ![](images/aac6ae86b9a3b8f356e50b6ae3c953666f17b07a089a59d613e227b64e20969d.jpg)
203
+ (a)
204
+
205
+ ![](images/693fb0dabf07b3faf0c5637939653b3a9e9515d8d6faa6fe85208ec9a4740148.jpg)
206
+ (b)
207
+
208
+ ![](images/e802d5d40a89d5fdbf3fdf097532e5bad26fc755440b7ea030e9e6ba83c2c6ae.jpg)
209
+ (c)
210
+ Figure 2: Artificial example. (a) Color-coded posterior distribution $p^{*}(z|x)$ . (b-e): Decision maps (arg max $_z$ ) of: (b) true posterior $p^{*}(z|x)$ , (c) factorized encoder $q_{\phi}(z|x)$ after joint learning, (d) model posterior $p_{\theta}(z|x)$ after joint learning, (e) RBM trained on the same data. Gaussian centers $\mu(z)$ are shown as black dots. (f) Probability simplex of distributions over the four binary configurations. The vertices correspond to pure (deterministic) binary states represented by the code and its respective color. The surface shows the manifold of factorized distributions realizable by $q(z|x)$ . Notice that the two edges (00, 11) and (01, 10) are not in the manifold because they correspond to switching of two bits simultaneously in a correlated way. The factorized approximation cannot model transitions between these states. Hence, when learning VAE, these pairs of states are repulsed in the decision maps (c), (d).
211
+
212
+ ![](images/5a7cba54a50809d55541fceb13d35679a76951fa691140f45a4ce3d0af263fdc.jpg)
213
+ (d)
214
+
215
+ ![](images/4481a03811fac0748eebecf9e43f79102852acd8f5b277b1a4f9cbc54d44f68f.jpg)
216
+ (e)
217
+
218
+ ![](images/cd09b15a4bc775eeb6a0ef091d8df91a52c7e266063ba61d6079cb573e057b98.jpg)
219
+ (f)
220
+
221
+ The aim of the experiment is to learn a VAE and to study the influence of the factorization assumption on the results. We use the decoder architecture as in the ground truth model — a Gaussian distribution $p_{\theta}(x|z) = \mathcal{N}(x|\theta z_{oh},\sigma^2 I)$ , where $z_{oh}$ is the one-hot (categorical) representation of $z$ , and $\theta$ is a $2\times 4$ matrix that maps the four latent codes to 2D centers at general locations. Note that the ground truth model is contained in the chosen decoder family. Hence, the ML solution is the ground truth decoder $p^{*}(x|z)$ . We restrict the encoder to factor over the binary representation of the code $z_{b}\in \{0,1\}^{2}$ and define it as $q_{\phi}(z_b|x)\propto \exp \langle g_{\phi}(x),z_b\rangle$ , where $g_{\phi}(x)$ is implemented as a feed-forward network with two hidden layers, each with 64 units and ReLU activations.
222
+
223
+ First, we pre-train our factorized encoder by optimizing ELBO and keeping the ground truth decoder fixed. The next step is to jointly train the encoder and decoder by maximizing ELBO. Since we are interested in how the ELBO objective distorts the likelihood solution, we start with the ground truth decoder and the pre-trained encoder from the previous step. The ELBO-optimal decoder has to match not only the training data, but also the inexact, factorizing encoder. The resulting $q_{\phi}(z|x)$ is shown in Fig. 2(c) and the learned model posterior $p_{\theta}(z|x) \propto p(z)p_{\theta}(x|z)$ in Fig. 2(d). Note that they match each other pretty well, but differ substantially from the ground truth posterior shown in Fig. 2(b). The impact of the factorization is clearly visible – one can see two decision boundaries (one for each bit of $z_b$ ), which together partition the $x$ -space into four regions, approximating the true posterior. For comparison, Fig. 2(e) shows the posterior of an RBM trained on the same data. It is clearly seen that the ELBO optimizer is pulled away from the likelihood optimizer towards an RBM solution. Notice also the explanation given in Fig. 2(f). Summarizing, this simple toy example clearly shows the VAE approximation error caused by the combination of ELBO objective and the factorization assumption for the encoder. While the numerical difference between ELBO and log-likelihood is small (see details in Appendix C.1), the qualitative difference in Fig. 2 appears substantial.
224
+
225
+ # 4.2 GAUSSIAN VAES FOR CELEBA IMAGES
226
+
227
+ The goal and design of this experiment is similar to the previous one. We first define a ground truth decoder which is used to generate training images. Then we pre-train an encoder by ELBO keeping the ground truth decoder fixed. Finally, we train both model parts starting from the ground truth decoder and the pre-trained encoder.
228
+
229
+ The ground truth generative model is obtained by training a convolutional Generative Adversarial network (GAN) using code of Inkawich (2017) on the CelebA dataset Liu et al. (2015). We scale and crop all images to $64 \times 64$ pixels. In order to get a stochastic decoder, we equip the GAN generator $x = d(z)$ , $z \in \mathbb{R}^{100}$ , $x \in \mathbb{R}^{64 \times 64 \times 3}$ with image noise $\sigma_d$ . The ground truth generative model is thus defined as $p^*(x, z) = p^*(z)p^*(x|z)$ , where $p^*(z) = \mathcal{N}(z|0, I)$ , $p^*(x|z) = \mathcal{N}(x|\mu_d(z), \sigma_d^2 I)$ , and $\sigma_d^2$ is a common noise variance for all pixels and color channels. We chose $\sigma_d = 0.05$ (the color values are normalized to $[-1, 1]$ ). This corresponds to an image noise level, which is just visible, but does not disturb visual perception essentially.
230
+
231
+ ![](images/08703bef01db1edeb23b5cb2b3f3d6470d78fc089f706452255825a3384a475b.jpg)
232
+ Figure 3: Results for the encoder learned by supervised conditional likelihood. Top row: training samples $\hat{x} \sim p^{*}(x)$ . Second row: the corresponding reconstructions from mean values of $z$ , i.e. $x \sim p^{*}(x|\mu_{e}(\hat{x}))$ . Third row: reconstructions from sampled $z$ , i.e. $\hat{z} \sim \mathcal{N}(\mu_{e}(\hat{x}), \sigma_{e}^{2}(\hat{x}))$ followed by $x \sim p^{*}(x|\hat{z})$ .
233
+
234
+ ![](images/56df18bb5474682fc42ae19f22cd67d40032a85a3f73cb05ece9708a92afeace.jpg)
235
+ Figure 4: Visual comparison - images drawn from the original/learned models. Each column corresponds to a particular value of $z \sim \mathcal{N}(0, I)$ . Top row: the ground truth model, middle row: learned decoder with fixed $\sigma_d$ , bottom row: decoder with learned $\sigma_d$ .
236
+
237
+ The decoder family of the considered VAE consists of networks with the same architecture as $d(z)$ . This ensures that the ground truth decoder is a likelihood maximizer of the VAE model. The encoder is defined as $q_{\phi}(z|x) = \mathcal{N}(x|\mu_e(x),\mathrm{diag}(\sigma_e^2 (x)))$ , where $\mu_{e},\sigma_{e}\in \mathbb{R}^{100}$ are two outputs of a convolutional neural network with an architecture similar to the architecture of the discriminator used for training the GAN (except the output layer), i.e., $q_{\phi}(z|x)$ is a multivariate Gaussian with diagonal covariance matrix whose parameters depend on $x$ .
238
+
239
+ We pre-train the encoder fully supervised by maximizing its conditional log-likelihood $\mathbb{E}_{p^{*}(x,z)}\log q_{\phi}(z|x)$ on examples drawn from the ground truth generating model $p^* (x,z)$ . The results of pre-training are shown in Fig. 3. Then we jointly learn the encoder and decoder by maximizing ELBO on $x$ -samples drawn from the ground truth model. We start the learning with the ground truth decoder $p^* (x|z)$ and the encoder obtained in the previous step. Two variants are considered for this training: (i) keeping the image noise $\sigma_{d}$ fixed and (ii) learning it along with other model parameters. We evaluate the results quantitatively by computing the Frechet Inception Distances (FID) between the ground truth model $p^* (x|z)$ and the obtained decoders $p_{\theta}(x|z)$ using the code of Seitzer (2020). For this we generate 200k images from each model. The obtained values are given in Tab. 1. Fig. 4 shows images generated by the ground truth model and the two learned models.
240
+
241
+ To conclude, ELBO optimization harms the decoder considerably as clearly seen both from FID-scores and the generated images. Models with higher ELBO values have worse FID-scores and produce less realistic images.
242
+
243
+ Table 1: Optimizing the ELBO starting from the ML solution degrades the FID-score. The first row corresponds to the pre-trained encoder for the ground truth decoder, its FID-score therefore compares two image sets, both generated by the ground truth model.
244
+
245
+ <table><tr><td>Experiment</td><td>ELBO</td><td>FID</td></tr><tr><td>optimize encoder (conditional likelihood)</td><td>-364513.78</td><td>0.13</td></tr><tr><td>optimize encoder and decoder (ELBO, fixed σd)</td><td>-5898.94</td><td>77.10</td></tr><tr><td>optimize encoder and decoder (ELBO, learned σd)</td><td>9035.69</td><td>117.87</td></tr></table>
246
+
247
+ # 4.3 BERNOULLI VAE FOR TEXT DOCUMENTS
248
+
249
+ This experiment compares training of the VAE model for semantic hashing discussed in Section 3.1 with and without our proposed correction on the 20Newsgroups dataset (Lang & Rennie, 2008). We describe the dataset, preprocessing and optimization details in Appendix C.2.
250
+
251
+ We compare three encoders: e1: linear encoder on word counts (the proposed correction), e2: deep (2 hidden layers) encoder using word frequencies and e3: a linear encoder on frequencies. The
252
+
253
+ encoders are compared across different numbers of latent Bernoulli variables (bits) and different decoder depths. The decoder depth denotes the number of fully connected hidden ReLU layers (0-2). In both the encoder and decoder we use 512 units in hidden layers. The prior work mainly used linear decoders following the ablation study of Shen et al. (2018). Our experiments also suggest that using deep decoders in combination with longer bit-length leads to a significant overfitting. When the decoder is linear, the posterior distribution is tractable and is linear as well, i.e., the VAE model is equivalent to a Multinomial-Bernoulli RBM. We experimentally verify that a linear encoder on word counts e1 indeed works better in this case. However, perhaps more surprisingly, we also find out that it works better even for non-linear decoders.
254
+
255
+ Table 2 show the achieved training and test Negative ELBO (NELBO) values. We observe across all settings that the simple encoder e1 is consistently better than the more complex encoder e2 which in turn is significantly better than the linear encoder on frequencies e3. We conclude that the use of VAEs with deep encoders based on word frequencies (Chaidaroon & Fang, 2017; Shen et al., 2018; Zamani Dadaneh et al., 2020; Nanculef et al., 2020) is sub-optimal for this dataset. We also observe that linear decoders generalize better under 32 and 64 bits compared to more complex decoders, which suffer from overfitting. This implies that in these cases the best encoder-decoder combination is linear, i.e. the basic RBM model. This evidence agrees with previously observed worse reconstruction error with deep architecture (Dai et al., 2020), however we did not observe (a more severe) posterior collapse with deeper models amongst the depths we report.
256
+
257
+ Table 2: Training and test NELBO values for Text-VAE with different configurations of bits, decoder and encoder. Bold highlights the best encoder choice and underlined bold values are the best decoder-encoder combinations for each bit-length.
258
+
259
+ <table><tr><td colspan="10">TRAINING</td><td colspan="9">TEST</td><td></td></tr><tr><td rowspan="2">Bits</td><td colspan="3">dhidden=0</td><td colspan="3">dhidden=1</td><td colspan="3">dhidden=2</td><td rowspan="2">Bits</td><td colspan="3">dhidden=0</td><td colspan="3">dhidden=1</td><td colspan="3">dhidden=2</td></tr><tr><td>e1</td><td>e2</td><td>e3</td><td>e1</td><td>e2</td><td>e3</td><td>e1</td><td>e2</td><td>e3</td><td>e1</td><td>e2</td><td>e3</td><td>e1</td><td>e2</td><td>e3</td><td>e1</td><td>e2</td><td>e3</td></tr><tr><td>8</td><td>419</td><td>429</td><td>439</td><td>321</td><td>390</td><td>415</td><td>325</td><td>370</td><td>421</td><td>8</td><td>423</td><td>429</td><td>435</td><td>413</td><td>421</td><td>424</td><td>418</td><td>423</td><td>427</td></tr><tr><td>16</td><td>382</td><td>398</td><td>419</td><td>201</td><td>329</td><td>407</td><td>164</td><td>269</td><td>413</td><td>16</td><td>409</td><td>417</td><td>421</td><td>404</td><td>422</td><td>420</td><td>410</td><td>416</td><td>422</td></tr><tr><td>32</td><td>337</td><td>358</td><td>412</td><td>165</td><td>189</td><td>403</td><td>132</td><td>159</td><td>411</td><td>32</td><td>396</td><td>413</td><td>416</td><td>399</td><td>413</td><td>418</td><td>406</td><td>416</td><td>421</td></tr><tr><td>64</td><td>296</td><td>324</td><td>407</td><td>171</td><td>189</td><td>398</td><td>134</td><td>149</td><td>409</td><td>64</td><td>392</td><td>411</td><td>414</td><td>398</td><td>413</td><td>417</td><td>406</td><td>417</td><td>422</td></tr></table>
260
+
261
+ # 5 CONCLUSIONS
262
+
263
+ We have analyzed the approximation error of VAEs in a general setting, when both the decoder and encoder are exponential families. This includes commonly used VAE variants as, e.g., Gaussian VAEs and Bernoulli VAEs. We have shown that the subset of generative models consistent with the encoder class is quite restricted: it coincides with the set of log-bilinear models on the sufficient statistics of both decoder and encoder, i.e., RBM-like models. This consistent subset can not be enlarged by using more complex encoder networks as long as encoder's sufficient statistics remain unchanged. In combination with the ELBO objective, this causes an approximation error — the ELBO optimizer is pulled away from the data likelihood optimizer towards this subset. Moreover, we proved theoretically that close-to-tight EF VAEs must be close to RBMs in a certain sense.
264
+
265
+ We have shown that the error is detrimental when the consistent subset is too restrictive. In the cases where a lot of data is available and a high quality generative model is of the primary interest, such as in the CelebA experiment, more expressive encoder families are required in addition to large networks. On the other hand the VAE approximation error may result in a useful regularization when the respective RBM is a good baseline model. In this case we can speak of a binning inductive bias towards RBM, such as in our text-VAE experiment. Furthermore, simple encoders can be desired when the learned representations are of interest, in particular they appear to facilitate similarity in Hamming distance, useful in the semantic hashing problem.
266
+
267
+ Further connections to related work and discussion can be found in Appendix B.
268
+
269
+ # ACKNOWLEDGMENT
270
+
271
+ D.S. was supported by the German Federal Ministry of Education and Research (BMBF, 01/S18026A-F) by funding the competence center for Big Data and AI "ScaDS.AI Dresden/Leipzig". A.S and B.F gratefully acknowledge support by the Czech OP VVV project "Research Center for Informatics" (CZ.02.1.01/0.0/0.0/16019/0000765)". B.F. was also supported by the Czech Science Foundation, grant 19-09967S. The authors gratefully acknowledge the Center for Information Services and HPC (ZIH) at TU Dresden for providing computing time. We thank the anonymous reviewers for many helpful links and suggestions.
272
+
273
+ # REFERENCES
274
+
275
+ B. C. Arnold and D. J. Strauss. Bivariate distributions with conditionals in prescribed exponential families. Journal of the Royal Statistical Society Series B (Methodological), 53(2):365-375, 1991.
276
+ Barry C. Arnold, Enrique Castillo, and Jose Maria Sarabia. Conditionally specified distributions: An introduction. Statistical Science, 16(3):249 - 274, 2001.
277
+ Yuri Burda, Roger Grosse, and Ruslan Salakhutdinov. Accurate and conservative estimates of MRF log-likelihood using reverse annealing. In AISTATS, volume 38, pp. 102-110, 09-12 May 2015.
278
+ Yuri Burda, Roger B. Grosse, and Ruslan Salakhutdinov. Importance weighted autoencoders. In ICLR, 2016.
279
+ Suthee Chaidaroon and Yi Fang. Variational deep semantic hashing for text documents. In SIGIR Conference on Research and Development in Information Retrieval, pp. 75-84, 2017.
280
+ Chris Cremer, Xuechen Li, and David Duvenaud. Inference suboptimality in variational autoencoders. In ICML, volume 80, pp. 1078-1086, 2018.
281
+ Bin Dai and David Wipf. Diagnosing and enhancing VAE models. In ICLR, 2019.
282
+ Bin Dai, Yu Wang, John Aston, Gang Hua, and David Wipf. Connections with robust PCA and the role of emergent sparsity in variational autoencoder models. Journal of Machine Learning Research, 19(41):1-42, 2018.
283
+ Bin Dai, Ziyu Wang, and David Wipf. The usual suspects? Reassessing blame for VAE posterior collapse. In ICML, 2020.
284
+ Junxian He, Daniel Spokoyny, Graham Neubig, and Taylor Berg-Kirkpatrick. Lagging inference networks and posterior collapse in variational autoencoders. In *ICLR*, 2019.
285
+ Devon Hjelm, Russ R Salakhutdinov, Kyunghyun Cho, Nebojsa Jojic, Vince Calhoun, and Junyoung Chung. Iterative refinement of the approximate posterior for directed belief networks. In Advances in Neural Information Processing Systems, volume 29, pp. 4691-4699, 2016.
286
+ Nathan Inkawich. DCGAN tutorial, 2017. URL https://pytorch.org/tutorials/beginner/dcgan_faces_tutorial.html.
287
+ Yoon Kim, Sam Wiseman, Andrew Miller, David Sontag, and Alexander Rush. Semi-amortized variational autoencoders. In ICML, volume 80, pp. 2678-2687, 2018.
288
+ Diederik P Kingma and Max Welling. Auto-encoding variational bayes. In ICLR, 2014.
289
+ Diederik P. Kingma, Danilo J. Rezende, Shakir Mohamed, and Max Welling. Semi-supervised learning with deep generative models. In Proceedings of the 27th International Conference on Neural Information Processing Systems - Volume 2, NIPS'14, pp. 3581-3589, Cambridge, MA, USA, 2014. MIT Press.
290
+ Diederik P Kingma, Tim Salimans, Rafal Jozefowicz, Xi Chen, Ilya Sutskever, and Max Welling. Improved variational inference with inverse autoregressive flow. In NeurIPS, volume 29, pp. 4743-4751, 2016.
291
+
292
+ Ken Lang and Jason Rennie. The 20 newsgroups dataset, 2008. http://qwone.com/~jason/20Newsgroups/.
293
+ Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaou Tang. Deep learning face attributes in the wild. In Proceedings of International Conference on Computer Vision (ICCV), December 2015.
294
+ James Lucas, George Tucker, Roger B Grosse, and Mohammad Norouzi. Don't blame the ELBO! a linear VAE perspective on posterior collapse. In NeurIPS, volume 32, pp. 9408-9418, 2019.
295
+ Lars Maalø e, Marco Fraccaro, Valentin Lievin, and Ole Winther. BIVA: A very deep hierarchy of latent variables for generative modeling. In NeurIPS, volume 32, 2019.
296
+ Pierre-Alexandre Mattei and Jes Frellsen. MIWAE: Deep generative modelling and imputation of incomplete data sets. In ICML, volume 97, pp. 4413-4423, 09-15 Jun 2019.
297
+ Ricardo Nanculef, Francisco Alejandro Mena, Antonio Macaluso, Stefano Lodi, and Claudio Sartori. Self-supervised Bernoulli autoencoders for semi-supervised hashing. CoRR, abs/2007.08799, 2020.
298
+ Sebastian Nowozin. Debiasing evidence approximations: On importance-weighted autoencoders and jackknife variational inference. In International Conference on Learning Representations, 2018.
299
+ Rajesh Ranganath, Dustin Tran, and David Blei. Hierarchical variational models. In ICML, volume 48, pp. 324-333, 20-22 Jun 2016.
300
+ Danilo Rezende and Shakir Mohamed. Variational inference with normalizing flows. In ICML, volume 37, pp. 1530-1538, 2015.
301
+ Danilo Jimenez Rezende, Shakir Mohamed, and Daan Wierstra. Stochastic backpropagation and approximate inference in deep generative models. In ICML, 2014.
302
+ Ruslan Salakhutdinov and Geoffrey Hinton. Semantic hashing. Int. J. Approx. Reasoning, 50(7): 969-978, July 2009.
303
+ Maximilian Seitzer. pytorch-fid: FID Score for PyTorch. https://github.com/mseitzer/pytorch-fid, August 2020. Version 0.1.1.
304
+ Dinghan Shen, Qinliang Su, Paidamoyo Chapfuwa, Wenlin Wang, Guoyin Wang, Ricardo Henao, and Lawrence Carin. NASH: Toward end-to-end neural architecture for generative semantic hashing. In Annual Meeting of the Association for Computational Linguistics, pp. 2041-2050, jul 2018.
305
+ Rui Shu, Hung H Bui, Shengjia Zhao, Mykel J Kochenderfer, and Stefano Ermon. Amortized inference regularization. In NeurIPS, volume 31, 2018.
306
+ Robert Sicks, Ralf Korn, and Stefanie Schwaar. A generalised linear model framework for $\beta$ -variational autoencoders based on exponential dispersion families. CoRR, 2021.
307
+ Casper Kaae Sønderby, Tapani Raiko, Lars Maaløe, Søren Kaae Sønderby, and Ole Winther. Ladder variational autoencoders. In Advances in Neural Information Processing Systems, volume 29, pp. 3738-3746, 2016.
308
+ Hiroshi Takahashi, Tomoharu Iwata, Yuki Yamanaka, Masanori Yamada, and Satoshi Yagi. Student-t variational autoencoder for robust density estimation. In *IJCAI*, pp. 2696-2702, 7 2018.
309
+ R. E. Turner and M. Sahani. Two problems with variational expectation maximisation for time-series models. In Bayesian Time series models, chapter 5, pp. 109-130. 2011.
310
+ Arash Vahdat and Jan Kautz. Nvae: A deep hierarchical variational autoencoder. In NeurIPS, volume 33, pp. 19667-19679, 2020.
311
+ Arash Vahdat, Evgeny Andriyash, and William Macready. Undirected graphical models as approximate posteriors. In ICML, volume 119, pp. 9680-9689, 13-18 Jul 2020.
312
+
313
+ Max Welling, Michal Rosen-Zvi, and Geoffrey E Hinton. Exponential family harmoniums with an application to information retrieval. In NeurIPS, volume 17, 2005.
314
+ Mingzhang Yin and Mingyuan Zhou. ARM: Augment-REINFORCE-merge gradient for stochastic binary networks. In ICLR, 2019.
315
+ Siamak Zamani Dadaneh, Shahin Boluki, Mingzhang Yin, Mingyuan Zhou, and Xiaoning Qian. Pairwise supervised hashing with Bernoulli variational auto-encoder and self-control gradient estimator. In UAI, volume 124, pp. 540-549, 2020.
316
+
317
+ # Appendix
318
+
319
+ # A PROOFS
320
+
321
+ # A.1 PROOF OF THEOREM 1
322
+
323
+ The proof directly follows from the characterization of conditionally specified joint distributions in the exponential family given by Arnold & Strauss (1991), see (Arnold et al., 2001, Theorem 3):
324
+
325
+ Theorem A.1 (Arnold & Strauss 1991). Let $x \in \mathcal{X}$ and $z \in \mathcal{Z}$ be random variables with a strictly positive joint distribution such that both conditional distributions are exponential families with densities
326
+
327
+ $$
328
+ p (x \mid z) = h (x) \exp [ \langle \nu (x), f (z) \rangle - A (z) ] \tag {16a}
329
+ $$
330
+
331
+ $$
332
+ p (z \mid x) = h ^ {\prime} (z) \exp [ \langle \psi (z), g (x) \rangle - B (x) ], \tag {16b}
333
+ $$
334
+
335
+ where $\nu : \mathcal{X} \to \mathbb{R}^n$ and $\psi : \mathcal{Z} \to \mathbb{R}^m$ are minimal sufficient statistics, $f : \mathcal{Z} \to \mathbb{R}^n$ and $g : \mathcal{X} \to \mathbb{R}^m$ are any mappings, $h(x)$ and $h'(z)$ are base measures, and $A$ and $B$ denote the respective log-partition functions<sup>4</sup>.
336
+
337
+ Then there exists a matrix $W \in \mathbb{M}(n + 1, m + 1)$ , such that the density of the joint distribution can be represented as
338
+
339
+ $$
340
+ p (x, z) = h (x) h ^ {\prime} (z) \exp \left\langle \nu_ {e} (x), W \psi_ {e} (z) \right\rangle , \tag {17}
341
+ $$
342
+
343
+ where $\nu_{e},\psi_{e}$ denote the statistics vectors extended with an additional component 1.
344
+
345
+ # A.2 EXAMPLE OF A DISCRETE VAE APPROACHING A FLOW
346
+
347
+ Example A.1. In this example we construct a VAE that can be arbitrary close to tight one, but where the decoder network does not approach a linear map. Let $\mathcal{X} = \{-1,1\}^2$ , $\mathcal{Z} = \{-1,1\}^2$ and let $p(z)$ be uniform. Let the decoder be conditionally independent
348
+
349
+ $$
350
+ p (x \mid z) = \exp \left[ \beta \langle x, \pi (z) \rangle - A (z) \right] \tag {18}
351
+ $$
352
+
353
+ where $\pi (z)$ denotes the invertible mapping of $\mathcal{Z}$ to $\mathcal{X}$ given by
354
+
355
+ $$
356
+ x _ {1} = z _ {1} \tag {19}
357
+ $$
358
+
359
+ $$
360
+ x _ {2} = z _ {1} z _ {2}. \tag {20}
361
+ $$
362
+
363
+ If the parameter $\beta$ is sufficiently large, the distribution $p(x|z)$ approaches the deterministic distribution $\delta_{x = \pi (z)}$ . Its posterior therefore also approaches the deterministic distribution $\delta_{z = \pi^{-1}(x)}$ (notice that $\pi^{-1} = \pi$ ). Let the encoder be the conditionally independent model $q(z|x) = \exp \bigl [\beta \langle z,\pi^{-1}(x)\rangle -A(x)\bigr ]$ . This decoder by design approaches $\delta_{x = \pi (z)}$ as well and thus the VAE $(p,q)$ achieves $\varepsilon$ -tightness for sufficiently large $\beta$ . At the same time the deviation between logarithms of probabilities $\log q(z|x)$ and $\log p(z|x)$ grows with $\beta$ .
364
+
365
+ # A.3 PROOF OF THEOREM 2
366
+
367
+ The idea of the proof is to bound the difference between $\log p(z|x)$ and $\log q(z|x)$ , which is done by Proposition A.2 and then in the space of log-probabilities to approximate the non-linear mapping $f_{e}(z)$ by a linear one as detailed in Proposition A.1. By carefully choosing the norms and the approximation we obtain a bound on the error for the joint model, which despite the discreteness assumption of the observation space $\mathcal{X}$ in Theorem 2 does not depend on its cardinality.
368
+
369
+ For a finite set $X \subset \mathcal{X}$ let $\mathcal{H}$ be the $|X|$ -dimensional vector space with the inner product $\langle u, v \rangle_{p_d} = \sum_{x \in X} p_d(x) u(x) v(x)$ , assuming that $p_d(x) > 0$ for all $x \in \mathcal{X}$ . The respective norm will be denoted as $\| \cdot \|_{p_d}$ .
370
+
371
+ Proposition A.1. Under model Assumption 1, for any finite $X \subseteq \mathcal{X}$ there exists a matrix $W \in \mathbb{M}(n + 1, m + 1)$ such that joint distribution implied by the decoder $p(x,z) = p(x|z)p(z)$ can be approximated by an unnormalized EF Harmonium
372
+
373
+ $$
374
+ \tilde {p} (x, z) = h (x) h ^ {\prime} (z) \exp \left(\left\langle \nu_ {e} (x), W \psi_ {e} (z) \right\rangle\right) \tag {21}
375
+ $$
376
+
377
+ with the error bound
378
+
379
+ $$
380
+ \left(\forall z\right) \sum_ {x \in X} p _ {d} (x) \left| \log p (x, z) - \log \tilde {p} (x, z) \right| ^ {2} \leq \sum_ {x \in X} p _ {d} (x) \left| \log q (z | x) - \log p (z | x) \right| ^ {2}. \tag {22}
381
+ $$
382
+
383
+ The function $\tilde{p}(x,z)$ is non-negative but does not necessarily satisfy the normalization constraint of a density.
384
+
385
+ Proof. For clarity, we will omit the dependence of the decoder and encoder on their parameters $\theta$ , resp. $\phi$ . Throughout the proof we will also assume that a single $z \in \mathcal{Z}$ is fixed.
386
+
387
+ First, we expand
388
+
389
+ $$
390
+ \log q (z \mid x) = \langle \psi (z), g (x) \rangle - B (x) + \log h ^ {\prime} (z); \tag {23a}
391
+ $$
392
+
393
+ $$
394
+ \begin{array}{l} \log p (z \mid x) = \log p (x \mid z) + \log p (z) - \log p (x) \\ = \left\langle \nu (x), f (z) \right\rangle - A (z) + \log h (x) + \log p (z) - \log p (x), \tag {23b} \\ \end{array}
395
+ $$
396
+
397
+ where $A(z) = A(f(z))$ and $B(x) = B(g(x))$ . We can therefore represent
398
+
399
+ $$
400
+ \begin{array}{l} \log q (z \mid x) - \log p (z \mid x) = \left\langle \psi (z), g (x) \right\rangle - B (x) + \log p (x) - \log h (x) (24) \\ - \left(\langle \nu (x), f (z) \rangle + \log p (z) - \log h ^ {\prime} (z) - A (z)\right) (25) \\ = \left\langle \psi_ {e} (z), g _ {e} (x) \right\rangle - \left\langle \nu_ {e} (x), f _ {e} (z) \right\rangle , (26) \\ \end{array}
401
+ $$
402
+
403
+ where
404
+
405
+ $$
406
+ \psi_ {e} (z) = (\psi (z), 1); \tag {27}
407
+ $$
408
+
409
+ $$
410
+ \nu_ {e} (x) = (\nu (x), 1); \tag {28}
411
+ $$
412
+
413
+ $$
414
+ g _ {e} (x) = (g (x), \log p (x) - B (x) - \log h (x)); \tag {29}
415
+ $$
416
+
417
+ $$
418
+ f _ {e} (z) = (f (z), \log p (z) - A (z) - \log h ^ {\prime} (z)). \tag {30}
419
+ $$
420
+
421
+ With this representation we have:
422
+
423
+ $$
424
+ \begin{array}{l} \left. \sum_ {x \in X} p _ {d} (x) \mid \langle \nu_ {e} (x), f _ {e} (z) \rangle - \langle \psi_ {e} (z), g _ {e} (x) \rangle \right| ^ {2} (31) \\ = \sum_ {x \in X} p _ {d} (x) | \log q (z | x) - \log p (z | x) | ^ {2} =: \Delta^ {2}. (32) \\ \end{array}
425
+ $$
426
+
427
+ Let $V$ be the matrix with rows $\nu_{e}(x)$ for all $x \in X$ . Let $G$ be the matrix with rows $g_{e}(x)$ for all $x \in X$ . We can rewrite the condition (31) in the form
428
+
429
+ $$
430
+ \xi = V f _ {e} (z) - G \psi_ {e} (z), \tag {33a}
431
+ $$
432
+
433
+ $$
434
+ \left\| \xi \right\| _ {p _ {d}} ^ {2} = \Delta^ {2}, \tag {33b}
435
+ $$
436
+
437
+ where $\xi \in \mathbb{R}^{|X|}$ is the vector of residuals. Let $P$ be the orthogonal projection onto the range of $V$ in the space $\mathcal{H}$ . Multiplying (33a) by $P$ on the left, we obtain
438
+
439
+ $$
440
+ P V f _ {e} (z) - P G \psi_ {e} (z) = P \xi . \tag {34}
441
+ $$
442
+
443
+ Because $PV = V$ we obtain
444
+
445
+ $$
446
+ V f _ {e} (z) - P G \psi_ {e} (z) = P \xi . \tag {35}
447
+ $$
448
+
449
+ We therefore can consider the decoder network approximation $\tilde{f}_e(z) = \tilde{W}\psi_e(z)$ , where $\tilde{W}$ is the solution to the consistent system of linear equations $V\tilde{W} = PG$ and is independent of $z$ . We can therefore express
450
+
451
+ $$
452
+ \left\| V f _ {e} (z) - V \bar {f} _ {e} (z) \right\| _ {p _ {d}} = \| P \xi \| _ {p _ {d}} \leq \| \xi \| _ {p _ {d}} = \Delta , \tag {36}
453
+ $$
454
+
455
+ where the inequality holds because $P$ is an orthogonal projection in $\mathcal{H}$ .
456
+
457
+ We obtained that the decoder network $f_{e}(z)$ can be approximated by a linear mapping $\tilde{W}\psi_{e}(z)$ such that
458
+
459
+ $$
460
+ \left. \sum_ {x \in X} p _ {d} (x) \mid \langle \nu_ {e} (x), f _ {e} (z) \rangle - \langle \nu_ {e} (x), \tilde {W} \psi_ {e} (z) \rangle \right| ^ {2} \leq \Delta^ {2}. \tag {37}
461
+ $$
462
+
463
+ Expressing back
464
+
465
+ $$
466
+ \begin{array}{l} \left\langle \nu_ {e} (x), f _ {e} (z) \right\rangle = \left\langle \nu (x), f (z) \right\rangle + \log p (z) - A (z) - \log h ^ {\prime} (z) (38a) \\ = \log p (x \mid z) + \log p (z) - \log h (x) - \log h ^ {\prime} (z) (38b) \\ = \log p (x, z) - \log h (x) - \log h ^ {\prime} (z) (38c) \\ \end{array}
467
+ $$
468
+
469
+ we obtain that
470
+
471
+ $$
472
+ \left. \sum_ {x \in X} p _ {d} (x) \right| \log p (x, z) - \left. \log \tilde {p} (x, z) \right| ^ {2} \leq \Delta^ {2}, \tag {39}
473
+ $$
474
+
475
+ where
476
+
477
+ $$
478
+ \log \tilde {p} (x, z) = \log h (x) + \log h ^ {\prime} (z) + \left\langle \nu_ {e} (x), W \psi_ {e} (z) \right\rangle . \tag {40}
479
+ $$
480
+
481
+ ![](images/ee1ecc020290a71e9d6d68efcf1171bad0e850de54af7e05464cb7e1cd2f9c4e.jpg)
482
+
483
+ Proposition A.2. Under model Assumption 1, let $\mathcal{X}$ and $\mathcal{Z}$ be discrete (finite) sets and let $z\in \mathcal{Z}$ be chosen. If $q(z|x)\geq \alpha$ and $p(z|x)\geq \alpha$ for all $x\in X$ , where $X\subseteq \mathcal{X}$ and
484
+
485
+ $$
486
+ \mathbb {E} _ {p _ {d} (x)} \left[ D _ {\mathrm {K L}} \left(q (z \mid x) \| p (z \mid x)\right) \right] \leq \varepsilon , \tag {41}
487
+ $$
488
+
489
+ then
490
+
491
+ $$
492
+ \sum_ {x \in X} p _ {d} (x) (\log p (z | x) - \log q (z | x)) ^ {2} \leq \frac {\varepsilon}{\alpha^ {2}} + o (\varepsilon). \tag {42}
493
+ $$
494
+
495
+ Proof. Let us denote $\varepsilon(x) = D_{\mathrm{KL}}(q(z|x) \| p(z|x))$ . Pinsker's inequality assures for each $x$
496
+
497
+ $$
498
+ \sup _ {S \subset \mathcal {Z}} | \mathbb {P} _ {q (z \mid x)} (S) - \mathbb {P} _ {p (z \mid x)} (S) | ^ {2} \leq \varepsilon (x) / 2. \tag {43}
499
+ $$
500
+
501
+ Substituting $S = \{z\}$ we obtain
502
+
503
+ $$
504
+ \left| p (z \mid x) - q (z \mid x) \right| ^ {2} \leq \varepsilon (x) / 2. \tag {44}
505
+ $$
506
+
507
+ By taking expectation in $p_d(x)$ on both sides we obtain a variant of Pinsker's inequality:
508
+
509
+ $$
510
+ \mathbb {E} _ {p _ {d} (x)} | p (z | x) - q (z | x) | ^ {2} \leq \mathbb {E} _ {p _ {d} (x)} \varepsilon (x) / 2 = \frac {1}{2} \mathbb {E} _ {p _ {d} (x)} \left[ D _ {\mathrm {K L}} \left(q (z | x) \| p (z | x)\right) \right] \leq \varepsilon / 2. \tag {45}
511
+ $$
512
+
513
+ Notice that the LHS depends on the given $z$ . Because all summands are non-negative it follows that
514
+
515
+ $$
516
+ \forall X ^ {\prime} \subseteq \mathcal {X} \quad \sum_ {x \in X ^ {\prime}} p _ {d} (x) | p (z | x) - q (z | x) | ^ {2} \leq \varepsilon / 2. \tag {46}
517
+ $$
518
+
519
+ This inequality will be used in several places below.
520
+
521
+ Consider $x \in X$ such that $p(z|x) > q(z|x)$ . Then
522
+
523
+ $$
524
+ \begin{array}{l} \left| \log p (z | x) - \log q (z | x) \right| ^ {2} = \log^ {2} \frac {p (z | x)}{q (z | x)} (47a) \\ = \log^ {2} (1 + \frac {p (z | x) - q (z | x)}{q (z | x)}) (47b) \\ \leq \log^ {2} (1 + \frac {p (z \mid x) - q (z \mid x)}{\alpha}), (47c) \\ \end{array}
525
+ $$
526
+
527
+ where the inequality holds because $\log^2$ is monotonously increasing for arguments greater equal than 1, which is ensured. Let us now consider $x\in X$ such that $p(z|x) < q(z|x)$ . Then
528
+
529
+ $$
530
+ \begin{array}{l} \left| \log p (z | x) - \log q (z | x) \right| ^ {2} = \log^ {2} \frac {q (z | x)}{p (z | x)} (48a) \\ = \log^ {2} (1 + \frac {q (z | x) - p (z | x)}{p (z | x)}) (48b) \\ \leq \log^ {2} (1 + \frac {q (z | x) - p (z | x)}{\alpha}). (48c) \\ \end{array}
531
+ $$
532
+
533
+ In total, we obtain
534
+
535
+ $$
536
+ \left| \log p (z | x) - \log q (z | x) \right| ^ {2} \leq \log^ {2} \left(1 + \frac {\left| p (z | x) - q (z | x) \right|}{\alpha}\right). \tag {49}
537
+ $$
538
+
539
+ Let us denote $u(x) = \frac{|p(z|x) - q(z|x)|}{\alpha}$ and partition the set $X$ into two parts:
540
+
541
+ $$
542
+ X _ {1} = \{x \in X \mid u (x) < u _ {0} \} \tag {50a}
543
+ $$
544
+
545
+ $$
546
+ X _ {2} = \{x \in X \mid u (x) \geq u _ {0} \}, \tag {50b}
547
+ $$
548
+
549
+ where we chose $u_0 \in [\sqrt{e - 1}, 5]$ for reasons to be clarified below. For both parts, i.e. $k = 1, 2$ , we have
550
+
551
+ $$
552
+ \sum_ {x \in X _ {k}} p _ {d} (x) | \log q (z | x) - \log p (z | x) | ^ {2} \leq \sum_ {x \in X _ {k}} p _ {d} (x) \log^ {2} \left(1 + \frac {| p (z | x) - q (z | x) |}{\alpha}\right). \tag {51}
553
+ $$
554
+
555
+ For $X_{1}$ (51) can be further bounded as
556
+
557
+ $$
558
+ \leq \sum_ {x \in X _ {1}} p _ {d} (x) \log \left(1 + \frac {\left| p (z | x) - q (z | x) \right| ^ {2}}{\alpha^ {2}}\right) \tag {52a}
559
+ $$
560
+
561
+ $$
562
+ \leq \log \sum_ {x \in X _ {1}} p _ {d} (x) \left(1 + \frac {\left| p (z | x) - q (z | x) \right| ^ {2}}{\alpha^ {2}}\right) \tag {52b}
563
+ $$
564
+
565
+ $$
566
+ = \log \left(p _ {d} \left(X _ {1}\right) + \frac {1}{\alpha^ {2}} \sum_ {x \in X _ {1}} p _ {d} (x) | p (z | x) - q (z | x) | ^ {2}\right) \tag {52c}
567
+ $$
568
+
569
+ $$
570
+ \leq \log \left(1 + \frac {\varepsilon}{2 \alpha^ {2}}\right) = \frac {\varepsilon}{2 \alpha^ {2}} + o (\varepsilon), \tag {52d}
571
+ $$
572
+
573
+ where the first inequality holds for $u_0 \leq 5$ , because in this case $\log^2 (1 + u) \leq \log (1 + u^2)$ holds, the second inequality is the Jensen's inequality for $\log$ and the last inequality uses (46) under monotone log.
574
+
575
+ For $X_{2}$ we have the following. Let $V = p_{d}(X_{2}) = \sum_{x\in X_{2}}p_{d}(x)$ . We can express
576
+
577
+ $$
578
+ \sum_ {x \in X _ {2}} p _ {d} (x) \log^ {2} \left(1 + \frac {\left| p (z | x) - q (z | x) \right|}{\alpha}\right) \tag {53a}
579
+ $$
580
+
581
+ $$
582
+ = V \left(\sum_ {x \in X _ {2}} p _ {d} (x \mid X _ {2}) \log^ {2} \left(1 + \frac {\left| p (z \mid x) - q (z \mid x) \right|}{\alpha}\right)\right) \tag {53b}
583
+ $$
584
+
585
+ Using that $u < u^2$ on $X_2$ and that $\log^2(1 + u)$ is monotone for a positive argument, we can bound (53b) as
586
+
587
+ $$
588
+ \leq V \left(\sum_ {x \in X _ {2}} p _ {d} (x \mid X _ {2}) \log^ {2} \left(1 + \frac {\left| p (z \mid x) - q (z \mid x) \right| ^ {2}}{\alpha^ {2}}\right)\right). \tag {54}
589
+ $$
590
+
591
+ Further, using that $\log^2 (1 + v)$ is concave on $X_{2}$ for $v\geq e - 1$ , we have
592
+
593
+ $$
594
+ \leq V \log^ {2} \left(\sum_ {x \in X _ {2}} p _ {d} (x \mid X _ {2}) \left(1 + \frac {\left| p (z \mid x) - q (z \mid x) \right| ^ {2}}{\alpha^ {2}}\right)\right) \tag {55a}
595
+ $$
596
+
597
+ $$
598
+ = V \log^ {2} \left(1 + \sum_ {x \in X _ {2}} p _ {d} (x \mid X _ {2}) \frac {\left| p (z \mid x) - q (z \mid x) \right| ^ {2}}{\alpha^ {2}}\right) \tag {55b}
599
+ $$
600
+
601
+ $$
602
+ \leq V \log^ {2} \left(1 + \frac {\varepsilon}{2 \alpha^ {2} V}\right), \tag {55c}
603
+ $$
604
+
605
+ where in the last step we used (46).
606
+
607
+ Next we show that $V$ itself is bounded above by $\frac{\varepsilon}{2u_0^2\alpha^2}$ . It follows from
608
+
609
+ $$
610
+ u _ {0} ^ {2} V = \sum_ {x \in X _ {2}} p _ {d} (x) u _ {0} ^ {2} \leq \sum_ {x \in X _ {2}} p _ {d} (x) \frac {\left| p (z | x) - q (z | x) \right| ^ {2}}{\alpha^ {2}} \leq \sum_ {x \in X} p _ {d} (x) \frac {\left| p (z | x) - q (z | x) \right| ^ {2}}{\alpha^ {2}} \leq \frac {\varepsilon}{2 \alpha^ {2}}, \tag {56}
611
+ $$
612
+
613
+ where the last inequality is again (46).
614
+
615
+ Now, letting $r = \frac{\varepsilon}{2\alpha^2V} \geq u_0^2 \geq 1$ we can bound (55c) as follows
616
+
617
+ $$
618
+ \begin{array}{l} V \log^ {2} \left(1 + \frac {\varepsilon}{2 \alpha^ {2} V}\right) = \frac {\varepsilon}{2 \alpha^ {2}} \frac {1}{r} \log^ {2} (1 + r) (57a) \\ \leq \frac {\varepsilon}{2 \alpha^ {2}} \sup _ {r \geq 1} \frac {1}{r} \log^ {2} (1 + r) \leq \frac {\varepsilon}{2 \alpha^ {2}} 0. 6 4. (57b) \\ \end{array}
619
+ $$
620
+
621
+ ![](images/ff4171ab2fd2bb29248eb0e60f161ff0d956b04b60e0593bfe22e1d1fa5820ac.jpg)
622
+
623
+ Theorem 2 follows by Proposition A.2 and Proposition A.1 with the choice $X = \mathcal{X}$
624
+
625
+ # B DISCUSSION
626
+
627
+ In this section we discuss further connections to related work and some open questions.
628
+
629
+ Cremer et al. (2018) showed experimentally that using a more expressive class of models for the encoder reduces not only the posterior family mismatch but also the amortization error. This observation is compatible with our results: increasing the expressive power of the encoder admits tight VAEs with more complex dependence of $z$ on $x$ . Indeed, increasing the expressive power of the encoder in our setting means extending its sufficient statistics $\psi(z)$ by new components. While it keeps the simple linear dependence $g(x) = W^{\mathsf{T}}\nu(x)$ characterizing tight VAEs, it does lead to a more expressive GLM $p(z|x)$ . Conversely, our results suggest that increasing the complexity of the encoder network in order to reduce the amortization gap is only useful for models that are far from the consistent set. Furthermore, there could be negative impact from increasing the model depth in practice: (Dai et al., 2020) demonstrated that the risk of the learning converging to a suboptimal solution (in particular leading to more collapsed latent dimensions) increases with decoder depth.
630
+
631
+ Lucas et al. (2019) showed that any spurious local minima in linear Gaussian VAEs are entirely due to the marginal log likelihood and that the ELBO does not introduce any new local minima. It is a good question<sup>5</sup> whether something similar can be said about the EF VAE generalization. To our best knowledge this is not straightforward in such a general setting. The result of Lucas et al. (2019) is possible thanks to the fact that for linear Gaussian models ELBO is analytically tractable and its stationary point conditions can be written down and analyzed. In the general EF setup, which includes, e.g., MRF VAEs, this does not appear possible. On the other hand, for any consistent EF VAE, the decoder posterior must be in the EF of the encoder. Therefore the optimal encoder could be easier to find analytically or numerically using forward KL divergence and not the reverse KL divergence used in ELBO, thus circumventing the question about local optima of ELBO. Since ELBO at the optimal encoder is tight for a consistent VAE, this could be an alternative way to find the global maximum.
632
+
633
+ A recent work by Sicks et al. (2021) extends the result of Lucas Lucas et al. (2019) in that they develop an analytical local approximation to ELBO, which is exact in the Gaussian linear model case and is a lower bound on ELBO for Binomial observation model. These results allow to analyze ELBO (and in particular the posterior collapse problem) locally under the assumption that the decoder's mapping $f(z)$ is (locally) an affine mapping of $z$ . Our Theorem 1 implies it must be so globally for tight VAEs in several special cases (e.g., Bernoulli model), while in general it is an affine mapping of $\psi(z)$ . These connections indicate that a better understanding of VAEs can be reached in the setting where either decoder or encoder or both are consistent with the joint model (7).
634
+
635
+ We restricted this study to exponential families. While in richer models discussed in the introduction, the approximation error still exists, it is made small by design, and it is less relevant and harder to analyze it theoretically. One possible open direction where such analysis would make sense is to consider fully factorized non-exponential cases, e.g., Student-t VAEs (Takahashi et al., 2018) or models satisfying hierarchical or partial factorization (Maaløe et al., 2019).
636
+
637
+ # C DETAILS OF EXPERIMENTAL SETUP
638
+
639
+ # C.1 ARTIFICIAL EXAMPLE
640
+
641
+ We give here the achieved likelihood and ELBO values for this experiment. The negative entropy $\sum_{x}p^{*}(x)\log p^{*}(x)$ of the ground truth model, i.e., the best reachable data log-likelihood, is $-3.65$ . The ELBO of the pre-trained VAE is $-3.74$ . During the second step of training, i.e., the joint learning of the encoder and decoder by ELBO maximization, the ELBO value increases from $-3.74$ to $-3.70$ . The data log-likelihood $\sum_{x}p^{*}(x)\log p_{\theta}(x)$ drops at the same time from $-3.65$ to $-3.68$ . The approximation error (2) in the decoder caused by using the factorized encoder is only 0.03 nats, but the qualitative difference between the ground truth model and the ELBO optimizer model shown in Fig. 2 appears detrimental.
642
+
643
+ # C.2 BERNOULLI VAE FOR TEXT DOCUMENTS
644
+
645
+ Dataset In this experiment we used the version of the 20Newsgroups data set (Lang & Rennie, 2008) denoted as "processed" by the authors. The dataset contains bag-of-words representations of documents and is split into a training set with 11269 documents and a test set with 7505 documents. We keep only the 10000 most frequent words in the training set, which is a common pre-processing (each of the omitted words occurs not more than in 10 documents).
646
+
647
+ Optimization To train VAE we used the state-of-the-art unbiased gradient estimator ARM (Yin & Zhou, 2019) and Adam optimizer with learning rate 0.001. We did not use the test set for parameter selection. We train for 1000 epochs using 1-sample ARM and then for 500 more epochs using 10 samples for computing each gradient estimate with ARM. We report the lowest negative ELBO (NELBO) values for the training set and test set during all epochs.
648
+
649
+ Models The decoder model (13) describes words as independent draws from a categorical distribution specified by the neural network $f(z)$ . This network respectively has a structure
650
+
651
+ $$
652
+ \operatorname {L i n e a r} \to \underbrace {\left(\operatorname {R e L U} \to \operatorname {L i n e a r}\right)} _ {\times \text {d h i d d e n}} \to \operatorname {L o g s o f t m a x}.
653
+ $$
654
+
655
+ The input dimension equals to the number of latent bits, the output dimension equals the number of words in the dictionary, 10000. For decoders with dhidden $= 1,2$ the hidden layers contained 512 units.
656
+
657
+ The encoder networks e2, e3 take on the input word frequencies $x / \sum_{k}x_{k}$ , the encoder network e1 takes on input word counts $x$ . For the deep encoder e2 we used 2 hidden ReLU layers with 512 units each.
vaeapproximationerrorelboandexponentialfamilies/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:92cbad5b87c2f4167d06d47f815c73932a49eef783f370892cd0897a4453a9df
3
+ size 675355
vaeapproximationerrorelboandexponentialfamilies/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c4a0474bb059c2a40b8844b839af6066f8869a154a3340a9d4f5b593ff646843
3
+ size 813121
valuegradientweightedmodelbasedreinforcementlearning/9c4cdf72-62f3-4a8d-9611-3d82d5c1330d_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:abac2f814d269170aa776f02fd3bf14089b29a4b4b46d7f986cce5a053c946c5
3
+ size 109153
valuegradientweightedmodelbasedreinforcementlearning/9c4cdf72-62f3-4a8d-9611-3d82d5c1330d_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2df9fdad5af98e7f174f908d43fbebe46458108bff975b276d212ebd4b1bb424
3
+ size 127890
valuegradientweightedmodelbasedreinforcementlearning/9c4cdf72-62f3-4a8d-9611-3d82d5c1330d_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:087e6bda2b837a71d14169f6559fab4260c7e31d807b1f789a803ab7ea4999b2
3
+ size 648390
valuegradientweightedmodelbasedreinforcementlearning/full.md ADDED
@@ -0,0 +1,393 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # VALUE GRADIENT WEIGHTED MODEL-BASED REINFORCEMENT LEARNING
2
+
3
+ Claas A. Voelcker $^{1,2}$ , Victor Liao $^{1,3}$ , Animesh Garg $^{1,2,4}$ , Amir-massoud Farahmand $^{1,2}$
4
+
5
+ $^{1}$ Vector Institute, $^{2}$ University of Toronto, $^{3}$ University of Waterloo, $^{4}$ Nvidia Correspondence to c.voelcker@cs.toronto.edu
6
+
7
+ # ABSTRACT
8
+
9
+ Model-based reinforcement learning (MBRL) is a sample efficient technique to obtain control policies, yet unavoidable modeling errors often lead to performance deterioration. The model in MBRL is often solely fitted to reconstruct dynamics, state observations in particular, while the impact of model error on the policy is not captured by the training objective. This leads to a mismatch between the intended goal of MBRL, enabling good policy and value learning, and the target of the loss function employed in practice, future state prediction. Naive intuition suggests that value-aware model learning would fix this problem and, indeed, several solutions to this objective mismatch problem have been proposed based on theoretical analysis. However, they tend to be inferior in practice to commonly used maximum likelihood (MLE) based approaches. In this paper we propose the Value-Gradient weighted Model loss (VaGram), a novel method for value-aware model learning which improves the performance of MBRL in challenging settings, such as small model capacity and the presence of distracting state dimensions. We analyze both MLE and value-aware approaches and demonstrate how they fail to account for sample coverage and the behavior of function approximation when learning value-aware models. From this, we highlight the additional goals that must be met to stabilize optimization in the deep learning setting. To achieve this, we leverage the gradient of the empirical value function as a measure of the sensitivity of the RL algorithm to model errors. We verify our analysis by showing that our loss function is able to achieve high returns on the Mujoco benchmark suite while being more robust than maximum likelihood based approaches.
10
+
11
+ # 1 INTRODUCTION
12
+
13
+ Model-based Reinforcement Learning (MBRL) is a sample-efficient approach to obtain a policy for a given control problem. It solves the control optimization into two interleaved stages: model learning and planning. In the model learning stage, an approximate model of the environment is learned which is then utilized in the planning stage to generate new experience without having to query the original environment. Often this process is repeated by continuously updating the model with new experience and replanning based on the updated model. MBRL is an enticing paradigm for scenarios in which samples of the true environment are difficult or expensive to obtain, such as computationally intensive simulators, real-world robots, or environments involving humans, since the model can be used to generalize the policy to unseen regions of the state space. The approach has received a lot of attention and significant progress has been made in the field (Sutton, 1990; Deisenroth & Rasmussen, 2011; Levine & Koltun, 2013; Hafner et al., 2020; Moerland et al., 2020; Schrittwieser et al., 2020).
14
+
15
+ One of the core problems of model-based policy learning methods, however, is that the accuracy of the model directly influences the quality of the learned policy or plan (Schneider, 1997; Kearns & Singh, 2002; Ross & Bagnell, 2012; Talvitie, 2017; Luo et al., 2019; Janner et al., 2019). Model errors tend to accumulate over time, and therefore long-term planning under approximate models can lead to suboptimal policies compared to the performance achievable with model-free approaches. This is especially prevalent in settings with complex dynamics, such as robotic environments with discontinuities, which can be hard to model with common function approximation methods. These model approximation errors are nearly impossible to avoid with current methods due to limits of
16
+
17
+ function approximation in model and value learning algorithms, which cannot fully capture the full distribution over dynamics functions perfectly, and the use of finite datasets.
18
+
19
+ Hence, it is important that a model is accurate where it counts for the planning procedure, by modelling dimensions and data points that have a higher impact on the planning. But this objective is not captured in most current MBRL methods, which generally use maximum likelihood estimation (MLE) to learn a parametric model of the environment without involving information from the planning process. The misalignment between the model learning and planning stages of MBRL has recently received renewed interest and is now commonly termed the objective mismatch of reinforcement learning (Lambert et al., 2020), but the problems has been investigated in earlier works (Joseph et al., 2013). Several recent papers have investigated the objective mismatch (Abachi et al., 2020; Zhang et al., 2021; Ayoub et al., 2020; Grimm et al., 2020; 2021; Nikishin et al., 2022), but currently theoretical investigation and understanding of possible approaches do not perform well when applied to complex deep learning based approaches (Lovatto et al., 2020) or the proposed approaches rely on heuristics which might not be applicable generally (Nair et al., 2020).
20
+
21
+ Summary of Contributions. We present the Value-Gradient weighted Model loss (VaGraM) which rescales the mean squared error loss function with gradient information from the current value function estimate. We demonstrate the advantage of the VaGraM loss over previous approaches via the analysis of the optimization behavior of the Value-Aware Model Learning framework (Farahmand et al., 2017; Farahmand, 2018) and form two hypotheses for the lack of empirical performance gain despite theoretical intuition: (a) the theory does not account for the optimization trajectory induced by the loss function and (b) it also does not address how to counter problems that arise when the state-space is yet insufficiently explored in early stages of the model training. Our experiments show, qualitatively and quantitatively, that the VaGraM loss impacts the resulting state and value prediction accuracy, and that it solves the optimization problems of previously published approaches. Beyond pedagogical domains, we show that VaGraM performs on par with a current state-of-the-art MBRL algorithms in more complex continuous control domains, while improving robustness to irrelevant dimensions in the state-space and smaller model sizes.
22
+
23
+ # 2 BACKGROUND
24
+
25
+ We consider the discounted MDP setting $(\mathcal{S},\mathcal{A},p,r,\gamma)$ (Puterman, 1994), where $\mathcal{S}$ denotes the state space, $\mathcal{A}$ the action space of an agent, $p$ is a transition probability kernel, $r:\mathcal{S}\times \mathcal{A}\to \mathbb{R}$ is a scalar reward function, and $\gamma$ denotes the reward discount factor. Following the standard setting of reinforcement learning, the goal is to obtain an agent which maximizes the reward function while interacting with the environment by taking actions after an optimal (potentially stochastic) policy $\pi^{*}$ without knowledge of the true transition kernel.
26
+
27
+ We will concentrate on value function-based methods to solve the reinforcement learning problem. With these, the aim is to learn a function $V_{\pi}:S\to \mathbb{R}$ which represent the (discounted) reward obtained in state $s$ by following policy $\pi$ from there: $V_{\pi}(s) = \mathbb{E}_{(s_0,a_0,\dots)}[\sum_{t = 0}^{\infty}\gamma^t r(s_t,a_t)|s_0 = s]$ . It is also helpful to define an action-value function $Q(s,a) = r(s,a) + \gamma \int p(s'|s,a)V(s')ds'$ . Many approaches (Watkins & Dayan, 1992; Mnih et al., 2013; Wang et al., 2016; Haarnoja et al., 2018) try to learn this function by minimizing the deviations of the value function approximation to a bootstrap target: $\min_{\phi}\mathbb{E}\left[(Q_{\phi}(s,a) - (r(s,a) + \gamma \int p(s'|s,a)V(s')\mathrm{d}s'))^{2}\right]$ . This equation forms the core motivation for our investigation of MBRL.
28
+
29
+ # 2.1 MODEL-BASED REINFORCEMENT LEARNING
30
+
31
+ In the MBRL framework, an approximate model $\hat{p}$ is trained from data to represent the unknown transition function $p$ . We will use the word 'model' to refer to the learned approximation and 'environment' to refer to the unknown MDP transition function.
32
+
33
+ We concentrate on the Dyna algorithm (Sutton, 1990) and specifically investigate the impact of model errors on the planning procedure. Dyna uses a dataset $\mathcal{D}$ of past experiences from the envi
34
+
35
+ ronment $\mathcal{D} = (s_i,a_i,r_i,s_i')_{i = 1}^N$ . A parametric model $\hat{p}_{\theta}$ of the environment is learned by a maximum likelihood estimate using $\mathcal{D}$ : $\theta^{*} = \arg \max_{\theta}\sum_{i = 1}^{N}\log \hat{p}_{\theta}(s_i',r_i|s_i,a_i)$ . This model $\hat{p}_{\theta}$ is then used to sample new next states $s_{\mathrm{model}}'\sim \hat{p}_{\theta}(\cdot |s,a)$ to obtain better coverage of the state-action space. The samples are used to train the value function and policy as if they were samples from the environment. It is also possible to learn deterministic models, which we will denote as $f_{\theta}$ for clarity.
36
+
37
+ # 2.2 KEY INSIGHT: MODEL MISMATCH PROBLEM
38
+
39
+ One of the main drawbacks of model-based reinforcement learning is the fact that model errors propagate and compound when the model is used for planning (Schneider, 1997; Kearns & Singh, 2002; Talvitie, 2017). As a simple example, assume that a sample is collected from a deterministic model and has an error $\epsilon$ . A value function based method will use the model sample to compute a biased bootstrap target $r(s, a) + \gamma V(s' + \epsilon)$ .
40
+
41
+ The impact of the modelling error on the value function therefore depends on the size of the error and the local behavior of the value function. As an extreme example take a value function that only depends on a subset of all state observation dimensions. In this case, a large error in an irrelevant dimension has no consequence on the obtained policy, yet a maximum likelihood loss for the model cannot properly capture this behavior without prior handcrafted features.
42
+
43
+ We can motivate the use of MLE (such as the mean squared error for a Gaussian model with fixed variance) as a loss function by an upper bound: $\sup_{V\in \mathcal{F}}|\langle p - \hat{p},V\rangle |\leq ||p - \hat{p} ||_1\sup_{V\in \mathcal{F}}||V||_\infty \leq$ $\sqrt{\mathrm{KL}(p||\hat{p})}\sup_{V\in \mathcal{F}}||V||_{\infty}$ (Farahmand et al., 2017), but this bound is loose and does not account for the geometry of the problem's value function. In our example above a mean squared error would penalize deviations equally by their $L_{2}$ norm without accounting for the relevance of the dimensions.
44
+
45
+ # 2.3 VALUE-AWARE MODEL LEARNING
46
+
47
+ To address the model mismatch, Farahmand et al. (2017) proposed Value-aware Model Learning (VAML), a loss function that captures the impact the model errors have on the one-step value estimation accuracy. The core idea behind VAML is to penalize a model prediction by the resulting difference in a value function. Given a distribution over the state-action space $\mu$ and a value function $V$ , it is possible to define a value-aware loss function $\mathcal{L}_V(\hat{p}, p, \mu)$ :
48
+
49
+ $$
50
+ \mathcal {L} _ {V} (\hat {p}, p, \mu) = \int \mu (s, a) \left| \overbrace {\int p \left(s ^ {\prime} \mid s , a\right) V \left(s ^ {\prime}\right) \mathrm {d} s ^ {\prime}} ^ {\text {e n v i r o n m e n t v a l u e e s t i m a t e}} - \overbrace {\int \hat {p} \left(s ^ {\prime} \mid s , a\right) V \left(s ^ {\prime}\right) \mathrm {d} s ^ {\prime}} ^ {\text {m o d e l v a l u e e s t i m a t e}} \right| ^ {2} \mathrm {d} (s, a) \tag {1}
51
+ $$
52
+
53
+ and its empirical approximation $\hat{\mathcal{L}}_V$ based on a dataset $D = (s, a, s')_{i=1}^{N}$ of samples from $\mu$ and $p$ :
54
+
55
+ $$
56
+ \hat {\mathcal {L}} _ {V} (\hat {p}, \mathcal {D}) = \sum_ {(s _ {i}, a _ {i}, s _ {i} ^ {\prime}) \in \mathcal {D}} \left| V \left(s _ {i} ^ {\prime}\right) - \int (\hat {p} \left(s ^ {\prime} \mid s _ {i}, a _ {i}\right)) V \left(s ^ {\prime}\right) d s ^ {\prime} \right| ^ {2}. \tag {2}
57
+ $$
58
+
59
+ It is worth noting that if the loss $\mathcal{L}_V$ is zero for a given model, environment and corresponding value function, then estimating the bootstrap target based on the model will result in the exact same update as if the environment were used. However, this is rarely the case in practice!
60
+
61
+ The main problem of this approach is that it relies on the value function, which is not known a priori while learning the model. In the original formulation by Farahmand et al. (2017), the value function is replaced with the supremum over a function space. While this works well in the case of linear value function spaces, finding a supremum for a function space parameterized by complex function approximators like neural networks is difficult. Furthermore, the supremum formulation is conservative and does not account for the fact that knowledge about the value function is gained over the course of exploration and optimization in a MBRL approach.
62
+
63
+ Instead of the supremum over a value function class, Farahmand (2018) introduced a modification of VAML called Iterative Value-Aware Model Learning (IterVAML), where the supremum is replaced with the current estimate of the value function, . In each iteration, the value function is updated based on the model, and the model is trained using the loss function based on the last iteration's value function. The author presents error bounds for both steps of the iteration, but did not test
64
+
65
+ the algorithm to ascertain whether the presented error bounds are sufficient to guarantee a strong algorithm in practice. Notably IterVAML provides an intuitive fix to the model-mismatch problem, yet overlooks two key optimization issues which lead to empirical ineffectiveness.
66
+
67
+ # 3 VALUE-GRADIENT WEIGHTED MODEL LOSS (VAGRAM)
68
+
69
+ We present Value-Gradient weighted Model loss (VaGraM), a loss which is value-aware and has stable optimization behavior even in challenging domains with function approximation. To motivate the loss function, we highlight two causes for the lack of empirical improvements of IterVAML over MLE based approaches. These phenomena are investigated and verified in detail in section 4.
70
+
71
+ Value function evaluation outside of the empirical state-action distribution IterVAML suffers when randomly initialized models predict next states that are far away from the current data distribution or if the optimization procedure leads the model's prediction outside of the covered state space. Since the value function has only been trained on the current data distribution, it will not have meaningful values at points outside of its training set. Nonetheless, these points can still achieve small value prediction errors if, due to the optimization process, the value function outside the training distribution happens to have the same value at the model prediction as at the environment sample. We therefore require that our value-aware loss function should not directly depend on the value function at the model prediction, since these might be potentially meaningless.
72
+
73
+ Suboptimal local minima Since the model can converge to a solution that is far away from the environment sample if the values are equal, we find that the model-based value prediction often performs poorly after updating the value function. We expect that the updated model loss forces the model prediction to a new solution, but due to the non-convex nature of the VAML loss, the model can get stuck or even diverge. This is especially prevalent when the previous minimum is situated outside of the empirically covered state space. A stable value-aware loss function should therefore have only one minimum in the state space $^2$ that lies within the empirical state distribution.
74
+
75
+ # 3.1 APPROXIMATING A VALUE-AWARE LOSS WITH THE VALUE FUNCTION GRADIENT
76
+
77
+ To derive a loss function that fulfils these requirements, we start from the assumption that the difference between the model prediction and the environment next states $s'$ are small. This is implicitly required by many MBRL approaches, since an MLE model cannot be used to estimate the next state's value otherwise. We also assume that the model has small transition noise, akin to the model assumptions underlying MSE regression, otherwise the difference between a model sample and the next state sample might be large. Under this assumption, the IterVAML loss can be approximated by a Taylor expansion of the value function, where we denote the expansion of $V$ around a reference point $s'$ as $\hat{V}_{s'}$ and obtain $\hat{V}_{s'}(s) \approx V(s') + (\nabla_s V(s)|_{s'})^\top (s - s')$ . Using this expansion at the next state sample $s_i' \in \mathcal{D}$ collected from the environment for each tuple independently instead of the original value function, the VAML error can be stated as:
78
+
79
+ $$
80
+ \begin{array}{l} \hat {\mathcal {L}} _ {\hat {V}} = \sum_ {\left\{s _ {i}, a _ {i}, s _ {i} ^ {\prime} \right\} \in \mathcal {D}} \left(V \left(s _ {i} ^ {\prime}\right) - \int \hat {p} _ {\theta} \left(s ^ {\prime} \mid s _ {i}, a _ {i}\right) \left(V \left(s _ {i} ^ {\prime}\right) + \left(\nabla_ {s} V (s) \mid_ {s _ {i} ^ {\prime}}\right) ^ {\intercal} \left(s ^ {\prime} - s _ {i} ^ {\prime}\right)\right) \mathrm {d} s ^ {\prime}\right) ^ {2} (3) \\ = \sum_ {\left\{s _ {i}, a _ {i}, s _ {i} ^ {\prime} \right\} \in \mathcal {D}} \left(\int \hat {p} _ {\theta} \left(s ^ {\prime} \mid s _ {i}, a _ {i}\right) \left(\left(\nabla_ {s} V (s) \mid_ {s _ {i} ^ {\prime}}\right) ^ {\intercal} \left(s ^ {\prime} - s _ {i} ^ {\prime}\right)\right) d s ^ {\prime}\right) ^ {2} (4) \\ \end{array}
81
+ $$
82
+
83
+ This objective function crucially does not depend on the value function at unknown state samples, all $s_i'$ are in the dataset the value function is trained on, which solves the first of our major problems with the VAML paradigm.
84
+
85
+ We can simplify the objective above even further if we restrict ourselves to deterministic models of the form $\hat{s}_i' = f_\theta(s, a)$ . Since VAML requires the expectation of the value function under the model
86
+
87
+ ![](images/7bbbd2ab04f36d125213f73952a0f470379e7043bcd4a7321664238b500ac6af.jpg)
88
+ Figure 1: Visualization of discussed loss function with regards to a reference point marked with the white cross and the corresponding value function on the Pendulum environment. For the value function, darker color indicates a lower value. In the loss figures, darker color indicates how large the loss is if the model predicts $(\theta ,\dot{\theta})$ instead of the reference sample marked in white. The VAML loss has a complex non-linear shape in the state space that follows isolines of the value function, while MSE and VaGraM are centered around the sample. For VaGraM, the rescaling of the MSE in the direction of high gradient along the $\theta$ axis is visible. Due to Equation 7, the scaling is aligned with the axis of the coordinate system and not rotated to fit the value function closer.
89
+
90
+ and the environment to be equal, we can exchange the probabilistic model with a deterministic one as long as we assume that the mean value function under the true environment is close to the empirical estimate of the value function from a single sample. We explore the prerequisites and consequences of this assumption further in Appendix F. The model loss can then be expressed as:
91
+
92
+ $$
93
+ \sum_ {i} \left(\left(\nabla_ {s} V (s) \mid_ {s _ {i} ^ {\prime}}\right) ^ {\intercal} \left(f _ {\theta} \left(s _ {i}, a _ {i}\right) - s _ {i} ^ {\prime}\right)\right) ^ {2} \tag {5}
94
+ $$
95
+
96
+ We can see that the objective is similar to a mean squared error regression with a vector that defines the local geometry of the objective function. This vector can be interpreted as a measure of sensitivity of the value function at each data point and dimension. In regions where the value function changes significantly, the regression incentivizes the model to be very accurate.
97
+
98
+ # 3.2 PREVENTING SPURIOUS LOCAL MINIMA
99
+
100
+ The formulation above retains one problem, Equation 5 does not constrain the solution for each $(s,a,s')$ tuple sufficiently. For each $(s,a,s')$ tuple, the loss function only requires that the difference between the model and environment sample be orthogonal to the gradient of the value function, which describes a hyperplane of solutions. These predictions can lie arbitrarily far away from the environment sample, which breaks the assumption underlying the Taylor approximation that the model prediction is within a small region of the expanded state point. For more details see Appendix A.
101
+
102
+ To prevent these suboptimal solutions and achieve our second design goal, we consider an upper bound on the value-gradient loss by applying the Cauchy Schwartz inequality $\left(\sum_{i=1}^{n} x_i\right)^2 \leq n \sum x_i^2$ to change the square of the sum with a sum of squares. We denote the diagonal matrix with vector $a$ on the diagonal as $\operatorname{diag}(a)$ and refer to the dimensionality of the state space as $\dim(S)$ and rephrase the sum as a vector-matrix multiplication:
103
+
104
+ $$
105
+ \begin{array}{l} \sum_ {\left\{s _ {i}, a _ {i}, s _ {i} ^ {\prime} \right\} \in \mathcal {D}} \left(\left(\nabla_ {s} V (s) \mid_ {s _ {i} ^ {\prime}}\right) ^ {\top} \left(f _ {\theta} \left(s _ {i}, a _ {i}\right) - s _ {i} ^ {\prime}\right)\right) ^ {2} (6) \\ \leq \dim (\mathcal {S}) \sum_ {\left\{s _ {i}, a _ {i}, s _ {i} ^ {\prime} \right\} \in \mathcal {D}} \left(\left(f _ {\theta} \left(s _ {i}, a _ {i}\right) - s _ {i} ^ {\prime}\right) ^ {\mathsf {T}} \operatorname {d i a g} \left(\nabla_ {s} V (s) \mid_ {s _ {i} ^ {\prime}}\right) ^ {2} \left(f _ {\theta} \left(s _ {i}, a _ {i}\right) - s _ {i} ^ {\prime}\right)\right). (7) \\ \end{array}
106
+ $$
107
+
108
+ This reformulation is equivalent to a mean squared error loss function with a per-sample diagonal scaling matrix. Because the scaling matrix is positive semi-definite by design, each summand in the loss is a quadratic function with a single solution as long as the derivative of the value function does not become zero in any component. Therefore this upper bound assures our second requirement: the loss function does not admit spurious local minima.<sup>3</sup>
109
+
110
+ ![](images/9223162e24b9abdc5fabc46d1edc9728fe9b9039311dedb8125e42c65b009083.jpg)
111
+ Figure 2: Evolution of the VAML loss over changing value functions on the Pendulum domain. Lines denote the mean and shaded areas show standard error over 8 model initialization and data set samples per model. In the linear setting, VAML achieves the lowest VAML error, while VaGraM is able to significantly outperform MSE. In the NN setting, VAML diverges rapidly, while VaGraM and MSE converge to approximately the same solution.
112
+
113
+ ![](images/56eab754379466719841c58bcee28822d347df94d1e990a9c13ad30922a0b096.jpg)
114
+
115
+ To give an intuitive insight into all the discussed loss functions, we visualized each one for a pedagogical environment, the Pendulum stabilization task. The resulting loss curves can be seen in Figure 1. The VAML loss has a complicated shape that depends on the exact values of the value function while both MSE and our proposal have a paraboloid shape. Compared to MSE, our proposed loss function is rescaled to account for the larger gradient of the value function in the $\theta$ axis.
116
+
117
+ # 4 EXPERIMENT: MODEL LEARNING IN LOW-DIMENSIONAL PROBLEM
118
+
119
+ We compare the performance of VaGraM, with both MSE and VAML on a pedagogical environment with a small state space and smooth dynamics to gain qualitative insight into the loss surfaces. We use the Pendulum environment, a canonical control problem in which an under-actuated pendulum must be swung and stabilized to an upright position. We use the implementation provided by Brockman et al. (2016). To learn the policy and its value function, we use the SAC algorithm (Haarnoja et al., 2018). The original IterVAML paper assumed that the value function was obtained using approximate value iteration (AVI) (Gordon, 1995; Ernst et al., 2005; Farahmand et al., 2010). We use SAC instead of a full AVI for stability in large scale experiments and discuss a proper extension of the VAML loss to SAC in Appendix C. We find that the difference in loss is negligible and therefore use SAC together with VAML throughout our experiments. More information on the implementation and hyperparameters of all of our experiments can be found in Appendix E.
120
+
121
+ To simplify the setup of the evaluation, we decided to investigate the model losses without model-based value function learning. This allows us to focus solely on the loss functions, without taking into account the inter-dependency between model and value function updates. Instead of the model-based loop, we used the SAC algorithm in a model-free setup to estimate the value function. We saved the intermediate value functions after each epoch of training, corresponding to 200 environment steps, and optimized the models using stochastic gradient descent on the respective loss function, updating the value function used for the loss every 1000 model training steps. As the MLE loss, we used the mean squared error which assumes a Gaussian model with fixed variance.
122
+
123
+ To compare the optimization, we used two architectures, a linear regression without feature transformations and a neural network with a single hidden layer and 16 neurons. We sampled a dataset uniformly over the whole state space and used the environment transition function to compute ground truth next state samples. Finally, we evaluated each models VAML error with regards to the current value function on a held out dataset and plotted the results in Figure 2.
124
+
125
+ Dependency on untrained value function estimates. The first cause for lacking empirical performance with VAML that we discussed in section 3 was that the algorithm can move outside of the covered state space region where the value function prediction is often meaningless.
126
+
127
+ ![](images/cb6b7a28c6771f81edd1478e8d7404a9ddd8e40878604796b715befcdd024184.jpg)
128
+ Figure 3: Performance of VaGraM and MLE models with reduced model size. The dotted lines correspond to the final performance reported for model-free SAC (grey, approx. 3200). Shaded area represents standard error over 16 repeated runs. VaGraM continues to solve the task almost unimpeded, while MLE is unable to even stabilize the Hopper when using a two layer neural network.
129
+
130
+ In our experiment we find that a linear regression model remains stable under all three loss functions, VaGraM, MSE and VAML. But when using a flexible function approximation, the VAML loss converges in the first iteration with the given value function, but then rapidly diverges once the value function is updated. When investigating the mean squared error of the VAML solution, we find that the model finds a stable minimum of the VAML loss outside of the reachable state space of the pendulum. This confirms our hypothesis that flexible VAML models can find solutions outside of the empirical state space distribution, which are unstable once we update the value function. VaGraM remains stable even with flexible function approximation and achieves a lower VAML error than the MSE baseline when using a model with insufficient capacity to represent the dynamics.
131
+
132
+ Single solution convergence. In the experiment, we see that the MSE and VaGraM models converge to a similar solution when using a neural network. This leads us to the conclusion that our loss function really only admits a single solution and that this solution coincides with the mean square error prediction when the function approximation has sufficient capacity to model the dynamics function with high precision. On the other hand, the VAML network converges to solutions that are far away from the environment sample measured in the $L_{2}$ norm and it cannot recover from these spurious minima due to the complex optimization landscape.
133
+
134
+ # 5 EXPERIMENT: MODEL-BASED CONTINUOUS CONTROL
135
+
136
+ Due to the limited complexity of the pendulum environment, the quantitative differences between the mean squared error and VaGraM are at times insignificant in this setting. The dynamics function of the environment can be approximated sufficiently well with a simple neural network and one hidden layer.
137
+
138
+ The underlying theory supporting VAML states that a value-aware loss is preferable to a mean squared error loss in a setting where the capacity of the model is too small to fully approximate the problem or the state space contains dimensions that are irrelevant for the control problem. To test whether our loss function is superior to a maximum likelihood approach in these cases, we used the Hopper environment from the OpenAI gym benchmark (Brockman et al., 2016). As a deep learning based Dyna algorithm, we chose Model-based Policy Optimization (MBPO) (Janner et al., 2019) and ran all of our experiments using the implementation provided by Pineda et al. (2021). We kept the structure of the MBPO algorithm and models and replaced the model loss function with VaGram.
139
+
140
+ # 5.1 HOPPER WITH REDUCED MODEL CAPACITY
141
+
142
+ In the first experiment, we decreased the network size of the used neural network ensemble. Janner et al. (2019) use fully connected neural networks with four hidden layers and 200 neurons per layer.
143
+
144
+ ![](images/743da2f213e1a590cb981f28a5627ac2bdadaea773e1ab6b1ef4fc48e70a6b01.jpg)
145
+ Figure 4: Performance of VaGram and MLE models with distracting state dimensions. The dotted lines correspond to the final performance achieved by both algorithms on the Hopper task without distraction (grey, approx. 3200). Shaded area represents standard error over 16 repeated runs. VaGram achieves significantly higher returns than the MLE baseline, especially in the most challenging setting with 15 distracting dimensions.
146
+
147
+ To test the performance of the algorithm under smaller models, we ran tests with two and three layer networks and 64 neurons per hidden layer. The results are shown in Figure 3. As before, when using a sufficiently powerful function approximation, we see no difference between the maximum likelihood approach and VaGram, suggesting that the networks are flexible enough to capture the true environment's dynamics sufficiently close for planning. But when reducing the model size, the maximum likelihood models quickly lose performance, completely failing to even stabilize the Hopper for a short period in the smallest setting, while VaGram retains almost its original performance.
148
+
149
+ # 5.2 HOPPER WITH DISTRACTING DIMENSIONS
150
+
151
+ To show that VaGraM is able to achieve good performance in a setting where there are additional dynamics in the environment that do not contribute to the control problem, we appended distractor dimensions to the Hopper observations. These are independent of the original environment state space and reward function, and evolve under non-linear and discontinuous dynamics (details in Appendix E). A setting with distracting dimensions is known to pose difficulty for model-based control algorithms (Stone et al., 2021) and neural networks struggle to model non-linear, discontinuous dynamics, so with an increasing number of dimensions the task becomes harder.
152
+
153
+ The results of this experiment are shown in Figure 4. When using five distractor dimensions, both models are able to capture the dynamics sufficiently well to achieve comparable reward to the original environment. When increasing the number of dimensions, the performance of the MLE model deteriorates, as more and more of its capacity is used to model the added dynamics. VaGram continues to be able to achieve reward even under the presence of distracting dimensions, since the gradient of the value function with regards to the state dimensions which are irrelevant to the control problem becomes small over training. Still, the performance of VaGram also suffers with increasing dimensions: when adding 20 distracting dimensions, neither algorithm is able to stabilize the Hopper consistently. In this case, the value function approximation cannot differentiate sufficiently between the relevant and irrelevant dimensions with the amount of environment samples provided.
154
+
155
+ In summary, we find that VaGram is able to deal with challenging distractions and reduced model capacity significantly better than a MLE baseline. This validates that our algorithm is really value-aware and can use the value function information to improve the performance of a model-based controller in settings where the model is unable to fully represent the environment.
156
+
157
+ # 6 RELATED WORK
158
+
159
+ Several authors have noted on the problem of learning models that align with the goal of obtaining a good policy. The proposed approaches fall into three broad categories: value-function or policy dependency, representation learning, and data resampling.
160
+
161
+ Inspired by VAML, Abachi et al. (2020) present a method that seeks to align the policy gradients under a learned model with the gradients under the true environment. Similar to our proposal, D'Oro et al. (2020) also proposed to reweigh samples in a log likelihood loss, but used policy search as the reinforcement learning approach and did not account for individual state dimensions. Nikishin et al. (2022) show an approach to directly optimizing the policy performance on the real environment by learning a model with implicit differentiation. Asadi et al. (2018) show that the original VAML loss coincides with a Wasserstein distance in the model space under the assumption that the value function is Lipschitz smooth. We find that all of these approaches suffer from similar scaling issues as VAML and have not been shown to lead to strong empirical performance outside of toy settings.
162
+
163
+ Grimm et al. (2020) characterize the space of possible solutions to the model learning problem under different restrictions given by value functions and policies, and propose to learn models that are value-equivalent, similar to Farahmand et al. (2017). In a follow-up work Grimm et al. (2021) expand on this idea and show that their principle can be used to improve the MuZero algorithm (Schrittwieser et al., 2020). However, these works do not discuss the optimization challenges in actually finding such value-equivalent models, they mostly characterize the space under different value functions and policies, and present an orthogonal research direction to this paper.
164
+
165
+ An alternative to characterizing the problem in the state space of the MDP are representation learning approaches, which seek to map the original states to a latent representation that is more amenable to control. Such approaches include Value Prediction Networks (Oh et al., 2017), Embed-to-Control (Watter et al., 2015) and related proposals (Levine et al., 2020; Cui et al., 2021). Zhang et al. (2021) build on the idea of bisimulation metrics (Ferns et al., 2004; 2011) which seeks to characterize the difference between MDPs by finding a state mapping that is reward-invariant under policy and value function. In this work, we did not investigate learning state embeddings, but combining our work with representation learning approaches is an exciting direction for future research.
166
+
167
+ Lambert et al. (2020) hypothesize that the objective mismatch could be solved by reweighing the training buffer for model learning to prioritize datapoints with high value. These are more likely to matter for obtaining an optimal policy. A similar proposal was evaluated empirically by Nair et al. (2020). Contrary to our work however, this technique cannot account for the differing impact of the state space dimensions and scaling, since the data points are weighted as a whole.
168
+
169
+ # 7 CONCLUSION
170
+
171
+ We presented the Value-Gradient weighted Model loss (VaGraM), a novel loss function to train models that model a dynamics function where it matters for the control problem. We derived our loss function from the value-aware model learning framework, showing that previous work does not account for two important optimization phenomena that appear when learning models with empirical value function approximations. We highlighted how VaGraM counters these issues and showed the increased stability of the training procedure when using our loss in a pedagogical environment.
172
+
173
+ On the Mujoco benchmark, VaGraM performs on par with maximum likelihood estimation when using large neural network models. However, introducing additional complications to the problem results in drastic performance impacts for MLE based models, which highlights the necessity for value function aware losses in challenging environments and settings in which sufficient model capacity cannot be guaranteed. In these cases, value-awareness can greatly increase the performance of Dyna algorithms by focusing the model learning procedure on relevant aspects of the state space. In future work we seek to scale our loss function to image-based RL, where relevant state space dimensions can vary over a task due to shifting camera angles. Furthermore, we seek to derive a related value-aware approach for partially observable domains that can take the state inference problem into account.
174
+
175
+ # ETHICAL CONCERNS AND LIMITATIONS
176
+
177
+ The proposed value-aware model learning approach is designed as a general purpose solution to the model mismatch problem in MBRL. While the reinforcement learning paradigm as a whole has important ethical ramifications, especially in settings where automated decision making affects humans directly, we do not address these concerns specifically in our paper as our method focuses on algorithmic problems that are orthogonal to the question of proper reward design. We restrict our proposal to cases in which the reward design actually captures the intended task, which is a common, yet rarely addressed, assumption in the RL literature.
178
+
179
+ # REPRODUCIBILITY
180
+
181
+ We provide an open-source version of our code at https://github.com/pairlab/vagram. Furthermore we document all details on the implementation and evaluation setting in Appendix E and describe all necessary components of our loss in the main text. We also used the open source MBRL-Lib implementation for MBPO (Pineda et al., 2021) as the basis for our code and for the evaluation of baselines and provide our model loss as an additional module in the framework for easy replication.
182
+
183
+ # ACKNOWLEDGMENTS
184
+
185
+ AG and AMF acknowledge the funding from the Canada CIFAR AI Chairs program, as well as the support of the Natural Sciences and Engineering Research Council of Canada (NSERC) through the Discovery Grant program. AG is also supported by the University of Toronto XSeed, LG and Huawei. We thank the members of the PAIR lab and AMF group for feedback on the paper and help with running the experiments. We are grateful to the anonymous reviewers for their constructive feedback and the valuable rebuttal discussion. Resources used in preparing this research were provided, in part, by the Province of Ontario, the Government of Canada through CIFAR, and companies sponsoring the Vector Institute.
186
+
187
+ # REFERENCES
188
+
189
+ Romina Abachi, Mohammad Ghavamzadeh, and Amir-massoud Farahmand. Policy-aware model learning for policy gradient methods. ArXiv, abs/2003.00030, 2020.
190
+ Kavosh Asadi, Evan Cater, Dipendra Misra, and Michael L Littman. Equivalence between wasserstein and value-aware loss for model-based reinforcement learning. *ArXiv*, abs/1806.01265, 2018.
191
+ Alex Ayoub, Zeyu Jia, Csaba Szepesvari, Mengdi Wang, and Lin F. Yang. Model-based reinforcement learning with value-targeted regression. In International Conference on Machine Learning, 2020.
192
+ Greg Brockman, Vicki Cheung, Ludwig Pettersson, Jonas Schneider, John Schulman, Jie Tang, and Wojciech Zaremba. Openai gym. ArXiv, abs/1606.01540, 2016.
193
+ Brandon Cui, Yinlam Chow, and Mohammad Ghavamzadeh. Control-aware representations for model-based reinforcement learning. In International Conference on Learning Representations, 2021.
194
+ Marc Deisenroth and Carl E Rasmussen. Pilco: A model-based and data-efficient approach to policy search. In International Conference on Machine Learning, 2011.
195
+ Pierluca D'Oro, Alberto Maria Metelli, Andrea Tirinzoni, Matteo Papini, and Marcello Restelli. Gradient-aware model-based policy search. In AAAI Conference on Artificial Intelligence, 2020.
196
+ Damien Ernst, Pierre Geurts, and Louis Wehenkel. Tree-based batch mode reinforcement learning. Journal of Machine Learning Research, 6:503-556, 2005.
197
+ Amir-massoud Farahmand. Iterative value-aware model learning. In Advances in Neural Information Processing Systems, volume 31, 2018.
198
+ Amir-massoud Farahmand, Csaba Szepesvári, and Rémi Munos. Error propagation for approximate policy and value iteration. Advances in Neural Information Processing Systems, 2010.
199
+ Amir-massoud Farahmand, André Barreto, and Daniel Nikovski. Value-Aware Loss Function for Model-based Reinforcement Learning. In International Conference on Artificial Intelligence and Statistics, 2017.
200
+ Norm Ferns, Prakash Panangaden, and Doina Precup. Metrics for finite markov decision processes. In Uncertainty in AI, 2004.
201
+ Norm Ferns, Prakash Panangaden, and Doina Precup. Bisimulation metrics for continuous markov decision processes. SIAM Journal on Computing, 40(6), 2011.
202
+ Geoffrey J Gordon. Stable function approximation in dynamic programming. In International Conference on Machine Learning, 1995.
203
+ Christopher Grimm, André Barreto, Satinder Singh, and David Silver. The value equivalence principle for model-based reinforcement learning. In Advances in Neural Information Processing Systems, 2020.
204
+ Christopher Grimm, André Barreto, Gregory Farquhar, David Silver, and Satinder Singh. Proper value equivalence. In Advances in Neural Information Processing Systems, 2021.
205
+ Tuomas Haarnoja, Aurick Zhou, Pieter Abbeel, and Sergey Levine. Soft actor-critic: Off-policy maximum entropy deep reinforcement learning with a stochastic actor. In International Conference on Machine Learning, 2018.
206
+ Danijar Hafner, Timothy Lillicrap, Jimmy Ba, and Mohammad Norouzi. Dream to control: Learning behaviors by latent imagination. In International Conference on Learning Representations, 2020.
207
+ Michael Janner, Justin Fu, Marvin Zhang, and Sergey Levine. When to trust your model: Model-based policy optimization. In Advances in Neural Information Processing Systems, 2019.
208
+
209
+ Joshua Joseph, Alborz Geramifard, John W Roberts, Jonathan P How, and Nicholas Roy. Reinforcement learning with misspecified model classes. In IEEE International Conference on Robotics and Automation, 2013.
210
+ Michael Kearns and Satinder Singh. Near-optimal reinforcement learning in polynomial time. Machine learning, 49(2):209-232, 2002.
211
+ Nathan Lambert, Brandon Amos, Omry Yadan, and Roberto Calandra. Objective mismatch in model-based reinforcement learning. In Conference on Learning for Dynamics and Control, 2020.
212
+ Nir Levine, Yinlam Chow, Rui Shu, Ang Li, Mohammad Ghavamzadeh, and Hung Bui. Prediction, consistency, curvature: Representation learning for locally-linear control. In International Conference on Learning Representations, 2020.
213
+ Sergey Levine and Vladlen Koltun. Guided policy search. In International Conference on Machine Learning, 2013.
214
+ Angelo G. Lovatto, Thiago P. Bueno, Denis D. Mauá, and Leliane N. de Barros. Decision-aware model learning for actor-critic methods: When theory does not meet practice. In "I Can't Believe It's Not Better!" at NeurIPS Workshops, 2020.
215
+ Yuping Luo, Huazhe Xu, Yuanzhi Li, Yuandong Tian, Trevor Darrell, and Tengyu Ma. Algorithmic framework for model-based deep reinforcement learning with theoretical guarantees. In International Conference on Learning Representations, 2019.
216
+ Michael Lutter, Leonard Hasenclever, Arunkumar Byravan, Gabriel Dulac-Arnold, Piotr Trochim, Nicolas Heess, Josh Merel, and Yuval Tassa. Learning dynamics models for model predictive agents. *ArXiv*, abs/2109.14311, 2021.
217
+ Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Alex Graves, Ioannis Antonoglou, Daan Wierstra, and Martin Riedmiller. Playing atari with deep reinforcement learning. In NeurIPS Deep Learning Workshop. 2013.
218
+ Thomas M. Moerland, Joost Broekens, and Catholijn M. Jonker. Model-based reinforcement learning: A survey. ArXiv, abs/2006.16712, 2020.
219
+ Suraj Nair, Silvio Savarese, and Chelsea Finn. Goal-aware prediction: Learning to model what matters. In International Conference on Machine Learning, 2020.
220
+ Evgenii Nikishin, Romina Abachi, Rishabh Agarwal, and Pierre-Luc Bacon. Control-oriented model-based reinforcement learning with implicit differentiation. In AAAI Conference on Artificial Intelligence, 2022.
221
+ Junhyuk Oh, Satinder Singh, and Honglak Lee. Value prediction network. In Advances in Neural Information Processing Systems, 2017.
222
+ Adam Paszke, Sam Gross, Francisco Massa, Adam Lerer, James Bradbury, Gregory Chanan, Trevor Killeen, Zeming Lin, Natalia Gimelshein, Luca Antiga, Alban Desmaison, Andreas Kopf, Edward Yang, Zachary DeVito, Martin Raison, Alykhan Tejani, Sasank Chilamkurthy, Benoit Steiner, Lu Fang, Junjie Bai, and Soumith Chintala. Pytorch: An imperative style, high-performance deep learning library. In Advances in Neural Information Processing Systems 32. 2019.
223
+ Jan Peters and Stefan Schaal. Natural actor-critic. Neurocomputing, 71(7-9):1180-1190, 2008.
224
+ Luis Pineda, Brandon Amos, Amy Zhang, Nathan O. Lambert, and Roberto Calandra. Mbrl-lib: A modular library for model-based reinforcement learning. ArXiv, abs/2104.10159, 2021.
225
+ Martin L. Puterman. Markov decision processes: Discrete stochastic dynamic programming. In Wiley Series in Probability and Statistics, 1994.
226
+ Stéphane Ross and Drew Bagnell. Agnostic system identification for model-based reinforcement learning. In International Conference on Machine Learning, 2012.
227
+ Jeff G Schneider. Exploiting model uncertainty estimates for safe dynamic control learning. In Advances in Neural Information Processing Systems, 1997.
228
+
229
+ Julian Schrittwieser, Ioannis Antonoglou, Thomas Hubert, Karen Simonyan, Laurent Sifre, Simon Schmitt, Arthur Guez, Edward Lockhart, Demis Hassabis, Thore Graepel, et al. Mastering atari, go, chess and shogi by planning with a learned model. Nature, 588(7839):604-609, 2020.
230
+ Austin Stone, Oscar Ramirez, Kurt Konolige, and Rico Jonschkowski. The distracting control suite - a challenging benchmark for reinforcement learning from pixels. ArXiv, abs/2101.02722, 2021.
231
+ Richard S Sutton. Integrated architectures for learning, planning, and reacting based on approximating dynamic programming. In Machine learning Proceedings, pp. 216-224. 1990.
232
+ Erin Talvitie. Self-correcting models for model-based reinforcement learning. In AAAI Conference on Artificial Intelligence, 2017.
233
+ Ziyu Wang, Tom Schaul, Matteo Hessel, Hado Hasselt, Marc Lanctot, and Nando Freitas. *Dueling network architectures for deep reinforcement learning*. In *International Conference on Machine Learning*, 2016.
234
+ Christopher JCH Watkins and Peter Dayan. Q-learning. Machine learning, 8(3-4), 1992.
235
+ Manuel Watter, Jost Tobias Springenberg, Joschka Boedecker, and Martin Riedmiller. Embed to control: A locally linear latent dynamics model for control from raw images. In Advances in Neural Information Processing Systems, 2015.
236
+ Amy Zhang, Rowan Thomas McAllister, Roberto Calandra, Yarin Gal, and Sergey Levine. Learning invariant representations for reinforcement learning without reconstruction. In International Conference on Learning Representations, 2021.
237
+
238
+ # A BOUND BETWEEN VALUE-AWARE MODEL LEARNING AND VALUE-GRADIENT WEIGHTED MODEL LOSS
239
+
240
+ The error in Taylor approximation $\mathcal{R}(V,s',f_{\theta}(s,a))$ is bounded by $\frac{M}{2} ||s' - f_{\theta}(s,a)||^2$ with M dependent on the Hessian of the value function. Plugging this into the VAML loss and assuming worst case approximation errors, we obtain an upper bound on the VAML error:
241
+
242
+ $$
243
+ \mathbb {E} _ {s ^ {\prime}, s, a \sim D} \left[ \left(V \left(f _ {\theta} (s, a)\right) - V \left(s _ {0} ^ {\prime}\right)\right) ^ {2} \right] \tag {8}
244
+ $$
245
+
246
+ $$
247
+ = \mathbb {E} _ {s ^ {\prime}, s, a \sim D} \left[ \left(\left(\nabla_ {s} V (s) \mid_ {s ^ {\prime}}\right) ^ {\intercal} \left(f _ {\theta} (s, a) - s ^ {\prime}\right) + \mathcal {R} \left(V, s ^ {\prime}, f _ {\theta} (s, a)\right)\right) ^ {2} \right] \tag {9}
248
+ $$
249
+
250
+ $$
251
+ \leq \mathbb {E} _ {s ^ {\prime}, s, a \sim D} \left[ \left(\left| \left(\nabla_ {s} V (s) \mid_ {s ^ {\prime}}\right) ^ {\top} \left(f _ {\theta} (s, a) - s ^ {\prime}\right) \right| + \left| \mathcal {R} \left(V, s _ {0} ^ {\prime}, f _ {\theta} (s, a)\right) \right|\right) ^ {2} \right] \tag {10}
252
+ $$
253
+
254
+ $$
255
+ \leq \mathbb {E} _ {s ^ {\prime}, s, a \sim D} \left[ \left(\left| \left(\nabla_ {s} V (s) \mid_ {s ^ {\prime}}\right) ^ {\top} \left(f _ {\theta} (s, a) - s ^ {\prime}\right) \right| + \frac {M}{2} \left\| s ^ {\prime} - f _ {\theta} (s, a) \right\| ^ {2}\right) ^ {2} \right] \tag {11}
256
+ $$
257
+
258
+ $$
259
+ \leq 2 \cdot \mathbb {E} _ {s ^ {\prime}, s, a \sim D} \left[ \left(\left(\nabla_ {s} V (s) | _ {s ^ {\prime}}\right) ^ {\top} \left(f _ {\theta} (s, a) - s ^ {\prime}\right)\right) ^ {2} \right] + 2 \cdot \mathbb {E} _ {s ^ {\prime}, s, a \sim D} \left[ \frac {M ^ {2}}{4} | | s ^ {\prime} - f _ {\theta} (s, a) | | ^ {4} \right] \tag {12}
260
+ $$
261
+
262
+ Our experiments show that if we treat $M$ like a tuneable hyperparameter, we obtain worse performance when optimizing this upper bound compared to VaGraM. The Hessian parameter is difficult to compute or estimate in practice and we find that most often, either the first or the second loss component will dominate when choosing heuristic values.
263
+
264
+ # B ANALYZING THE ADDITIONAL LOCAL MINIMA OF THE TAYLOR APPROXIMATION LOSS
265
+
266
+ We noted in the main paper that the direct Taylor approximation of the value function leads to a spurious local minimum. This is clear when looking at the loss for a single datapoint:
267
+
268
+ $$
269
+ \min _ {\theta} \left(\left(\nabla_ {s} V (s) \mid_ {s ^ {\prime}}\right) ^ {\intercal} f _ {\theta} (s, a)\right) ^ {2} \tag {13}
270
+ $$
271
+
272
+ $$
273
+ = \min _ {\theta} \left(\sum_ {n = 0} ^ {\dim (\mathcal {S})} \left(\nabla_ {s} V (s) | _ {s ^ {\prime}}\right) _ {n} \cdot f _ {\theta} (s, a) _ {n}\right) ^ {2} \tag {14}
274
+ $$
275
+
276
+ Assuming that $f$ is flexible and can predict any next state $s'$ (i.e. by choosing $f = \theta$ ), the optimal solution is obtained from an undetermined linear system of equations. This system admits far more solutions than either the corresponding IterVAML loss or a mean squared error, and many of them will achieve arbitrary large value prediction errors. In fact, the equation describes a hyperplane of minimal solutions consisting of every weight vector that is orthogonal to the gradient of the value function at the reference sample, with $\dim(S) - 1$ free variables. Therefore we need to enforce the closeness of the model prediction and the environment sample, since the Taylor approximation is only approximately valid in a close ball around the reference sample.
277
+
278
+ One way to achieve this closeness is by adding the second order Taylor term, which results in an additional MSE loss term. As pointed out in Appendix A, we did not achieve good performance when testing out this version, since it is difficult to compute the Hessian in higher state spaces and heuristically choosing a value as a hyperparameter proved to be difficult to tune in practice. Therefore, we approached the solution to this problem as outlined in the paper.
279
+
280
+ # C FULL VAML FOR SAC
281
+
282
+ The formulation of VAML which we derive for SAC is a direct extension of the VAML loss to the SAC soft bellman backup. Specifically, given some distribution over the state-action space $\mathcal{D}$ , state-action value function $Q$ and policy $\pi$ , we can define a SAC-aware loss.
283
+
284
+ ![](images/44abd707e337300f66160aadd74e7928f69762ddd7b0bdae1fb9f0051e3dc848.jpg)
285
+ Figure 5: Comparison of VaGraM, MLE (MBPO baseline), IterVAML Farahmand (2018) and a value-weighing ablation on two simple continuous control tasks. The shaded area represents standard error estimated over 8 runs. While VaGraM, IterVAML and MBPO are able to achieve satisfactory performance on the Pendulum Swingup task, IterVAML fails to stabilize the more difficult Cartpole balancing task.
286
+
287
+ ![](images/428a6d25bb9be450429fea88efd0f3a46407da5d138ccddb8a15405faf6700ea.jpg)
288
+
289
+ $$
290
+ \begin{array}{l} \mathcal {L} _ {Q, \pi} (\hat {p}, p, \mathcal {D}) = \\ \int \left| \int (\hat {p} \left(s ^ {\prime} \mid s, a\right) - p \left(s ^ {\prime} \mid s, a\right)) \mathbb {E} _ {a ^ {\prime} \sim \pi \left(\cdot \mid s ^ {\prime}\right)} \left(Q \left(s ^ {\prime}, a ^ {\prime}\right) - \log \pi \left(a ^ {\prime} \mid s ^ {\prime}\right)\right) d s ^ {\prime} \right| ^ {2} d \mathcal {D} (s, a) (15) \\ = \int \left| \int \left(\hat {p} \left(s ^ {\prime} \mid s, a\right) - p \left(s ^ {\prime} \mid s, a\right)\right) V ^ {\pi} \left(s ^ {\prime}, a ^ {\prime}\right) d s ^ {\prime} \right. \\ - \int \left(\hat {p} \left(s ^ {\prime} \mid s, a\right) - p \left(s ^ {\prime} \mid s, a\right)\right) \mathbb {E} _ {a ^ {\prime} \sim \pi (\cdot | s ^ {\prime})} \left[ \log \pi \left(a ^ {\prime} \mid s ^ {\prime}\right) \right] d s ^ {\prime} \Bigg | ^ {2} d \mathcal {D} (s, a) (16) \\ \end{array}
291
+ $$
292
+
293
+ as well as its sample-based version:
294
+
295
+ $$
296
+ \begin{array}{l} \hat {\mathcal {L}} _ {Q, \pi} (\hat {p}, p, \mathcal {D}) = \sum_ {i} \left| V ^ {\pi} (s _ {i} ^ {\prime}) - \int \hat {p} (s ^ {\prime} | s _ {i}, a _ {i}) V ^ {\pi} (s ^ {\prime}) \mathrm {d} s ^ {\prime} - \right. \\ \left. \left(\int \pi \left(a ^ {\prime} \mid s _ {i} ^ {\prime}\right) \log \pi \left(a ^ {\prime} \mid s _ {i} ^ {\prime}\right) \mathrm {d} a ^ {\prime} - \int \int \hat {p} \left(s ^ {\prime} \mid s _ {i}, a _ {i}\right) \pi \left(a ^ {\prime} \mid s ^ {\prime}\right) \log \pi \left(a ^ {\prime} \mid s ^ {\prime}\right) \mathrm {d} a ^ {\prime} \mathrm {d} s ^ {\prime}\right) \right| ^ {2} \tag {17} \\ \end{array}
297
+ $$
298
+
299
+ We find that in most of our experiments, the entropy terms did not significantly contribute to the loss. Therefore we dropped it in our experiments and directly derived VaGraM for the value function prediction error only. This makes our loss applicable in all situations where the model is used to estimate the value function of a policy.
300
+
301
+ Finally, we do not account for the dependency of the policy function update on the model. Since SAC aims to minimize the KL divergence between the action distribution and the Gibbs distribution defined by the value function directly, the only way the model influences this update is via the induced state space distribution. We do not address this matching explicitly in this work, but a hybrid policy-aware and value-aware model is an enticing direction for future research.
302
+
303
+ # D ADDITIONAL EXPERIMENTS
304
+
305
+ # D.1 ABLATIONS
306
+
307
+ To test the performance of VaGraM and MBPO against alternative models, we used the classic Pendulum swingup and Cartpole benchmarks. As points of comparison, we used IterVAML (Farahmand, 2018) and a simple value-weighted regression similar to Nair et al. (2020), where the MSE error is multiplied by the inverse of the value function of the sample. The results are visualized in Figure 5. Hyperparameters follow the Cartpole task baseline in Pineda et al. (2021).
308
+
309
+ Since IterVAML suffers from strong destabilization on the Pendulum model learning problem, as discussed in section 4, we added an MSE loss to the original formulation $\mathcal{L}_{\mathrm{joint}} = \mathcal{L}_{\mathrm{IterVAML}} + \lambda \mathcal{L}_{\mathrm{MSE}}$
310
+
311
+ ![](images/f8a46a54509ae51c0cf47dd932c0fad0224653ba7321e229d4a82eed958a991f.jpg)
312
+
313
+ ![](images/c0ca8d0db11a7aa40f46276bb9ec546b728a0424f6a8f87ed126d6de71931be2.jpg)
314
+
315
+ ![](images/ed4495fa0c9e9c8e318295fdf593f722df3e42f3cdc6353dfbfd4b3eec83ad13.jpg)
316
+ Figure 6: Comparison of VaGraM and MBPO on the Mujoco tasks presented in Janner et al. (2019). We see that VaGraM is able to perform on par with the MBPO implementation on all tasks, while outperforming both the model-based and model-free baseline on the Ant environment. For the HalfCHEetah-v2 task, different performances emerge when using different rollout lengths. While the MLE baseline is not able to benefit from longer rollouts, VaGraM increases in performance, although the statistical significance of this increase is low due to the strong bimodality of solutions on the HalfCHEetah task.
317
+
318
+ ![](images/d509f0d43e1c6b11860fdaf1857c5e4297df53e97362fc693d3c96243a240d98.jpg)
319
+
320
+ with a tradeoff factor of $\lambda = 0.01$ . We see that this is sufficient to stabilize the performance in the Pendulum swingup task and prevent catastrophic divergence, but the model still performs significantly below the MBPO and VaGraM results in the Cartpole stabilization task. This is evidence that even with additional stabilization mechanisms, the issues presented in section 3 prevents the easy adoption of IterVAML to complex domains.
321
+
322
+ The value-weighing baseline is unable to achieve satisfactory performance even on the simple pendulum task, leading us to conclude that more complex reweighing schemes such as VaGraM are indeed necessary.
323
+
324
+ # D.2 PERFORMANCE IN MUJOCO BENCHMARK SUITE
325
+
326
+ The comparison runs on the Mujoco benchmark environments presented in Figure 6 are faulty due to a bug that was pointed out to us at the poster session. The bug only harms the performance of VaGraM, so we do not see it as a reason to withdraw the paper, but due to limited time and computational resources, we were unable to repeat the full comparison presented here. All other experiments are corrected and to the best of our knowledge reflect the performance of VaGraM. We will update the paper with updated comparisons once they are finished.
327
+
328
+ The results of VaGraM and MBPO are presented in Figure 6. We find that VaGraM is able to perform on par with the MBPO baseline on all the tasks. Due to stability issues, the Humanoid-v2 task is excluded, no algorithm achieved satisfactory performance (compare Pineda et al. (2021) for a discussion).
329
+
330
+ On the Ant-v2, we see small performance improvements above the results reported by Janner et al. (2019) and Pineda et al. (2021). We hypothesise that for this task, the canonical state space representation could be misaligned with the control problem in the sense that not all dimensions are informative for control. A further investigation of the phenomenon would be an interesting direction
331
+
332
+ for future research. All comparisons were done on the hyperparameter settings provided by Pineda et al. (2021).
333
+
334
+ Investigating the performance differences further, we find that on the HalfCheetah-v2 domain, VaGraM is able to profit from longer rollouts, while MBPO does not increase in performance when rolling out the model for more than 1 step. The comparison is presented in Figure 6. The MLE based model completely destabilizes if trained beyond 180 - 200 epochs on longer rollouts, which is why we truncated the training length before convergence. The performance of VaGraM with longer rollouts is already beyond the final performance of the fully trained MBPO baseline after 180 steps.
335
+
336
+ The destabilization leads to a complete collapse of the policy performance, probably due to increasing uncertainty of the model and in some cases to a gradient explosion that produces NaN values in the policy. We find that VaGraM does not suffer from this pattern and is able to slightly outperform both MBPO and VaGraM trained on a single step rollout. Similar patterns do not emerge in the Walker-v2 domain, here training on longer rollouts destabilizes all algorithms. We leave a more in-depth discussion of the impact of rollout length on policy performance under different models and losses for future work but highlight that significant performance might be gained by finding better tradeoffs than those discussed in Janner et al. (2019), especially when comparing deterministic and probabilistic models (compare Appendix F) as well as value-aware and value-agnostic models.
337
+
338
+ # EXPERIMENT DETAILS
339
+
340
+ As described in the main paper, we conducted our experiment in two domains from the OpenAI benchmark OpenAI Gym (Brockman et al., 2016), Pendulum-v2 and Hopper-v0. We used both environments as provided by the framework without further modification in our capacity tests. Our algorithm is shown in pseudocode in algorithm 1.
341
+
342
+ Expanded Hopper environment To test the performance of VaGraM in a setting with additional unnecessary state observations, we created a random dynamical system that evolves according to randomly initialized dynamics function, where $A$ is a fixed matrix with entries randomly drawn from $\mathcal{N}(0.,10.)$ , and a fixed initial state $s_0$ with components randomly drawn from $\mathcal{N}(0.,0.1)$ . We do not resample the fixed components at reset.
343
+
344
+ The transitions are then described by the following deterministic function:
345
+
346
+ $$
347
+ f \left(s _ {t}, a _ {t}\right) = \left\{ \begin{array}{l l} s _ {t} + \sin (A s) & \text {i f} | f \left(s _ {t}, a _ {t}\right) | < 2 0 \\ s _ {0} & \text {e l s e} \end{array} \right. \tag {18}
348
+ $$
349
+
350
+ This dynamics function contains two attributes which are hard for neural networks to model: discontinuity and non-linear dynamics. We find that this is sufficient to provide a very challenging environment for the MLE trained neural network models. To account for varying difficulty over different random initialization of the environments, we made sure to test the comparison runs with the same seeds over the different loss functions, but we did not find that the inter-seed variance was larger than the observed difference between the different loss functions.
351
+
352
+ # E.1 ARCHITECTURE AND HYPERPARAMETERS
353
+
354
+ For the Pendulum experiments, we use a simple fully connected neural network with a single layer, and a linear regression without feature transformations as architectures. The used non-linearity is ReLU. All experiments were implemented in PyTorch (Paszke et al., 2019) and were not specified, the standard initialization of the library were kept. The exact versions of all used libraries are documented in the provided source code.
355
+
356
+ To assure a fair comparison we used the hyperparameters provided by Janner et al. (2019) for all experiments with our approach and the NLL loss function used for the baseline. All models used were fully connected neural networks with SiLU non-linearities and standard initialization. For all experiments with full model size we followed MBPO and used seven ensemble members with four layers and 200 neurons per layer.
357
+
358
+ Algorithm 1: Value-Gradient weighted Model learning (VaGraM)
359
+ Initialize policy $\pi_{\phi}$ ,value function $v_{\psi}$ ,model $\hat{f}_{\theta}$ ,environment dataset $\mathcal{D}_{\mathrm{env}}$ , model dataset
360
+ $\mathcal{D}_{\mathrm{model}}$ .
361
+ for N epochs do
362
+ while $\hat{p}_{\theta}$ not converged do Sample batch $(s,a,r,s^{\prime})$ from $\mathcal{D}_{\mathrm{env}}$ .. $\mathcal{L}_{v_{\psi}} = \left((s' - \hat{f}_{\theta}(s,a))^{\intercal}\mathrm{diag}\left(\frac{d}{ds} v_{\psi}(s)|_{s'}\right)^{2}(s' - \hat{f}_{\theta}(s,a))\right);$ $\theta \gets \theta -\alpha \frac{d}{d\theta}\mathcal{L}_{v_{\psi}}$ Train reward model
363
+ end
364
+ for E steps do Take action in env according to $\pi_{\phi}$ ;add to $\mathcal{D}_{\mathrm{env}}$ . for M model rollouts do Sample s from $\mathcal{D}_{\mathrm{env}}$ ; sample $a\sim \pi_{\phi}(s)$ $s^{\prime},r = \hat{f}_{\theta}(s,a)$ Add $(s,a,r,s^{\prime})$ to $\mathcal{D}_{\mathrm{model}}$
365
+ end
366
+ for G policy gradient updates do Sample batch $(s,a,r,s^{\prime})$ from $\mathcal{D}_{\mathrm{env}}\cup \mathcal{D}_{\mathrm{model}}$ . $\psi \gets \psi -\beta \frac{d}{d\psi} (v_{\psi}(s) - (r + \gamma v'(s'))^{2};$ $\phi \gets \phi -\lambda \hat{\nabla}_{\phi}J(\pi_{\phi},v_{\psi},(s,a,r,s'))$
367
+ end
368
+ end
369
+
370
+ Even though our loss derivation does not support rolling out the model for more than a single step without accounting for this in the training setup, we find that VaGraM is still stable over the short rollout horizons used by MBPO. Therefore we used the rollout scheme from MBPO.
371
+
372
+ However, it was necessary to make a small alteration to the training setup: in the provided implementation, the value function is solely trained on model samples. Since our model is directly dependent on the value function, we need to break the inter-dependency between model and value function in the early training iterations. Hence, we used both real environment data and model data to train the value function, linearly increasing the amount of model samples from 0 to $95\%$ of the SAC replay buffer over the first 40 epochs of training (corresponding to 40.000 real environment steps). We did not transition to fully using model data to assure that the real environment samples are still able to inform the value function learning. We found that this did not diminish the training returns of MBPO compared to solely using model samples and so used this approach for both VaGraM and MLE.
373
+
374
+ To estimate the gradient of the value function, we used the four empirical value functions, two direct estimates and two target value functions used in the SAC algorithm and summed the losses using each data tuple and value function gradient independently. Furthermore we calculated the $L_{2}$ norm of all value function gradients and clipped these at the 95-th percentile. We found that this was necessary since the empirical value function gradients can get very sharp, which in rare cases leads to a destabilization of the gradient descent algorithm used to update the model.
375
+
376
+ # F DETERMINISTIC VS PROBABILISTIC MODELS
377
+
378
+ Our derivation of VaGram lead us to the conclusion that a deterministic model was sufficient to achieve the goal of value-aware model learning in environments with small transition noise. This insight stands in contrast to the current literature, which often claims that probabilistic models are needed to achieve optimal performance in model-based reinforcement learning. However, there is no clear consensus among different authors whether probabilistic models are needed or if a deterministic model can be sufficient for MBRL (compare Lutter et al. (2021)).
379
+
380
+ ![](images/f0a6c0b8ad7454b9b0c892ef3a47d833b199f9ab844a5d1db73508e660057275.jpg)
381
+ Figure 7: Comparison of the empirical performance of deterministic and probabilistic MLE models vs VaGraM. Thick lines denote the mean and shaded area the standard error over 8 runs. In the limited capacity setting, the deterministic model is able to achieve significantly higher returns than the probabilistic baseline, however with stability issues during longer training. On the distracting benchmark, the deterministic model is not able to achieve any significant returns.
382
+
383
+ ![](images/18cb2b866e6d84be1a7ecb79f5dfc3fbb013754ab80eb3b93ee3982dae56ddcf.jpg)
384
+
385
+ Our assumption that the model can be replaced with a deterministic one relies on the assumption that the underlying model is not dominated by stochastic transitions, but is deterministic or near deterministic and unimodal. This follows from the requirement that the model prediction admits a small error in the mean squared error sense, otherwise the Taylor approximation does not properly capture the behavior of the value function, as a model prediction might have high likelihood under the environment and still be far away from the environment sample in a mean squared sense otherwise. In domains where capturing the stochasticity is crucial, we have to revisit this requirement in follow up work.
386
+
387
+ Furthermore, we are operating under the assumption that the mean value function of each distribution over states can be represented as the value function of a single state prediction. Since value function approximations represented by neural networks are continuous, this is true in our setting due to the mean value theorem for integrals. Implicitly due to the Taylor approximation, we also assume that this mean value lies close to or on the environment sample we obtained. If other approximation schemes are used, this property needs to be checked and potentially probabilistic models are needed to represent the expectation over all possible value functions and transition dynamics.
388
+
389
+ # F.1 ABLATION EXPERIMENT WITH DETERMINISTIC MODELS
390
+
391
+ In our experiments in the Hopper domain, we used probabilistic models following Janner et al. (2019). To verify that the improvement in performance did not result from using a deterministic model instead of a probabilistic model, we repeated the experiment showing the impact of smaller model sizes, and replaced the probabilistic Gaussian ensemble with an ensemble of deterministic functions trained with the mean squared error loss between sample and state prediction. All other implementation details, architecture and hyperparameters were kept fixed. The results are shown in Figure 7. In this ablation, we do indeed see that a mean squared trained model captures the dynamics information better than a model that is trained using negative log likelihood. To the best of our knowledge, this phenomenon has not received attention in the literature, but we hypothesize that it is an artifact of training a probabilistic model with gradient descent instead of natural gradient descent (compare Figure 1 in Peters & Schaal (2008) for a visual intuition).
392
+
393
+ Nonetheless, VaGraM is still able to achieve higher cumulative reward consistently than the MSE model. Especially on the distraction task we find that a deterministic MSE model performs on par with the probabilistic model and fails to achieve any reward when faced with a challenging number of distractions. This validates our hypothesis that value awareness is important in settings with insufficient model capacity, but crucial in cases where the environment observations are not aligned with the control problem.
valuegradientweightedmodelbasedreinforcementlearning/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:197aabbdb764e66791be1361d0f335d500a11fcd0831c0e7fb816d8c866af8a2
3
+ size 424776
valuegradientweightedmodelbasedreinforcementlearning/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d7ac36ea2cfe795b0d0b8883eba07adcd5f37a9e341ef28377ef29c55cd2c69
3
+ size 467718
variationalmethodsforsimulationbasedinference/b631abec-cbcf-48ed-8993-df86144885bb_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b276a395b38e63a66406de42e58fbd6b56c597e38bc7f4b33658525f6289dd8d
3
+ size 154174
variationalmethodsforsimulationbasedinference/b631abec-cbcf-48ed-8993-df86144885bb_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:013296fe1ff0de189c548d51808865782c845af6412ed0bfa9981fcb6bcbebee
3
+ size 179909
variationalmethodsforsimulationbasedinference/b631abec-cbcf-48ed-8993-df86144885bb_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:08079d1bfe5044d1ecb8d24cb8e95585046bb07f05ae70b831d178bbf3341604
3
+ size 7135318
variationalmethodsforsimulationbasedinference/full.md ADDED
@@ -0,0 +1,624 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # VARIATIONAL METHODS FOR SIMULATION-BASED INFERENCE
2
+
3
+ Manuel Glickler
4
+
5
+ University of Tübingen
6
+
7
+ Michael Deistler
8
+
9
+ University of Tübingen
10
+
11
+ Jakob H. Macke
12
+
13
+ University of Tübingen
14
+
15
+ # ABSTRACT
16
+
17
+ We present Sequential Neural Variational Inference (SNVI), an approach to perform Bayesian inference in models with intractable likelihoods. SNVI combines likelihood-estimation (or likelihood-ratio-estimation) with variational inference to achieve a scalable simulation-based inference approach. SNVI maintains the flexibility of likelihood(-ratio) estimation to allow arbitrary proposals for simulations, while simultaneously providing a functional estimate of the posterior distribution without requiring MCMC sampling. We present several variants of SNVI and demonstrate that they are substantially more computationally efficient than previous algorithms, without loss of accuracy on benchmark tasks. We apply SNVI to a neuroscience model of the pyloric network in the crab and demonstrate that it can infer the posterior distribution with one order of magnitude fewer simulations than previously reported. SNVI vastly reduces the computational cost of simulation-based inference while maintaining accuracy and flexibility, making it possible to tackle problems that were previously inaccessible.
18
+
19
+ # 1 INTRODUCTION
20
+
21
+ Many domains in science and engineering use numerical simulations to model empirically observed phenomena. These models are designed by domain experts and are built to produce mechanistic insights. However, in many cases, some parameters of the simulator cannot be experimentally measured and need to be inferred from data. A principled way to identify parameters that match empirical observations is Bayesian inference. However, for many models of interest, one can only sample from the model by simulating a (stochastic) computer program, but explicitly evaluating the likelihood $p(\pmb{x}|\pmb{\theta})$ is intractable. Traditional methods to perform Bayesian inference in such simulation-based inference (SBI), also known as likelihood-free inference scenarios, include Approximate Bayesian computation (ABC) (Beaumont et al., 2002) and synthetic likelihood (SL) (Wood, 2010) methods. However, these methods generally struggle with high-dimensional data and typically require one to design or learn (Chen et al., 2021) summary statistics and distance functions.
22
+
23
+ Recently, several methods using neural density(-ratio) estimation have emerged. These methods train neural networks to learn the posterior (SNPE, Papamakarios & Murray, 2016; Lueckmann et al., 2017; Greenberg et al., 2019), the likelihood (SNLE, Papamakarios et al., 2019; Lueckmann et al., 2019a), or the likelihood-to-evidence ratio (SNRE, Thomas et al., 2021; Hermans et al., 2020; Durkan et al., 2020; Miller et al., 2022).
24
+
25
+ To improve the simulation efficiency of these methods, sequential training schemes have been proposed: Initially, parameters are sampled from the prior distribution to train an estimation-network. Subsequently, new samples are drawn adaptively to focus training on specific regions in parameter space, thus allowing the methods to scale to larger models with more parameters.
26
+
27
+ In practice, however, it has remained a challenge to realize the full potential of these sequential schemes: For sequential neural posterior estimation (SNPE) techniques, the loss function needs to be adjusted across rounds (Greenberg et al., 2019), and it has been reported that this can be problematic if the proposal distribution is very different from prior, and lead to 'leakage' of probability mass into regions without prior support (Durkan et al., 2020). Both sequential neural likelihood (SNLE) and likelihood-ratio (SNRE) methods require MCMC sampling, which can become prohibitively slow-- MCMC sampling is required for each round of simulations, which, for high-dimensional models, can take more time than running the simulations and training the neural density estimator.
28
+
29
+ ![](images/b1b8928b3b21579846e67c557e21ba14c90eb897238e9c884634b14b121c0c06.jpg)
30
+ Figure 1: Illustration of SNVI. We first learn the likelihood $p(\pmb{x}|\pmb{\theta})$ for any $\pmb{\theta}$ . We then use variational inference to learn the posterior distribution by minimizing a general divergence measure $D$ . The obtained posterior distribution is sampled with sampling importance resampling (SIR) to run new simulations and refine the likelihood estimator.
31
+
32
+ Our goal is to provide a method which combines the advantages of posterior-targeting methods and those targeting likelihood(-ratios): Posterior targeting methods allow rapid inference by providing a functional approximation to the posterior which can be evaluated without the need to use MCMC sampling. Conversely, a key advantage of likelihood(-ratio) targeting methods is their flexibility-learned likelihoods can e.g. be used to integrate information from multiple observations, or can be used without retraining if the prior is changed. In addition, they can be applied with any active-learning scheme without requiring modifications of the loss-function.
33
+
34
+ We achieve this method by combining likelihood(-ratio) estimation with variationally learned inference networks using normalizing flows (Rezende & Mohamed, 2015; Papamakarios et al., 2017; Durkan et al., 2019a) and sampling importance resampling (SIR) (Rubin, 1988). We name our approach Sequential Neural Variational Inference (SNVI). We will show that our simulation-based inference methods are as accurate as SNLE and SNRE, while being substantially faster at inference as they do not require MCMC sampling. In addition, real-world simulators sometimes produce invalid outputs, e.g. when a simulation fails. We introduce a strategy that allows likelihood(-ratio) targeting methods (such as SNVI) to deal with such invalid simulation outputs.
35
+
36
+ A recent method termed "Sequential Neural Posterior and Likelihood Approximation" (SNPLA) also proposed to use variational inference (VI) instead of MCMC to speed up inference in likelihood-targeting methods (Wiqvist et al., 2021). While this proposal is related to our approach, their VI objective is based on the reverse Kullback Leibler (rKL) divergence for learning the posterior. As we also show on benchmark tasks, this leads to mode-seeking behaviour which can limit its performance. In contrast, we show how this limitation can be overcome through modifying the variational objective in combination with using SIR for adjusting posteriors.
37
+
38
+ After an introduction on neural network-based simulation-based inference (SBI) and variational inference (Sec. 2), we present our method, Sequential Neural Variational Inference (SNVI) (Sec. 3). In Sec. 4.2, we empirically show that SNVI is significantly faster than state-of-the-art SBI methods while achieving similar accuracy on benchmark tasks. In Sec. 4.3, we demonstrate that SNVI is scalable, and that it is robust to invalid simulation outputs: We obtain the posterior distribution of a complex neuroscience model with one order of magnitude fewer simulations than previous methods.
39
+
40
+ # 2 BACKGROUND
41
+
42
+ # 2.1 SIMULATION-BASED INFERENCE
43
+
44
+ Simulation-based inference (SBI) aims to perform Bayesian inference on statistical models for which the likelihood function is only implicitly defined through a stochastic simulator. Given a prior $p(\pmb{\theta})$ and a simulator which implicitly defines the likelihood $p(\pmb{x}|\pmb{\theta})$ , the goal is to identify the posterior distribution $p(\pmb{\theta}|\pmb{x}_o)$ for an observation $\pmb{x}_o$ . The simulator is considered to be 'black-box', i.e. one cannot evaluate $p(\pmb{x}|\pmb{\theta})$ and does not have access to the internal states of the simulator, but only to its inputs $\pmb{\theta}$ and its outputs $\pmb{x}$ .
45
+
46
+ We focus on improving likelihood-estimation (SNLE) and likelihood-ratio-estimation (SNRE) methods. SNLE trains a deep neural density estimator $\ell_{\psi}(\pmb{x}|\pmb{\theta})$ by minimizing the forward Kullback-Leibler divergence (fKL) between $\ell_{\psi}(\pmb{x}|\pmb{\theta})$ and $p(\pmb{x}|\pmb{\theta})$ using samples $(\pmb{x},\pmb{\theta}) \sim \tilde{p}(\pmb{x},\pmb{\theta}) = p(\pmb{x}|\pmb{\theta})\tilde{p}(\pmb{\theta})$ from the simulator with $\mathcal{L}(\psi) = -\frac{1}{N}\sum_{i=1}^{N}\log \ell_{\psi}(\pmb{x}_i|\pmb{\theta}_i)$ . Here, $\ell_{\psi}(\pmb{x}|\pmb{\theta})$ is a conditional density estimator learning the conditional density $p(\pmb{x}|\pmb{\theta})$ from $(\pmb{\theta},\pmb{x})$ pairs, $\psi$ are its learnable parameters, and $\tilde{p}(\pmb{\theta})$ is the proposal distribution from which the parameters $\pmb{\theta}$ are drawn (given by e.g. a previous estimate of the posterior or by an active learning scheme, Papamakarios et al., 2019; Lueckmann et al., 2019a).
47
+
48
+ Analogously, SNRE uses a discriminator, e.g. a deep logistic regression network, to estimate the density ratio $r(\pmb{x}, \pmb{\theta}) = \frac{\tilde{p}(\pmb{x}, \pmb{\theta})}{\tilde{p}(\pmb{x}) \tilde{p}(\pmb{\theta})} = \frac{p(\pmb{x}|\pmb{\theta})}{\tilde{p}(\pmb{x})}$ . (Hermans et al., 2020; Durkan et al., 2020). If the proposal is given by the prior, then one can recover the exact posterior density, otherwise the posterior can be recovered up to a normalizing constant (Durkan et al., 2020). Once the likelihood (or likelihood-ratio) has been learned, the posterior can be sampled with MCMC. In sequential schemes, the proposal $\tilde{p}$ is updated each round using the current estimate of the posterior – thus, computationally expensive MCMC sampling needs to be run in each round.
49
+
50
+ # 2.2 VARIATIONAL INFERENCE
51
+
52
+ We use variational inference (VI) to estimate the posterior distribution. VI formulates an optimization problem over a class of tractable distributions $\mathcal{Q}$ to find parameters $\phi^{*}$ such that $q_{\phi^{*}} \in \mathcal{Q}$ is closest to the true posterior $p(\boldsymbol{\theta} | \boldsymbol{x}_o)$ according to some divergence $D$ (Blei et al., 2017). Formally,
53
+
54
+ $$
55
+ \phi^ {*} = \underset {\phi} {\arg \min } D (q _ {\phi} (\boldsymbol {\theta}) | | p (\boldsymbol {\theta} | \boldsymbol {x} _ {o}))
56
+ $$
57
+
58
+ with $q_{\phi^*}(\pmb{\theta}) = p(\pmb{\theta}|\pmb{x}_o) \iff D(q_{\phi^*}(\pmb{\theta})||p(\pmb{\theta}|\pmb{x}_o)) = 0$ . Recent work has introduced normalizing flows as a variational family for VI (Ranganath et al., 2014; Agrawal et al., 2020; Rezende & Mohamed, 2015). Normalizing flows define a distribution $q_{\phi}(\pmb{\theta})$ by learning a bijection $T_{\phi}$ which transforms a simpler distribution into a complex distribution $p(\pmb{\theta}|\pmb{x}_o)$ . Normalizing flows provide a highly flexible variational family, while at the same time allowing low variance gradient estimation of an expectation by the reparameterization trick, i.e. $\nabla_{\phi}\mathbb{E}_{\pmb{\theta}\sim q_{\phi}}[f(\pmb{\theta})] = \mathbb{E}_{\pmb{\theta}_0\sim q_0}[\nabla_{\phi}f(T_{\phi}(\pmb{\theta}_0))]$ with $\pmb{\theta} = T_{\phi}(\pmb{\theta}_0)$ (Kingma & Welling, 2014; Rezende et al., 2014; Rezende & Mohamed, 2015).
59
+
60
+ # 3 SEQUENTIAL NEURAL VARIATIONAL INFERENCE (SNVI)
61
+
62
+ # 3.1 KEYINGREDIENTS
63
+
64
+ We propose a framework to use variational inference (VI) for simulation-based inference. Our method consists of three parts: A learnable likelihood (or likelihood-ratio) model, a posterior model (typically parameterized as a normalizing flow) to be learned with VI, and sampling importance resampling (SIR) (Rubin, 1988) to refine the accuracy of the posterior (Fig. 1). The likelihood(-ratio) model $\ell_{\psi}(\pmb{x}|\pmb{\theta})$ learns to approximate the likelihood $p(\pmb{x}|\pmb{\theta})$ or the likelihood-ratio $\frac{p(\pmb{x}|\pmb{\theta})}{p(\pmb{x})}$ from pairs of parameters and simulation outputs $(\pmb{\theta},\pmb{x})$ . We use the term SNLVI to refer to SNVI with likelihoods, and SNRVI with likelihood-ratios. After a likelihood(-ratio) model has been trained, the posterior model $q_{\phi}(\pmb{\theta})$ is trained with variational inference using normalizing flows. Finally, SIR is used to correct potential inaccuracies in the posterior $q_{\phi}(\pmb{\theta})$ - as we will show below, the SIR step leads to empirical improvements at modest computational overhead. To refine the likelihood(-ratio) model and the posterior, the procedure can be repeated across several 'rounds'. We opt to sample the parameters $\pmb{\theta}$ from the previous posterior estimate $q_{\phi}(\pmb{\theta})$ , but other strategies for active learning (e.g. Lueckmann et al., 2019b) could be plugged into SNVI. The algorithm is summarized in Alg. 1. We will now describe three variational objectives that can be used with SNVI, the SIR procedure to refine the posterior, and a strategy for dealing with invalid simulation outputs.
65
+
66
+ # 3.2 VARIATIONAL OBJECTIVES FOR SBI
67
+
68
+ Because of the expressiveness of normalizing flows, the true posterior can likely be approximated well by a member of the variational family (Papamakarios et al., 2021). Thus, the quality of the
69
+
70
+ Algorithm 1: SNVI
71
+ 1 Inputs: prior $p(\theta)$ , observation $\pmb{x}_o$ , divergence $D$ , simulations per round $N$ , number of
72
+ rounds $R$ , selection strategy $\mathcal{S}$
73
+ 2 Outputs: Approximate likelihood $\ell_{\psi}$ and variational posterior $q_{\phi}$
74
+ 3 Initialize: Proposal $\tilde{p} (\pmb {\theta}) = p(\pmb {\theta})$ , simulation dataset $\mathcal{X} = \{\}$
75
+ 4 for $r\in [1,\dots,R]$ do
76
+ 5 for $i\in [1,\dots,N]$ do
77
+ 6 $\pmb {\theta}_i = \mathcal{S}(\tilde{p},\ell_\phi ,p)$ // sample $\pmb {\theta}_i\sim \tilde{p} (\pmb {\theta})$
78
+ 7 simulate $\pmb {x}_i\sim p(\pmb {x}|\pmb {\theta}_i)$ // run the simulator on $\pmb{\theta}_{i}$
79
+ 8 add $(\pmb {\theta}_i,\pmb {x}_i)$ to $\mathcal{X}$
80
+ 9 end
81
+ 10 (re-)train $\ell_{\psi}$ .. $\psi^{*} = \arg \min_{\psi} - \frac{1}{N}\sum_{(\pmb {x}_i,\pmb {\theta}_i)\in \mathcal{X}}\log \ell_{\psi}(\pmb {x}_i|\pmb {\theta}_i);$ / or SNRE loss
82
+ 11 (re-)train $q_{\phi}$ .. $\phi^{*} = \arg \min_{\phi}D(q_{\phi}(\pmb {\theta})||p(\pmb {\theta}|\pmb {x}_o))$ with
83
+ 12 $p(\pmb {\theta}|\pmb {x}_o)\propto p(\pmb {x}_o|\pmb {\theta})p(\pmb {\theta})\approx \ell_{\psi^*}(\pmb {x}_o|\pmb {\theta})p(\pmb {\theta})$
84
+ 13 end
85
+
86
+ variational approximation is strongly linked to the ability to achieve the best possible approximation through optimization, which in turn depends on the choice of variational objective $D$ . Using the reverse Kullback-Leibler Divergence (rKL) as proposed by Wiqvist et al. (2021) can give rise to mode-seeking behaviour and $q_{\phi}$ might not cover all regions of the posterior (Bishop, 2006; Blei et al., 2017). As a complementary approach, we suggest and evaluate three alternative variational objectives that induce a mass-covering behaviour and posit that this strategy will be particularly important in sequential schemes.
87
+
88
+ 1. Forward KL divergence (fKL) In contrast to the reverse KL (rKL), the forward Kullback-Leibler divergence (fKL) is mass-covering (Bishop, 2006). Wan et al. (2020) minimize the following upper bound to the evidence, which implicitly minimizes the fKL: $\mathcal{L}(\phi) = \mathbb{E}_{\pmb{\theta}\sim q_{\phi}}[w(\pmb{\theta})\log(w(\pmb{\theta}))]$ with $w(\pmb{\theta}) = p(\pmb{x}_o,\pmb{\theta}) / q_{\phi}(\pmb{\theta})$ . This expression is hard to estimate with samples: If $q_{\phi}(\pmb{\theta})$ is different from $p(\pmb{x}_o,\pmb{\theta})$ then $w(\pmb{\theta}) \approx 0$ for most $\pmb{\theta} \sim q_{\phi}(\pmb{\theta})$ , thus $\nabla_{\phi}\mathcal{L}(\phi) \approx 0$ , which would prevent learning (see Appendix Sec. A.3).
89
+
90
+ To overcome this problem, we rewrite the fKL using self-normalized importance sampling (Jerfel et al., 2021). Let $\theta_{1},\ldots ,\theta_{N}\sim \pi$ be samples from an arbitrary proposal distribution $\pi$ . We then minimize the loss:
91
+
92
+ $$
93
+ \mathcal {L} _ {\mathrm {f K L}} (\phi) = D _ {K L} (p | | q _ {\phi}) \approx \sum_ {i = 1} ^ {N} \frac {w (\boldsymbol {\theta} _ {i})}{\sum_ {j = 1} ^ {N} w (\boldsymbol {\theta} _ {j})} \log \left(\frac {p (\boldsymbol {x} _ {o} , \boldsymbol {\theta} _ {i})}{q _ {\phi} (\boldsymbol {\theta} _ {i})}\right)
94
+ $$
95
+
96
+ where $w(\pmb{\theta}) = p(\pmb{x}_o, \pmb{\theta}) / \pi(\pmb{\theta})$ . As a self-normalized importance sampling scheme, this estimate is biased, but the bias vanishes at rate $\mathcal{O}(1/N)$ (Hesterberg, 2003). In our experiments, we use $\pi = q_{\phi}$ , which provides a good proposal when $q_{\phi}$ is close to $p$ (Chatterjee & Diaconis, 2018). Even though $q_{\phi}$ will differ from $p$ initially, sufficient gradient information is available to drive $q_{\phi}$ towards $p$ , as we demonstrate in Appendix Sec. A.3.
97
+
98
+ 2. Importance weighted ELBO The importance weighted ELBO (IW-ELBO) introduced by Burda et al. (2016) uses the importance-weighted gradient of the evidence lower bound (ELBO). It minimizes the KL divergence between the self-normalized importance sampling distribution of $q_{\phi}$ and the posterior and thus provides a good proposal for sampling importance resampling (Cremer et al., 2017; Domke & Sheldon, 2018; Ranganath et al., 2014). It can be formulated as
99
+
100
+ $$
101
+ \mathcal {L} _ {I W} ^ {(K)} (\phi) = \mathbb {E} _ {\boldsymbol {\theta} _ {1}, \dots , \boldsymbol {\theta} _ {k} \sim q _ {\phi}} \left[ \log \frac {1}{K} \sum_ {k = 1} ^ {K} \frac {p (\boldsymbol {x} _ {o} , \boldsymbol {\theta} _ {k})}{q _ {\phi} (\boldsymbol {\theta} _ {k})} \right].
102
+ $$
103
+
104
+ To avoid a low SNR of the gradient estimator (Rainforth et al., 2018), we use the 'Sticking the Landing' (STL) estimator introduced by Roeder et al. (2017).
105
+
106
+ 3. Rényi $\alpha$ -divergences Rényi $\alpha$ -divergences are a divergence family with a hyperparameter $\alpha$ which allows to tune the mass-covering (or mode-seeking) behaviour of the algorithm. For $\alpha \to 1$ , the divergence approaches the rKL. For $\alpha < 1$ , the divergence becomes more mass-covering, for $\alpha > 1$ more mode-seeking. We use $\alpha = 0.1$ in our experiments. A Rényi variational bound was established by Li & Turner (2016) and is given by
107
+
108
+ $$
109
+ \mathcal {L} _ {\alpha} (\phi) = \frac {1}{1 - \alpha} \log \left(\mathbb {E} _ {\pmb {\theta} \sim q _ {\phi}} \left[ \left(\frac {p (\pmb {x} _ {o} , \pmb {\theta})}{q _ {\phi} (\pmb {\theta})}\right) ^ {1 - \alpha} \right]\right)
110
+ $$
111
+
112
+ For $\alpha = 0$ , $\mathcal{L}_{\alpha}$ is a single sample Monte Carlo estimate of the IW-ELBO (when using $K$ samples to estimate the expectation in $\mathcal{L}_{\alpha}(\phi)$ ) and thus also suffers from a low SNR as $\alpha \rightarrow 0$ (Rainforth et al., 2018; Li & Turner, 2016). Just as for the IW-ELBO, we alleviate this issue by combining the $\alpha$ -divergences with the STL estimator.
113
+
114
+ # 3.3 SAMPLING IMPORTANCE RESAMPLING
115
+
116
+ After the variational posterior has been trained, $q_{\phi}$ approximates $\ell_{\psi}(\pmb{x}_o|\pmb{\theta})p(\pmb{\theta}) / Z$ with normalization constant $Z$ . We propose to improve the quality of posterior samples by applying Sampling Importance Resampling (SIR) (Rubin, 1988). We sample $K = 32$ samples from $\pmb{\theta} \sim q_{\phi}(\pmb{\theta})$ , compute the corresponding importance weights $w_i = \ell_{\psi}(\pmb{x}_o|\pmb{\theta}_i)p(\pmb{\theta}_i) / q_{\phi}(\pmb{\theta}_i)$ and resample a single sample from a categorical distribution whose probabilities equal the normalized importance weights (details in Appendix Sec. A.4). This strategy enriches the variational family with minimal computational cost (Agrawal et al., 2020). SIR is particularly useful when $q_{\phi}(\pmb{\theta})$ covers the true posterior and is thus well-suited for the objectives described above (see Appendix Fig. 6).
117
+
118
+ # 3.4 EXCLUDING INVALID DATA
119
+
120
+ Simulators may produce unreasonable or undefined values (e.g. NaN), as we will also see in the pyloric network model described later. In posterior estimation methods (SNPE), one can simply remove these 'invalid' simulations from the training dataset, and the trained neural density estimator will still approximate the true posterior (Lueckmann et al., 2017). However, as we show in Appendix Sec. A.6, this is not the case for likelihood(-ratio)-methods- when 'invalid' simulations are removed, the network will converge to $\ell_{\psi}(\pmb{x}_o|\pmb{\theta})\approx \frac{1}{Z} p(\pmb{x}_o|\pmb{\theta}) / p(\mathrm{valid}|\pmb {\theta})$ , i.e. the learned likelihood-function will be biased towards parameter regions which often produce 'invalid' simulations. This prohibits any method that estimates the likelihood(-ratio) (i.e. SNVI, SNLE, SNRE) from excluding 'invalid' simulations, and would therefore prohibit their use on models that produce such data.
121
+
122
+ To overcome this limitation of likelihood-targeting techniques, we propose to estimate the bias-term $p(\mathrm{valid}|\pmb{\theta})$ with an additional feedforward neural network $c_{\zeta}(\pmb{\theta}) \approx p(\mathrm{valid}|\pmb{\theta})$ (details in Appendix Sec. A.6). Once trained, $c_{\zeta}(\pmb{\theta})$ can be used to correct for the bias in the likelihood network. Given the (biased) likelihood network $\ell_{\psi}(\pmb{x}_o|\pmb{\theta})$ and the correction factor $c_{\zeta}(\pmb{\theta})$ , the posterior distribution is proportional to
123
+
124
+ $$
125
+ \mathcal {P} (\boldsymbol {\theta}) = \ell_ {\psi} (\boldsymbol {x} _ {o} | \boldsymbol {\theta}) p (\boldsymbol {\theta}) c _ {\zeta} (\boldsymbol {\theta}) \propto p (\boldsymbol {x} _ {o} | \boldsymbol {\theta}) p (\boldsymbol {\theta}) \propto p (\boldsymbol {\theta} | \boldsymbol {x} _ {o}).
126
+ $$
127
+
128
+ We sample from this distribution with VI in combination with SIR. Details, proof and extension to SNRVI in Appendix Sec. A.6. The additional network $c_{\zeta}(\theta)$ is only required in models which can produce invalid simulations. This is not the case for the toy models in Sec. 4.2, but it is required in the model in Sec. 4.3. Alg. 1 shows SNVI without the additional bias-correction step, Appendix Alg. 3 shows the method with correction.
129
+
130
+ # 4 EXPERIMENTS
131
+
132
+ We demonstrate the accuracy and the computational efficiency of SNVI on several examples. First, we apply SNVI to an illustrative example to demonstrate its ability to capture complex posteriors without mode-collapse. Second, we compare SNVI to alternative methods on several benchmark tasks. Third, we demonstrate that SNVI can obtain the posterior distribution in models with many parameters by applying it to a neuroscience model of the pyloric network in the crab Cancer borealis.
133
+
134
+ ![](images/c8ddfaa96839edab69c610643bd2f089a8dcff246be826abc8fb9894dfec05ef.jpg)
135
+ Figure 2: A Posterior approximations of SNLE, SNPLA, and SNVI+fKL for the two moons benchmark example. B Runtime of all algorithms.
136
+
137
+ ![](images/2acc3931d8eaf39fb18fab6181380b45e6c4f15357f313164cd8e8b0112ff972.jpg)
138
+
139
+ # 4.1 ILLUSTRATIVE EXAMPLE: TWO MOONS
140
+
141
+ We use the 'two moons' simulator (Greenberg et al., 2019) to illustrate the ability of SNVI to capture complex posterior distributions. The two moons simulator has two parameters with a uniform prior and generates a posterior that has both local and global structure. Fig. 2A shows the ground truth posterior distribution as well as approximations learned by several methods using $10^{5}$ simulations.
142
+
143
+ SNLE with MCMC (in the form of Slice Sampling with axis-aligned updates (Neal, 2003)) can recover the bimodality when running 100 chains in parallel (Lueckmann et al., 2021) (not shown: individual chains typically only explore a single mode). SNPLA, which is based on the mode-seeking rKL (and could thus also be considered as $\mathrm{SNVI + rKL}$ , see Appendix Sec. A.7) captures only a single mode. In contrast, SNLVI (using the fKL and SIR, denoted as $\mathrm{SNVI + fKL}$ ) recovers both the local and the global structure of the posterior accurately. In terms of runtime, SNPLA and $\mathrm{SNVI + fKL}$ are up to twenty times faster than 100 chain MCMC in our implementation (Fig. 2B), and two to four orders of magnitude faster than single chain MCMC (single chain not shown, the relative speed-up for multi-chain MCMC is due to vectorization).
144
+
145
+ # 4.2 RESULTS ON BENCHMARK PROBLEMS
146
+
147
+ We compare the accuracy and computational cost of SNVI to that of previous methods, using SBI benchmark tasks (Lueckmann et al., 2021):
148
+
149
+ Bernoulli GLM: Generalized linear model with Bernoulli observations. Inference is performed on 10-dimensional sufficient summary statistics of the originally 100 dimensional raw data. The resulting posterior is 10-dimensional, unimodal, and concave.
150
+
151
+ Lotka Volterra: A traditional model in ecology (Wangersky, 1978), which describes a predator-prey interaction between species, illustrating a task with complex likelihood and unimodal posterior.
152
+
153
+ Two moons: Same as described in the previous section.
154
+
155
+ SLCP: A task introduced by Papamakarios et al. (2019) with a simple likelihood and complex posterior. The prior is uniform, the likelihood has Gaussian noise but is nonlinearly related to the parameters, resulting in a posterior with four symmetrical modes.
156
+
157
+ For each task, we perform inference for ten different runs, each with a different observation. As performance metric, we used classifier 2-sample tests (C2ST) (best is 0.5, worst is 1.0) (Friedman, 2004; Lopez-Paz & Oquab, 2017). For each method, we perform inference given a total of $10^{3}$ , $10^{4}$ and $10^{5}$ simulations, evenly distributed across ten rounds of simulation and training. Details on the hyperparameters are provided in Appendix Sec. A.8, details on results in Appendix Fig. 9, comparisons to the forward KL without self-normalized weights as well as to the IW-ELBO and the $\alpha$ -divergences without STL in Appendix Fig. 11.
158
+
159
+ We show results for two reference methods, SNLE with MCMC sampling, and SNPLA, and compare them to three variants of SNLVI using the forward KL (SNVI+fKL), the importance-weighted ELBO (SNVI+IW) as well as an alpha-divergence (SNVI+α). We find that all three SNVI-variants achieve performance comparable to MCMC across all four tasks (Fig. 3 A-D, left), and outperform SNPLA on the two tasks with multi-modal posteriors (Two moons and SLCP). We find that omitting the SIR-adjustment (dotted lines) leads to a small but consistent degradation in inference
160
+
161
+ ![](images/09d0dfd918cf416b78614e69c435718fa28461be25e59de7b01da526b26eea8f.jpg)
162
+ Figure 3: C2ST benchmark results for SNVI with likelihood-estimation (SNLVI) for four models, Bernoulli GLM (A), Lotka volterra (B), Two moons (C) and SLCP (D). Each point represents the average metric value for ten different observations, as well as the confidence intervals. Bars on the right indicate the average runtime. Two reference methods: SNLE with MCMC sampling, and SNPLA (which uses rKL), as well as three variants of SNVI, with forward KL (SNVI+fKL), importance-weighted ELBO (SNVI+IW) and $\alpha$ -divergence (SNVI+ $\alpha$ ). Dotted lines: Performance when not using SIR.
163
+
164
+ performance for all SNVI-variants, but not for SNPLA with the rKL: When using the rKL, the approximate posterior $q_{\phi}$ is generally narrower than the posterior and thus ill-suited for SIR (Appendix Fig. 6). Qualitatively similar results were found when using likelihood-ratio approaches with the same hyperparameters, see Appendix Fig. 10.
165
+
166
+ In terms of runtime, all three variants of SNLVI are substantially faster than SNLE on every task (bars in Fig. 3 on the right), in some cases by more than an order of magnitude. When using likelihood-ratio estimation, MCMC with 100 chains can be as fast as SNRVI on tasks with few parameters (Appendix Fig. 10). On tasks with many parameters, however, SNRVI is significantly faster than SNRE (see e.g. Bernoulli GLM with 10 parameters).
167
+
168
+ # 4.3 INFERENCE IN A NEUROSCIENCE MODEL OF THE PYLORIC NETWORK
169
+
170
+ Finally, we applied SNVI to a simulator of the pyloric network in the stomatogastric ganglion (STG) of the crab Cancer Borealis, a well-characterized circuit producing rhythmic activity. The model consists of three model neurons (each with eight membrane conductances) with seven synapses (31 parameters in total) and produces voltage traces that can be characterized with 15 established summary statistics (Prinz et al., 2003; 2004). In this model, disparate parameter sets can produce similar activity, leading to a posterior distribution with broad margins but narrow conditionals (Prinz et al., 2004; Gonçalves et al., 2020). Previous work has used millions of simulations from prior samples and performed amortized inference with NPE (18 million simulations in Gonçalves et al. (2020), 9 million in Deistler et al. (2021)). Sequential neural posterior estimation (SNPE) struggles on this problem due to leakage, whereas SNLE and SNRE with MCMC are inefficient (Durkan et al., 2020). Here, we apply SNVI to identify the posterior distribution given an extracellular recording of the stomatogastric motor neuron (Fig. 4A) (Haddad & Marder, 2021; 2018). We demonstrate that SNVI can perform multi-round inference and obtains the posterior distribution with only 350,000 simulations – 25 times fewer than previous methods!
171
+
172
+ ![](images/ecd6bab0eaf837369a192373f19e25c5b44089fd36ed3bbae8c615440f2273f0.jpg)
173
+
174
+ ![](images/da6850c3df958b86e2c17ed480079ee3ec6ae311959c242c8bf2b71445ef393a.jpg)
175
+
176
+ ![](images/da66a81c9ad730e85abcd8331ba968a46f9ea037d035f2b69a2a26cfdc47c939.jpg)
177
+
178
+ ![](images/fe75cd589d06ecb2b7e60da24b114ae134902227e3c073d2950a5f583cf42245.jpg)
179
+ Figure 4: (A) Empirical observation, arrows indicate some of the summary statistics. Scale bar is one second. (B) Cornerplot showing a subset of the marginal and pairwise marginal distributions of the 31-dimensional posterior (full posterior in Appendix Fig. 12). Red dot: MAP. Black dot: Posterior mean. (C) Conditional distributions $p(\theta_{i,j} | \boldsymbol{x}, \theta_{\neq i,j})$ . Green dot shows the sample on which we condition. (D) Simulated traces from the posterior mean and MAP. Scale bar is one second. (E) Simulated traces of three posterior samples. (F) Posterior predictive and prior predictive median (z-scored) distances from the observation. (G) Time required to obtain 10k samples: SNVI takes 11 minutes and SNLE with 100-chain MCMC 808 minutes, i.e. over 13 hours.
180
+
181
+ ![](images/cb5975262aa154cb4e9d2749389fbd38b7521280569e30dd746a9eff13191d72.jpg)
182
+
183
+ ![](images/14c2b4153ca79b049d5105255d4ed861f4754fedf5d83eb178736998b17148ef.jpg)
184
+
185
+ We ran SNVI with a likelihood-estimator with the fKL divergence (SNVI+fKL) and SIR. Since the simulator produces many invalid summary statistics (e.g. gaps between bursts cannot be defined if there are no bursts) we employed the strategy described in Sec. 3.4. Because only $1\%$ of the simulations from prior samples are valid (Fig. 4F), we used 50,000 simulations in the first round and continued for 30 rounds with 10,000 simulations each.
186
+
187
+ The posterior is complex and reveals strong correlations and nonlinear relationships between parameters (Fig. 4B showing 4 out of 31 dimensions, full posterior in Appendix Fig. 12). The conditional distributions $p(\theta_{i,j} | \boldsymbol{x}, \theta_{\neq i,j})$ given a posterior sample (Fig. 4C) are narrow, demonstrating that parameters have to be finely tuned to generate the summary statistics of the experimentally measured activity. We used posterior predictive checks to inspect the quality of the posterior. When simulating data from the posterior mean and posterior mode (MAP), we find that both of them match the statistics of the experimental activity (Fig. 4D). Similarly, samples from the posterior distribution closely match statistics of the experimental activity (Fig. 4E). Out of 10,000 posterior samples, 9366 ( $\approx 94\%$ ) generated activity with well-defined summary statistics (compared to $1\%$ of prior samples). For the samples which generate well-defined summary statistics, the (z-scored) median distance between the observed data $x_o$ and generated activity is smaller for posterior samples than for prior samples (Fig. 4F). We emphasize that an application of SNLE with MCMC would be estimated to take an additional 400 hours, due to 30 rounds of slow MCMC sampling (Fig. 4G) that would be required- instead of 27 hours for SNVI. Likewise, when running SNPE-C on this example, only one out of 2 million samples was within the prior bounds after the second round, requiring computationally expensive rejection sampling (Greenberg et al., 2019; Durkan et al., 2020). Finally, we note that the additional neural network $c_\zeta(\theta)$ (required to correct for the effect of invalid simulations) can be learned robustly and with low computational cost (see Appendix Fig. 13 for runtime).
188
+
189
+ These results show that SNVI makes it possible to overcome the limitations of previous methods and allows sequential neural simulation-based inference methods to effectively and robustly scale to challenging inference problems of scientific interest. While it is difficult to rigorously evaluate the accuracy of the obtained posterior distribution due to a lack of ground truth, we observed that almost all posterior predictions have well-defined summary statistics (94% vs 80% in Gonçalves et al. (2020)) and that the posterior predictions closely match $\pmb{x}_o$ .
190
+
191
+ # 5 DISCUSSION
192
+
193
+ We introduced Sequential Neural Variational Inference (SNVI), an efficient, flexible, and robust approach to perform Bayesian inference in models with an intractable likelihood. We achieve this by combining likelihood-estimation (or likelihood-ratio estimation) with variational inference, further improved by using SIR for refining posteriors. We demonstrate that SNVI reduces the computational cost of inference while maintaining accuracy. We applied our approach to a neuroscience model of the pyloric network with 31 parameters and showed that it is 25 times more efficient than previous methods. Our results demonstrate that SNVI is a scalable and robust method for simulation-based inference, opening up new possibilities for Bayesian inference in models with intractable likelihoods.
194
+
195
+ We selected three variational objectives for SNVI which induce mass-covering behaviour and are, therefore, well suited as a proposal for sampling from complex posterior distributions. We empirically evaluated all of these methods in terms of runtime and accuracy on four benchmark tasks. We found that, while their performance differed when using the raw VI output, they all showed similar performance after an additional, computationally cheap, sampling importance resampling (SIR) step. After the SIR step, all methods had similar accuracy as MCMC, and all methods outperformed a mode-seeking variational objective (reverse KL) which was used in a previously proposed method Wiqvist et al. (2021). Our results suggest that mass-covering VI objectives (regardless of their exact implementation) provide a means to perform fast and accurate inference in models with intractable likelihood, without loss of accuracy compared to MCMC. In Appendix Sec. A.2, we provide technical recommendations for choosing a variational objective for specific problems.
196
+
197
+ A common approach in sequential methods is to use the current posterior estimate as the proposal distribution for the next round, but more elaborate active-learning strategies for choosing new simulations are possible (Papamakarios & Murray, 2016; Papamakarios et al., 2019; Lueckmann et al., 2019a). SNVI can flexibly be combined with any active learning scheme, and unlike neural likelihood(-ratio) methods, does not require expensive MCMC sampling for updating posterior estimates. While this comes at the cost of having to train two neural networks (a likelihood-model and a posterior-model), the cost of training these neural networks is often negligible compared to the cost of simulations. Another method that trains both a likelihood- and a posterior network is Posterior-Aided Regularization (Kim et al., 2021), which regularizes the likelihood-estimate with a simultaneously trained posterior-estimate. This improves the modelling of multimodal posteriors, but the method still requires MCMC and thus scales poorly with the number of samples and dimensions. Likelihood-free variational inference (Tran et al., 2017) avoids learning a likelihood model by learning an implicit posterior distribution, but it requires an adversarial training objective which can be difficult to optimize and requires extensive hyperparameter tuning (Huszár, 2017). Ong et al. (2018) is another method that performs variational inference with a synthetic likelihood, but their approach requires that the summary statistics are approximately Gaussian in order to obtain unbiased estimates of the log-likelihood.
198
+
199
+ Overall, SNVI combines the desirable properties of current methods: It can be combined with any active learning scheme, it can flexibly combine information from multiple datapoints, it returns a posterior distribution that can be sampled quickly, and it can robustly deal with missing data. SNVI speeds up inference relative to MCMC-based methods, sometimes by orders of magnitude, and can perform inference in large models with many parameters. SNVI therefore has potential to provide a new 'go-to' approach for simulation-based inference, and to open up new application domains for simulation-based Bayesian inference.
200
+
201
+ # 6 REPRODUCIBILITY STATEMENT
202
+
203
+ We used the configuration manager hydra to track the configuration and seeds of each run (Yadan, 2019). The results shown in this paper can be reproduced with the git repository https://github.com/mackelab/snvi Repo. The algorithms developed in this work are also available in the sbi toolbox (Tejero-Cantero et al., 2020). All simulations and runs were performed on a high-performance computer. For each run, we used 16 CPU cores (Intel family 6, model 61) and 8GB RAM.
204
+
205
+ # 7 ACKNOWLEDGEMENTS
206
+
207
+ We thank Jan-Matthis Lueckmann for insightful comments on the manuscript. This work was funded by the German Research Foundation (DFG; Germany's Excellence Strategy MLCoE - EXC number 2064/1 PN 390727645) and the German Federal Ministry of Education and Research (BMBF; Tübingen AI Center, FKZ: 01IS18039A).
208
+
209
+ # 8 ETHICS STATEMENT
210
+
211
+ We used data recorded from animal experiments in the crab Cancer borealis. The data we used were recorded for a different, independent study and have recently been made publicly available (Haddad & Marder, 2018; 2021). While simulation-based inference has the potential to greatly accelerate scientific discovery across a broad range of disciplines, one could also imagine undesired use-cases of SBI.
212
+
213
+ # REFERENCES
214
+
215
+ LF Abbott and Eve Marder. Modeling small networks. Methods in Neuronal Modeling, pp. 361-410, 1998.
216
+ Abhinav Agrawal, Daniel Sheldon, and Justin Domke. Advances in black-box vi: Normalizing flows, importance weighting, and optimization. arXiv preprint arXiv:2006.10343, 2020.
217
+ Mark A Beaumont, Wenyang Zhang, and David J Balding. Approximate bayesian computation in population genetics. Genetics, 162(4):2025-2035, 2002.
218
+ Eli Bingham, Jonathan P. Chen, Martin Jankowiak, Fritz Obermeyer, Neeraj Pradhan, Theofanis Karaletsos, Rohit Singh, Paul A. Szerlip, Paul Horsfall, and Noah D. Goodman. Pyro: Deep universal probabilistic programming. J. Mach. Learn. Res., 20:28:1-28:6, 2019.
219
+ Christopher M Bishop. Pattern recognition. Machine learning, 128(9), 2006.
220
+ David M. Blei, Alp Kucukelbir, and Jon D. McAuliffe. Variational inference: A review for statisticians. Journal of the American Statistical Association, 112(518):859-877, Apr 2017.
221
+ Yuri Burda, Roger Grosse, and Ruslan Salakhutdinov. Importance weighted autoencoders. International Conference on Learning Representations, 2016.
222
+ Sourav Chatterjee and Persi Diaconis. The sample size required in importance sampling. The Annals of Applied Probability, 28(2):1099-1135, 2018.
223
+ Yanzhi Chen, Dinghuai Zhang, Michael Gutmann, Aaron Courville, and Zhanxing Zhu. Neural approximate sufficient statistics for implicit models. International Conference on Learning Representations, 2021.
224
+ Kyle Cranmer, Juan Pavez, and Gilles Louppe. Approximating likelihood ratios with calibrated discriminative classifiers. arXiv preprint arXiv:1506.02169, 2015.
225
+ Chris Cremer, Quaid Morris, and David Duvenaud. Reinterpreting importance-weighted autoencoders, 2017.
226
+
227
+ Michael Deistler, Jakob H. Macke, and Pedro J. Gonçalves. Disparate energy consumption despite similar network activity. bioRxiv, 2021.
228
+ Laurent Dinh, Jascha Sohl-Dickstein, and Samy Bengio. Density estimation using real nvp. International Conference in Learning Representations 2017, 2017.
229
+ Justin Domke and Daniel Sheldon. Importance weighting and variational inference. In Proceedings of the 32nd International Conference on Neural Information Processing Systems, pp. 4475-4484, 2018.
230
+ Conor Durkan, Artur Bekasov, Iain Murray, and George Papamakarios. Neural spline flows. Advances in Neural Information Processing Systems, 32:7511-7522, 2019a.
231
+ Conor Durkan, Artur Bekasov, Iain Murray, and George Papamakarios. Neural spline flows. In H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché-Buc, E. Fox, and R. Garnett (eds.), Advances in Neural Information Processing Systems, volume 32. Curran Associates, Inc., 2019b.
232
+ Conor Durkan, Iain Murray, and George Papamakarios. On contrastive learning for likelihood-free inference. In International Conference on Machine Learning, pp. 2771-2781. PMLR, 2020.
233
+ Jerome Friedman. On multivariate goodness-of-fit and two-sample testing. Technical report, Cite-seer, 2004.
234
+ Pedro J Gonçalves, Jan-Matthis Lueckmann, Michael Deistler, Marcel Nonnenmacher, Kaan Öcal, Giacomo Bassetto, Chaitanya Chintaluri, William F Podlaski, Sara A Haddad, Tim P Vogels, et al. Training deep neural density estimators to identify mechanistic models of neural dynamics. *Elife*, 9:e56261, 2020.
235
+ David Greenberg, Marcel Nonnenmacher, and Jakob Macke. Automatic posterior transformation for likelihood-free inference. In International Conference on Machine Learning, pp. 2404-2414, 2019.
236
+ Michael U Gutmann, Ritabrata Dutta, Samuel Kaski, and Jukka Corander. Likelihood-free inference via classification. Statistics and Computing, 28(2):411-425, 2018.
237
+ Sara A. Haddad and Eve Marder. Circuit robustness to temperature perturbation is altered by neuromodulators. Neuron, 100(3):609-623.e3, 2018.
238
+ Sara Ann Haddad and Eve Marder. Recordings from the C. borealis Stomatogastric Nervous System at different temperatures in the decentralized condition, July 2021. URL https://doi.org/10.5281/zenodo.5139650.
239
+ Joeri Hermans, Volodimir Begy, and Gilles Louppe. Likelihood-free mcmc with amortized approximate ratio estimators. In International Conference on Machine Learning, pp. 4239-4248. PMLR, 2020.
240
+ Timothy Classen Hesterberg. Advances in importance sampling. PhD thesis, CiteSeer, 2003.
241
+ Ferenc Huszár. Variational inference using implicit distributions, 2017.
242
+ Ghassen Jerfel, Serena Wang, Clara Fannjiang, Katherine A. Heller, Yian Ma, and Michael I. Jordan. Variational refinement for importance sampling using the forward kullback-leibler divergence, 2021.
243
+ Dongjun Kim, Kyungwoo Song, Seungjae Shin, Wanmo Kang, and Il-Chul Moon. Posterior-aided regularization for likelihood-free inference. arXiv preprint arXiv:2102.07770, 2021.
244
+ Diederik P Kingma and Max Welling. Auto-encoding variational bayes, 2014.
245
+ Durk P Kingma, Tim Salimans, Rafal Jozefowicz, Xi Chen, Ilya Sutskever, and Max Welling. Improved variational inference with inverse autoregressive flow. Advances in neural information processing systems, 29:4743-4751, 2016.
246
+ Y Li and RE Turner. Rényi divergence variational inference. Advances in Neural Information Processing Systems 29 (NIPS 2016), pp. 1073-1081, 2016.
247
+
248
+ David Lopez-Paz and Maxime Oquab. Revisiting classifier two-sample tests. In International Conference on Learning Representations, 2017.
249
+ Jan-Matthis Lueckmann, Pedro J Goncalves, Giacomo Bassetto, Kaan Öcal, Marcel Nonnenmacher, and Jakob H Macke. Flexible statistical inference for mechanistic models of neural dynamics. In Advances in Neural Information Processing Systems, pp. 1289-1299, 2017.
250
+ Jan-Matthis Lueckmann, Giacomo Bassetto, Theofanis Karaletsos, and Jakob H. Macke. Likelihood-free inference with emulator networks. In Francisco Ruiz, Cheng Zhang, Dawen Liang, and Thang Bui (eds.), Proceedings of The 1st Symposium on Advances in Approximate Bayesian Inference, volume 96 of Proceedings of Machine Learning Research, pp. 32-53, 2019a.
251
+ Jan-Matthis Lueckmann, Giacomo Bassetto, Theofanis Karaletsos, and Jakob H Macke. Likelihood-free inference with emulator networks. In Symposium on Advances in Approximate Bayesian Inference, pp. 32-53. PMLR, 2019b.
252
+ Jan-Matthis Lueckmann, Jan Boelts, David Greenberg, Pedro Goncalves, and Jakob Macke. Benchmarking simulation-based inference. In Arindam Banerjee and Kenji Fukumizu (eds.), Proceedings of The 24th International Conference on Artificial Intelligence and Statistics, volume 130 of Proceedings of Machine Learning Research, pp. 343-351. PMLR, 13-15 Apr 2021.
253
+ Benjamin Kurt Miller, Alex Cole, Patrick Forre, Gilles Louppe, and Christoph Weniger. Truncated marginal neural ratio estimation. Advances in Neural Information Processing Systems, 2022.
254
+ Shakir Mohamed and Balaji Lakshminarayanan. Learning in implicit generative models. arXiv preprint arXiv:1610.03483, 2016.
255
+ Radford M Neal. Slice sampling. The annals of statistics, 31(3):705-767, 2003.
256
+ Victor MH Ong, David J Nott, Minh-Ngoc Tran, Scott A Sisson, and Christopher C Drovandi. Variational bayes with synthetic likelihood. Statistics and Computing, 28(4):971-988, 2018.
257
+ George Papamakarios and Iain Murray. Fast $\varepsilon$ -free inference of simulation models with bayesian conditional density estimation. In Advances in Neural Information Processing Systems, pp. 1028-1036, 2016.
258
+ George Papamakarios, Theo Pavlakou, and Iain Murray. Masked autoregressive flow for density estimation. In Proceedings of the 31st International Conference on Neural Information Processing Systems, pp. 2335-2344, 2017.
259
+ George Papamakarios, David Sterratt, and Iain Murray. Sequential neural likelihood: Fast likelihood-free inference with autoregressive flows. In The 22nd International Conference on Artificial Intelligence and Statistics, pp. 837-848, 2019.
260
+ George Papamakarios, Eric Nalisnick, Danilo Jimenez Rezende, Shakir Mohamed, and Balaji Lakshminarayanan. Normalizing flows for probabilistic modeling and inference. Journal of Machine Learning Research, 22(57):1-64, 2021.
261
+ Astrid A Prinz, Cyrus P Billimoria, and Eve Marder. Alternative to hand-tuning conductance-based models: construction and analysis of databases of model neurons. Journal of neurophysiology, 2003.
262
+ Astrid A Prinz, Dirk Bucher, and Eve Marder. Similar network activity from disparate circuit parameters. Nature neuroscience, 7(12):1345-1352, 2004.
263
+ Tom Rainforth, Adam Kosiorek, Tuan Anh Le, Chris Maddison, Maximilian Igl, Frank Wood, and Yee Whye Teh. Tighter variational bounds are not necessarily better. In International Conference on Machine Learning, pp. 4277-4285. PMLR, 2018.
264
+ Rajesh Ranganath, Sean Gerrish, and David Blei. Black box variational inference. In Artificial Intelligence and Statistics, pp. 814-822. PMLR, 2014.
265
+ Danilo Rezende and Shakir Mohamed. Variational inference with normalizing flows. In International conference on machine learning, pp. 1530-1538. PMLR, 2015.
266
+
267
+ Danilo Jimenez Rezende, Shakir Mohamed, and Daan Wierstra. Stochastic backpropagation and approximate inference in deep generative models. In International conference on machine learning, pp. 1278-1286. PMLR, 2014.
268
+ Geoffrey Roeder, Yuhuai Wu, and David K Duvenaud. Sticking the landing: Simple, lower-variance gradient estimators for variational inference. Advances in Neural Information Processing Systems, 30:6925-6934, 2017.
269
+ Donald B Rubin. Using the sir algorithm to simulate posterior distributions. Bayesian statistics, 3: 395-402, 1988.
270
+ Alvaro Tejero-Cantero, Jan Boelts, Michael Deistler, Jan-Matthis Lueckmann, Conor Durkan, Pedro J. Gonçalves, David S. Greenberg, and Jakob H. Macke. sbi: A toolkit for simulation-based inference. Journal of Open Source Software, 5(52):2505, 2020. doi: 10.21105/joss.02505.
271
+ Owen Thomas, Ritabrata Dutta, Jukka Corander, Samuel Kaski, Michael U Gutmann, et al. Likelihood-free inference by ratio estimation. Bayesian Analysis, 2021.
272
+ Dustin Tran, Rajesh Ranganath, and David M Blei. Hierarchical implicit models and likelihood-free variational inference. In Proceedings of the 31st International Conference on Neural Information Processing Systems, pp. 5529-5539, 2017.
273
+ George Tucker, Dieterich Lawson, Shixiang Gu, and Chris J Maddison. Doubly reparameterized gradient estimators for monte carlo objectives. In International Conference on Learning Representations, 2018.
274
+ Neng Wan, Dapeng Li, and Naira Hovakimyan. f-divergence variational inference. Advances in Neural Information Processing Systems, 33, 2020.
275
+ Peter J Wangersky. Lotka-volterra population models. Annual Review of Ecology and Systematics, 9(1):189-218, 1978.
276
+ Samuel Wiqvist, Jes Frellsen, and Umberto Picchini. Sequential neural posterior and likelihood approximation, 2021.
277
+ Simon N. Wood. Statistical inference for noisy nonlinear ecological dynamic systems. Nature, 466 (7310):1102-1104, Aug 2010.
278
+ Omry Yadan. Hydra - a framework for elegantly configuring complex applications. Github, 2019. URL https://github.com/facebookresearch/hydra.
279
+
280
+ # A APPENDIX
281
+
282
+ # A.1 GRADIENTS OF THE DIVERGENCES
283
+
284
+ For completeness, we provide the gradients of the divergences introduced in Sec. 3.2.
285
+
286
+ Forward Kullback-Leibler divergence The gradient estimate is given by
287
+
288
+ $$
289
+ \nabla_ {\phi} \mathcal {L} _ {\mathrm {f K L}} (\phi) = - \mathbb {E} _ {\pmb {\theta} \sim p} \left[ \nabla_ {\phi} \log (q _ {\phi} (\pmb {\theta})) \right] \approx - \sum_ {i = 1} ^ {N} \frac {w (\pmb {\theta} _ {i})}{\sum_ {j = 1} ^ {N} w (\pmb {\theta} _ {j})} \nabla_ {\phi} \log q _ {\phi} (\pmb {\theta} _ {i})
290
+ $$
291
+
292
+ Importance-weighted ELBO A gradient estimator is given by
293
+
294
+ $$
295
+ \nabla_ {\phi} \mathcal {L} _ {I W} ^ {(K)} (\boldsymbol {\phi}) = \mathbb {E} _ {\boldsymbol {\theta} _ {1}, \dots , \boldsymbol {\theta} _ {K} \sim q _ {\phi}} \left[ \sum_ {i = 1} ^ {K} \tilde {w} (\boldsymbol {\theta} _ {i}) \nabla_ {\phi} \log \left(\frac {p (\boldsymbol {x} _ {o} , \boldsymbol {\theta} _ {i})}{q _ {\phi} (\boldsymbol {\theta} _ {i})}\right) \right] \quad \tilde {w} (\boldsymbol {\theta} _ {i}) = \frac {w (\boldsymbol {\theta} _ {i})}{\sum_ {i = 1} ^ {K} w (\boldsymbol {\theta} _ {i})}
296
+ $$
297
+
298
+ where $w(\pmb {\theta}) = p(\pmb{x}_o,\pmb {\theta}) / q_\phi (\pmb {\theta})$
299
+
300
+ Renyi $\alpha$ -divergence A biased gradient estimator using the reparameterization trick can be written as:
301
+
302
+ $$
303
+ \nabla_ {\phi} \mathcal {L} _ {\alpha} (\phi) = \mathbb {E} _ {\pmb {\theta} \sim q _ {\phi}} \left[ \tilde {w} _ {\alpha} (\pmb {\theta}) \nabla_ {\phi} \log \left(\frac {p (\pmb {x} _ {o} , \pmb {\theta})}{q _ {\phi} (\pmb {\theta})}\right) \right] \quad \tilde {w} _ {\alpha} = \frac {w (\pmb {\theta}) ^ {1 - \alpha}}{\mathbb {E} _ {\pmb {\theta} \sim q _ {\phi}} [ w (\pmb {\theta}) ^ {1 - \alpha} ]},
304
+ $$
305
+
306
+ where $w(\pmb{\theta}) = p(\pmb{x}_o, \pmb{\theta}) / q_{\phi}(\pmb{\theta})$ . This gradient estimator is biased towards the rKL but the bias vanishes as more samples are used for the Monte Carlo approximation (Li & Turner, 2016).
307
+
308
+ # A.2 CHOICE OF DIVERGENCE
309
+
310
+ In Fig. 4.2, we demonstrated that all mass-covering objectives perform similarly in terms of accuracy and runtime on the problems we considered. We here give technical recommendations for choosing a variational objective:
311
+
312
+ (i) Closed-form posterior: The variational posterior provides a closed-form approximation to the posterior, but this is no longer the case when SIR is used. While, in our results, all three approaches performed similarly with SIR, they can differ in their performance without it, and the forward KL and the $\alpha$ -divergence provided better approximations than the IW-ELBO. Thus, if one seeks a posterior density that can be evaluated in closed-form, our results suggest to use the forward KL or the $\alpha$ -divergence.
313
+ (ii) Dimensionality of the parameter space: We use an autoregressive normalizing flow as variational family. These flows are very expressive, yet the computation time of their forward or backward passes scale with the dimensionality of $\theta$ (Papamakarios et al., 2017; Kingma et al., 2016; Durkan et al., 2019a). The IW-ELBO and the $\alpha$ -divergences only require forward passes, whereas the forward KL requires forward and backward passes, thus making the forward KL expensive for high-dimensional parameter spaces. The STL estimator used in the IW-ELBO and the $\alpha$ -divergences also requires forward and backward passes. We found that the STL estimator improves performance of the IW-ELBO only weakly (Fig. 11). Thus, in cases where computational cost is critical, our results suggest that using the IW-ELBO without the STL can give high accuracy at low computational cost. Another way to reduce computational cost is to use alternative architectures for the normalizing flow, e.g. coupling layers (Durkan et al., 2019a; Papamakarios et al., 2021).
314
+ (iii) Trading-off the mass-covering property with computational cost: For $\alpha$ -divergences, one can trade-off the extent to which the divergence is mass-covering by choosing the value of $\alpha$ (low $\alpha$ is more mass-covering). As shown in Fig. 11, high values of $\alpha$ benefit less from using the STL estimator. Thus, in cases where mass-covering behavior of the algorithm is less crucial, the STL estimator can be waived, leading to lower computational cost because the normalizing flow requires only forward passes (see point (ii)).
315
+
316
+ ![](images/325d85fb1dd1d687b77efbe81f12b91998e7015cd0bd997e039195ef1e22de29.jpg)
317
+ Figure 5: A Left: Gradient estimation on the Gaussian example. For values of $\mu$ around $\mu^{*} = 4 / 5$ , all estimators provide good gradients. As $\mu$ is farther from $\mu^{*}$ , the forward variational bound (fVB) (grey) vanishes, whereas the self-normalized fVB approaches a constant. Right: SNR for the fVB and the self-normalized fVB. B Theoretical and empirical densities $p_{R}(r)$ for $\mu = 6$ and $\mu = 12$ .
318
+
319
+ ![](images/c27fa5ba8f92949c4e55c16e9b192e7b9ac9e2620bdc5c531f4183112778cda6.jpg)
320
+
321
+ # A.3 OVERCOMING VANISHING GRADIENTS IN THE FORWARD KL ESTIMATOR
322
+
323
+ We use an estimator of the forward Kullback-Leibler divergence (fKL) that is based on self-normalized importance sampling. In this section, we demonstrate that this estimator moves the variational distribution $q_{\phi}(\pmb{\theta})$ towards the target density $p(\pmb{x}_o, \pmb{\theta})$ even if $q_{\phi}(\pmb{\theta})$ and $p(\pmb{x}_o, \pmb{\theta})$ differ strongly.
324
+
325
+ For this analysis, we consider a Gaussian toy example with prior $p(\pmb{\theta}) = \mathcal{N}(\pmb{\theta}; 0, 4)$ , likelihood $p(\pmb{x}|\pmb{\theta}) = \mathcal{N}(\pmb{x}; \pmb{\theta}, 1)$ , and observation $\pmb{x}_o = 1$ . The posterior distribution can be computed in closed-form as $p(\pmb{\theta}|\pmb{x}_o) = \mathcal{N}(\pmb{\theta}; 4/5, 4/5)$ . We aim to learn the posterior distribution using variational inference with the variational family $q_{\mu}(\pmb{\theta}) = \mathcal{N}(\mu, 4/5)$ (note that $\mu$ is the only parameter). The best approximation within this family is $\mu^* = 4/5$ .
326
+
327
+ We use this toy example to compare the gradient and the signal-to-noise ratio (SNR) of the self-normalized fKL estimator to the fKL estimator introduced by Wan et al. (2020). Fig. 5A (left) shows the gradient of the loss for different values of $\mu$ . When $\mu \approx \mu^{*} = 4/5$ , the fKL (gray) without self-normalization closely matches the true gradient (red). However, as $\mu$ is further from $\mu^{*}$ , the fKL first points in the wrong direction and then vanishes, which prevents learning. The self-normalized fKL (blue, orange, green) closely matches the gradient around $\mu \approx \mu^{*} = 4/5$ and does not vanish for $\mu$ that are far from $\mu^{*}$ . The gradient is stronger if more samples $N$ are used to approximate the fKL. Similarly, the $\mathrm{SNR}(\nabla_{\phi}\mathcal{L}(\phi)) = |\mathbb{E}[\nabla_{\phi}\mathcal{L}(\phi)] / \sqrt{\mathrm{Var}(\nabla_{\phi}\mathcal{L}(\phi))}|$ does not vanish for $\mu$ that are far from $\mu^{*}$ for the self-normalized fKL.
328
+
329
+ To understand this behaviour of the self-normalized fKL, we computed an approximation to the gradient $\nabla_{\mu}\mathcal{L}_{\mathrm{fKL}}(\mu)$ in this toy example. The fKL loss is given as:
330
+
331
+ $$
332
+ \nabla_ {\mu} \mathcal {L} _ {\mathrm {f K L}} (\mu) = - \mathbb {E} _ {\pmb {\theta} \sim q _ {\phi}} \left[ \frac {w (\pmb {\theta})}{\sum_ {i = 1} ^ {N} w (\pmb {\theta})} \nabla_ {\mu} \log q _ {\mu} (\pmb {\theta}) \right] \approx - \sum_ {i = 1} ^ {N} \frac {w (\pmb {\theta} _ {i})}{\sum_ {i = 1} ^ {N} w (\pmb {\theta} _ {i})} \nabla_ {\mu} \log q _ {\mu} (\pmb {\theta} _ {i})
333
+ $$
334
+
335
+ with weights $w(\pmb{\theta}_i) = \frac{p(\pmb{x}_o, \pmb{\theta})}{q_\phi(\pmb{\theta})}$ . In the case where $q_{\phi}(\pmb{\theta})$ differs strongly from $p(\pmb{x}_o, \pmb{\theta})$ , the weights are often degenerate, i.e. the strongest weight is much larger than all others. In the worst case, $\tilde{w}(\pmb{\theta}_i) = \frac{w(\pmb{\theta}_i)}{\sum_{i=1}^N w(\pmb{\theta}_i)} = 1$ for some $i$ and the gradient estimator reduces to
336
+
337
+ $$
338
+ \nabla_ {\mu} \mathcal {L} _ {\mathrm {f K L}} (\mu) = - \nabla_ {\mu} \log q _ {\mu} (\underset {\boldsymbol {\theta} _ {1}, \ldots , \boldsymbol {\theta} _ {N}} {\arg \max } w (\boldsymbol {\theta})) = - \nabla_ {\mu} \log q _ {\mu} (r)
339
+ $$
340
+
341
+ The gradient of $\mu$ is thus determined by $r = \arg \max_{\theta_1,\dots,\theta_N}w(\pmb {\theta})$ , which itself can be considered a draw from a random variable $R$ . We will now derive the probability density $p_R(r)$ of $R$ .
342
+
343
+ Algorithm 2: SIR
344
+ 1 Input: $K$ the number of importance samples, proposal $q_{\phi}$ , joint density $p(\boldsymbol{x}_o,\boldsymbol{\theta}) = \ell_\psi (\boldsymbol{x}_o|\boldsymbol {\theta})p(\boldsymbol {\theta})$
345
+ 2 for $i\in [1,\dots ,K]$ do
346
+ 3 $\begin{array}{l}\pmb {\theta}_i\sim q_\phi (\pmb {\theta})\\ w_i = \frac{p(\pmb{x}_o,\pmb{\theta}_i)}{q_\phi(\pmb{\theta}_i)} \end{array}$
347
+ 4 end
348
+ 6 Each $\tilde{w}_i = w_i / \sum_{k = 1}^K w_k$
349
+ 7 $j\sim$ Categorical $(\tilde{w})$
350
+ 8 return $\pmb{\theta}_{j}$
351
+
352
+ If $\mu >\mu^{*}$ , then $w(\pmb {\theta})$ is monotonically decreasing in $\pmb{\theta}$ because $w(\pmb {\theta})\propto \frac{\mathcal{N}(\pmb{\theta};\mu^{*},4 / 5)}{\mathcal{N}(\pmb{\theta};\mu,4 / 5)}\propto \exp (5 / 4\cdot \pmb {\theta}(\mu^{*} - \mu))$ . The cumulative distribution function $F_{R}(R\leq r)$ can then be written as
353
+
354
+ $$
355
+ \begin{array}{l} F_{R}(R\leq r) = P(\underset {\boldsymbol{\theta}_{1},\ldots ,\boldsymbol{\theta}_{n}}{\arg \max}w(\boldsymbol {\theta})\leq r) = P(\min (\boldsymbol{\theta}_{1},\ldots ,\boldsymbol{\theta}_{n})\leq r) \\ = 1 - P \left(\min \left(\boldsymbol {\theta} _ {1}, \dots , \boldsymbol {\theta} _ {n}\right) > r\right) = 1 - \prod_ {i = 1} ^ {N} P \left(\boldsymbol {\theta} _ {i} > r\right) \\ = 1 - \left(1 - F _ {q _ {\phi}} (r)\right) ^ {N} \\ \end{array}
356
+ $$
357
+
358
+ Thus, $R$ has the density $p_{R}(r) = \frac{d}{dr} F(R\leq r) = N(1 - F_{q_{\phi}}(r))^{N - 1}q_{\mu}(r)$ . The derivation is analogous for the case $\mu < \mu^{*}$ . Because $\nabla_{\mu}\mathcal{L}_{\mathrm{fKL}}(\mu) = \nabla_{\mu}\log q_{\mu}(r)$ for $r\sim p_R$ , this allows us to compute the distribution of the gradient of $\mu$ (under the assumption that weights are degenerate).
359
+
360
+ We empirically validate this result on the Gaussian toy example. Fig. 5B (left) shows the true posterior distribution (black), the variational density $q_{\mu}(\pmb{\theta})$ for $\mu = 6$ and $\mu = 10$ and the corresponding $p_R(r)$ for $N = 1000$ . The theoretically computed density $p_R(r)$ (dashed lines) matches the empirically observed distribution of $\arg \max_{\pmb{\theta}_{i} = 1\dots N} w(\pmb{\theta}_{i})$ . For almost every value of $r \sim p_R(r)$ , the gradient $\nabla_{\mu} \log q_{\mu}(r)$ is negative, thus driving $\nabla_{\mu} \mathcal{L}_{\mathrm{fKL}}(\mu)$ into the correct direction. For larger $N$ , the distribution $p_R(r)$ shifts towards the true posterior distribution and thus also the gradient signal increases.
361
+
362
+ Notably, for $\mu$ that are even further from $\mu^{*}$ , $\nabla_{\mu} \log q_{\mu}(r)$ remains relatively constant (Fig. 5B, right). This explains why the gradient $\nabla_{\mu} \mathcal{L}_{\mathrm{fKL}}(\mu)$ becomes constant in Fig. 5A (left).
363
+
364
+ # A.4 IMPROVEMENT THROUGH SIR
365
+
366
+ We use Sampling Importance Resampling (SIR) to refine samples obtained from the variational posterior. The SIR procedure is detailed in Alg. 2 for drawing a single sample from the posterior. Consistent with Agrawal et al. (2020), we found that using SIR always helps to improve the approximation quality even when using complex variational families such as normalizing flows (compare dotted and solid lines in Fig. 3).
367
+
368
+ We visualize the benefits of SIR in Fig. 6 on an example which uses a Gaussian proposal distribution (i.e. variational family). SIR enhances the variational family and allows to approximate the bimodal target distribution. SIR particularly improves the posterior estimate when the proposal (i.e. the variational posterior) is overdispersed. This provides an explanation for why SIR is particularly useful for the mass-covering divergences used in SNVI, and less so for mode-covering divergences (as used in SNPLA).
369
+
370
+ # A.5 QUALITY OF THE LIKELIHOOD ESTIMATOR
371
+
372
+ The estimated variational posterior is based on the estimated likelihood $\ell(\pmb{x}_o|\pmb{\theta})$ . It is thus important to accurately learn the likelihood from simulations. To be able to learn skewed or bimodal likelihoods, we use a conditional autoregressive normalizing flow for $\ell(\pmb{x}|\pmb{\theta})$ (Papamakarios et al., 2017; Kingma et al., 2016; Durkan et al., 2019a). Fig. 7 demonstrates that these flows can learn complex likelihoods (Papamakarios et al., 2019).
373
+
374
+ ![](images/e7df72a7f54e2d2965cca40282f678265e58146fdcb13935024041580a305bf7.jpg)
375
+ Figure 6: Visualization of SIR. A Toy example with a Gaussian proposal density. Left: Two toy examples with a Gaussian (top) or bimodal (bottom) target density. SIR (with $K = 32$ ) can extend the Gaussian density and refine the approximation if the proposal is overdispersed (middle), but helps less when it is too narrow (right). B SIR improvements on two moons example. We plot the joint density as learned by the likelihood-model $p(\pmb{x}_o, \pmb{\theta}) = \ell_{\psi}(\pmb{x}_o | \pmb{\theta}) p(\pmb{\theta})$ against the variational posterior $q_{\phi}$ (blue, obtained with the fKL), as well as the SIR-corrected density with $K = 2$ (orange) and $K = 32$ (green). Despite using an expressive normalizing flow as $q_{\phi}$ , SIR improves the accuracy.
376
+
377
+ ![](images/454c71ef7844fc3e27b954f8ae9a984a143d9bbaab44dc6513dd696e61a5f199.jpg)
378
+
379
+ ![](images/58a8602b1d82f2085d4882ea678239296facd1ba062d21e68f91128d5d4e3eeb.jpg)
380
+
381
+ ![](images/b25b4e326d28224221f101e2f453c92815a08d20af52fc36da23f664ef02d47b.jpg)
382
+
383
+ ![](images/b1bac6424f2ad25fd0b959609052a15b0459c41208ddd443029443558293305e.jpg)
384
+
385
+ ![](images/f125b9bb50eb54000f4fbff0c7959a5bb59af7296d7e62ad3f7d0dce91a1bdc1.jpg)
386
+
387
+ ![](images/0466c086e08fc677ab2d7f2ca2cb01c45d95c925eef5b759ef9d66515728629b.jpg)
388
+ Figure 7: A neural spline flow (NSF) estimating a bimodal likelihood with $10^{4}$ simulations with prior $\mathcal{N}(0,2)$ . Top: Ground truth. Bottom: Likelihood-approximation with NSF. The learned likelihood closely matches the true likelihood.
389
+
390
+ ![](images/4fc9e466bdf634d90e653a46f9481ed378c6a94fe2f798ef66deeb677ef4ab97.jpg)
391
+
392
+ # A.6 PROOFS FOR EXCLUDING INVALID DATA
393
+
394
+ Many simulators can produce unreasonable or undefined values when fed with parameters sampled from the prior (Lueckmann et al., 2017). These invalid simulations are not useful for accurately learning the likelihood, and we would like to ignore them. To do so, we developed a loss-reweighing strategy.
395
+
396
+ Algorithm 3: SNVI with calibration kernel
397
+ 1 Inputs: prior $p(\theta)$ , observation $x_o$ , divergence $D$ , simulations per round $N$ , number of rounds $R$ , selection strategy $S$ and calibration kernel $K$ .
398
+ 2 Outputs: Approximate likelihood $\ell_{\psi}$ , variational posterior $q_{\phi}$ and calibration network $c_{\zeta}$ .
399
+ 3 Initialize: Proposal $\tilde{p}(\theta) = p(\theta)$ , simulation dataset $\mathcal{X} = \{\}$ , calibration dataset $C = \{\}$
400
+ 4 for $r \in [1, \dots, R]$ do
401
+ 5 for $i \in [1, \dots, N]$ do
402
+ 6 $\theta_i = S(\tilde{p}, \ell_{\phi}, p)$ ; // sample $\theta_i \sim \tilde{p}(\theta)$
403
+ 7 simulate $x_i \sim p(x|\theta_i)$ ; // run the simulator on $\theta_i$
404
+ 8 add $(\theta_i, K(x_i, x_o))$ to $C$
405
+ 9 if $K(x, x_o) > 0$ then
406
+ 10 | add $(\theta_i, x_i)$ to $X$
407
+ 11 end
408
+ 12 end
409
+ 13 (re-)train $\ell_{\psi}$ ; $\psi^* = \arg \min_{\psi} -\frac{1}{N}\sum_{(x_i,\theta_i)\in X}K(x_i,x_o)\log\ell_{\psi}(x_i|\theta_i)$ ; // or SNRE
410
+ 14 (re-)train $c_{\zeta}$ ; $\xi^* = \arg \min_{\xi}\frac{1}{N}\sum_{(\theta_i,K(x_i,x_o))\in\mathcal{C}}\mathcal{L}(c_{\zeta}(\theta_i),K(x_i,x_o))$ ; // MSE or cross-entropy for binary calibration kernel
411
+ 15 (re-)train $q_{\phi}$ ; $\phi^* = \arg \min_{\phi}D(q_{\phi}(\theta)||p(\theta|x_o))$ with
412
+ 16 $p(\theta|x_o) \propto p(x_o|\theta)p(\theta) \approx \ell_{\psi^*}(x_o|\theta)c_{\xi^*}(\theta)p(\theta)$
413
+ 17 end
414
+
415
+ We formulate the exclusion of invalid simulations by the means of a calibration kernel $K(\pmb{x}, \pmb{x}_o)$ (originally introduced for neural posterior estimation in Lueckmann et al. (2017)). This calibration kernel can be any function, and can thus be used beyond excluding invalid data. The case of excluding invalid simulations can be recovered by using a binary calibration kernel:
416
+
417
+ $$
418
+ K \left(\boldsymbol {x}, \boldsymbol {x} _ {o}\right) = \left\{ \begin{array}{l l} 0 & \text {i f} \boldsymbol {x} \text {i n v a l i d} \\ 1 & \text {i f} \boldsymbol {x} \text {v a l i d} \end{array} \right. \tag {1}
419
+ $$
420
+
421
+ Alg. 3 shows SNVI with calibration kernel. Notice that, in the case of a binary calibration kernel, the loss for the likelihood $\ell_{\psi}$ ; $\psi^{*} = \arg \min_{\psi} - \frac{1}{N}\sum_{(\boldsymbol{x}_{i},\boldsymbol{\theta}_{i})\in \mathcal{X}}K(\boldsymbol{x}_{i},\boldsymbol{x}_{o})\log \ell_{\psi}(\boldsymbol{x}_{i}|\boldsymbol{\theta}_{i})$ is zero for all invalid simulations (because $K(\boldsymbol{x},\boldsymbol{x}_o) = 0$ ). Thus, since these simulations do not contribute to the loss, we exclude these simulations from the dataset that is used to train the likelihood(-ratio) model.
422
+
423
+ Below, we provide proofs of convergence for Alg. 3. Theorem 1 and Lemma 1 are relevant to SNLVI, Theorem 2 and Lemma 2 are relevant to SNRVI, and Lemma 3 is relevant to both methods. Theorem 1 and Theorem 2 provide a means to use a calibration kernel in the training of the likelihood(ratio)-model such that one can still recover the posterior density. In SNVI, we sample from the (unnormized) potential function with variational inference. However, one can also use Theorem 1 and Theorem 2 in combination with SNLE and SNRE and draw samples from the potential function with MCMC.
424
+
425
+ Both SNLVI and SNRVI with calibration kernels rely on the estimation of $\mathbb{E}_{\boldsymbol{x} \sim p(\boldsymbol{x}|\boldsymbol{\theta})}[K(\boldsymbol{x}, \boldsymbol{x}_o)]$ (note that this turns into $p(\mathrm{valid}|\boldsymbol{\theta})$ for the binary calibration kernel). We estimate this term with a feed-forward regression neural network $c_{\zeta}(\boldsymbol{\theta})$ (see Lemma 3). The network is trained on pairs $(\boldsymbol{\theta}, K(\boldsymbol{x}, \boldsymbol{x}_o))$ , where $\boldsymbol{\theta}$ and $\boldsymbol{x}$ are the same pairs as used for training the likelihood(-ratio)-model. For general calibration kernels $K(\boldsymbol{x}, \boldsymbol{x}_o)$ , we use a mean-squared error loss, whereas in the case of invalid data, we parameterize $c_{\zeta}(\boldsymbol{\theta})$ as a logistic regression network and train it with a cross-entropy loss (since the calibration kernel $K(\boldsymbol{x}, \boldsymbol{x}_o)$ is a binary function: 0 for invalid data, 1 for valid data).
426
+
427
+ Theorem 1. Let $K: \mathcal{X} \times \mathcal{X} \to \mathbb{R}^+$ be a kernel. Let $\ell_{\psi^*}(\pmb{x}|\pmb{\theta})$ be the maximizer of the objective
428
+
429
+ $$
430
+ \mathcal {L} = \mathbb {E} _ {\boldsymbol {\theta}, \boldsymbol {x} \sim \tilde {p} (\boldsymbol {\theta}, \boldsymbol {x})} [ K (\boldsymbol {x}, \boldsymbol {x} _ {o}) \log (\ell_ {\psi} (\boldsymbol {x} | \boldsymbol {\theta})) ]
431
+ $$
432
+
433
+ and let $c_{\zeta^{*}}(\pmb {\theta})$ be the minimizer of
434
+
435
+ $$
436
+ \mathcal {L} = \mathbb {E} _ {\boldsymbol {\theta}, \boldsymbol {x} \sim \tilde {p} (\boldsymbol {\theta}, \boldsymbol {x})} \left[ \left(c _ {\zeta} (\boldsymbol {\theta}) - K \left(\boldsymbol {x}, \boldsymbol {x} _ {o}\right)\right) ^ {2} \right]
437
+ $$
438
+
439
+ Then the potential function
440
+
441
+ $$
442
+ \mathcal {P} (\boldsymbol {\theta}) = \ell_ {\psi^ {*}} \left(\boldsymbol {x} _ {o} | \boldsymbol {\theta}\right) p (\boldsymbol {\theta}) c _ {\zeta^ {*}} (\boldsymbol {\theta})
443
+ $$
444
+
445
+ is proportional to the posterior density $p(\pmb{\theta}|\pmb{x}_o)$ .
446
+
447
+ Proof. Using Lemma 1 and Lemma 3, we get
448
+
449
+ $$
450
+ \begin{array}{l} \mathcal {P} (\boldsymbol {\theta}) = \ell_ {\psi^ {*}} \left(\boldsymbol {x} _ {o} | \boldsymbol {\theta}\right) p (\boldsymbol {\theta}) c _ {\zeta^ {*}} (\boldsymbol {\theta}) \\ = \frac {K (\boldsymbol {x} , \boldsymbol {x} _ {o}) p (\boldsymbol {x} _ {o} | \boldsymbol {\theta})}{\mathbb {E} _ {\boldsymbol {x} \sim p (\boldsymbol {x} | \boldsymbol {\theta})} [ K (\boldsymbol {x} , \boldsymbol {x} _ {o}) ]} p (\boldsymbol {\theta}) \mathbb {E} _ {\boldsymbol {x} \sim p (\boldsymbol {x} | \boldsymbol {\theta})} [ K (\boldsymbol {x}, \boldsymbol {x} _ {o}) ] \\ = K (\boldsymbol {x}, \boldsymbol {x} _ {o}) p (\boldsymbol {x} _ {o} | \boldsymbol {\theta}) p (\boldsymbol {\theta}) \\ \propto p (\boldsymbol {\theta} \mid \boldsymbol {x} _ {o}) \\ \end{array}
451
+ $$
452
+
453
+ ![](images/5bce6286b5fe4351fc4627b640a824a4d712c500883626d5adb21749c050007f.jpg)
454
+
455
+ Theorem 2. Let $K:\mathcal{X}\times \mathcal{X}\to \mathbb{R}^{+}$ be a kernel. Let $\ell_{\psi^*}(\pmb {x},\pmb {\theta})$ be the minimizer of the objective
456
+
457
+ $$
458
+ \mathcal {L} = \mathbb {E} _ {\boldsymbol {\theta}, \boldsymbol {x} \sim \tilde {p} (\boldsymbol {\theta}, \boldsymbol {x})} [ K (\boldsymbol {x}, \boldsymbol {x} _ {o}) \log (\ell_ {\psi^ {*}} (\boldsymbol {x}, \boldsymbol {\theta})) ] + \mathbb {E} _ {\boldsymbol {\theta}, \boldsymbol {x} \sim p (\boldsymbol {\theta}) p (\boldsymbol {x})} [ K (\boldsymbol {x}, \boldsymbol {x} _ {o}) \log (1 - \ell_ {\psi^ {*}} (\boldsymbol {x}, \boldsymbol {\theta})) ]
459
+ $$
460
+
461
+ and let $c_{\zeta^{*}}(\pmb {\theta})$ be the minimizer of
462
+
463
+ $$
464
+ \mathcal {L} = \mathbb {E} _ {\boldsymbol {\theta}, \boldsymbol {x} \sim \tilde {p} (\boldsymbol {\theta}, \boldsymbol {x})} \left[ \left(c _ {\zeta} (\boldsymbol {\theta}) - K \left(\boldsymbol {x}, \boldsymbol {x} _ {o}\right)\right) ^ {2} \right]
465
+ $$
466
+
467
+ Then the potential function
468
+
469
+ $$
470
+ \mathcal {P} (\boldsymbol {\theta}) = \ell_ {\psi^ {*}} (\boldsymbol {x} _ {o}, \boldsymbol {\theta}) p (\boldsymbol {\theta}) c _ {\zeta^ {*}} (\boldsymbol {\theta})
471
+ $$
472
+
473
+ is proportional to the posterior density $p(\boldsymbol{\theta}|\boldsymbol{x}_o)$ .
474
+
475
+ Proof. Using Lemma 2 and Lemma 3, we get
476
+
477
+ $$
478
+ \begin{array}{l} \mathcal {P} (\boldsymbol {\theta}) = \ell_ {\psi^ {*}} \left(\boldsymbol {x} _ {o}, \boldsymbol {\theta}\right) p (\boldsymbol {\theta}) c _ {\zeta^ {*}} (\boldsymbol {\theta}) \\ = \frac {\mathbb {E} _ {\boldsymbol {x} \sim p (\boldsymbol {x})} [ K (\boldsymbol {x} , \boldsymbol {x} _ {o}) ]}{\mathbb {E} _ {\boldsymbol {x} \sim p (\boldsymbol {x} | \boldsymbol {\theta})} [ K (\boldsymbol {x} , \boldsymbol {x} _ {o}) ]} \frac {p (\boldsymbol {x} _ {o} | \boldsymbol {\theta})}{p (\boldsymbol {x} _ {o})} p (\boldsymbol {\theta}) \mathbb {E} _ {\boldsymbol {x} \sim p (\boldsymbol {x} | \boldsymbol {\theta})} [ K (\boldsymbol {x}, \boldsymbol {x} _ {o}) ] \\ = \mathbb {E} _ {\boldsymbol {x} \sim p (\boldsymbol {x})} [ K (\boldsymbol {x}, \boldsymbol {x} _ {o}) ] \frac {p (\boldsymbol {x} _ {o} | \boldsymbol {\theta})}{p (\boldsymbol {x} _ {o})} p (\boldsymbol {\theta}) \\ \propto p (\boldsymbol {\theta} | \boldsymbol {x} _ {o}) \\ \end{array}
479
+ $$
480
+
481
+ ![](images/c4a76435081b9b24bc17a4c8f5f26f250901bdc052ca61eb8b7f66fb61957a34.jpg)
482
+
483
+ Lemma 1. Let $K: \mathcal{X} \times \mathcal{X} \to \mathbb{R}^+$ be an arbitrary kernel. Then, the objective
484
+
485
+ $$
486
+ \mathcal {L} = \mathbb {E} _ {\boldsymbol {\theta}, \boldsymbol {x} \sim \tilde {p} (\boldsymbol {\theta}, \boldsymbol {x})} [ K (\boldsymbol {x}, \boldsymbol {x} _ {o}) \log (\ell_ {\psi} (\boldsymbol {x} | \boldsymbol {\theta})) ]
487
+ $$
488
+
489
+ is maximized if and only if $\ell_{\psi}(\pmb{x}|\pmb{\theta}) = \frac{1}{Z(\pmb{\theta})} K(\pmb{x},\pmb{x}_o)p(\pmb{x}|\pmb{\theta})$ for all $\pmb{\theta} \in \text{support}(\tilde{p}(\pmb{\theta}))$ , with normalizing constant $Z(\pmb{\theta}) = \int K(\pmb{x},\pmb{x}_o)p(\pmb{x}|\pmb{\theta})d\pmb{x} = \mathbb{E}_{\pmb{x} \sim p(\pmb{x}|\pmb{\theta})}[K(\pmb{x},\pmb{x}_o)]$ .
490
+
491
+ Proof.
492
+
493
+ $$
494
+ \begin{array}{l} \mathcal {L} = \mathbb {E} _ {\boldsymbol {\theta}, \boldsymbol {x} \sim \tilde {p} (\boldsymbol {\theta}, \boldsymbol {x})} [ K (\boldsymbol {x}, \boldsymbol {x} _ {o}) \log (\ell_ {\psi} (\boldsymbol {x} | \boldsymbol {\theta})) ] \\ = \iint K (\boldsymbol {x}, \boldsymbol {x} _ {o}) \tilde {p} (\boldsymbol {\theta}, \boldsymbol {x}) \log \left(\ell_ {\psi} (\boldsymbol {x} | \boldsymbol {\theta})\right) d \boldsymbol {x} d \boldsymbol {\theta} \\ = \iint K (\boldsymbol {x}, \boldsymbol {x} _ {o}) \tilde {p} (\boldsymbol {\theta}) p (\boldsymbol {x} | \boldsymbol {\theta}) \log \left(\ell_ {\psi} (\boldsymbol {x} | \boldsymbol {\theta})\right) d \boldsymbol {x} d \boldsymbol {\theta} \\ = \int \tilde {p} (\boldsymbol {\theta}) \int K (\boldsymbol {x}, \boldsymbol {x} _ {o}) p (\boldsymbol {x} | \boldsymbol {\theta}) \log \left(\ell_ {\psi} (\boldsymbol {x} | \boldsymbol {\theta})\right) d \boldsymbol {x} d \boldsymbol {\theta} \\ \end{array}
495
+ $$
496
+
497
+ Since $\int K(\pmb{x},\pmb{x}_o)p(\pmb{x}|\pmb{\theta})\log (\ell_{\psi}(\pmb{x}|\pmb{\theta}))d\pmb{x}\propto -D_{\mathrm{KL}}(\frac{1}{Z(\pmb{\theta})} K(\pmb{x},\pmb{x}_o)p(\pmb{x}|\pmb{\theta}),\ell_{\psi}(\pmb{x}|\pmb{\theta}))$ , this term is maximized if and only if $\ell_{\psi}(\pmb {x}|\pmb {\theta}) = \frac{1}{Z(\pmb{\theta})} K(\pmb {x},\pmb{x}_o)p(\pmb {x}|\pmb {\theta})$ for all $\pmb {\theta}\in \operatorname {supp}(p(\pmb {\theta}))$ with $Z(\pmb {\theta}) =$ $\int K(\pmb {x},\pmb {x}_o)p(\pmb {x}|\pmb {\theta})d\pmb {x} = \mathbb{E}_{\pmb{x}\sim p(\pmb {x}|\pmb {\theta})}[K(\pmb {x},\pmb {x}_o)]$
498
+
499
+ Lemma 2. Let $K: \mathcal{X} \times \mathcal{X} \to \mathbb{R}^+$ be an arbitrary kernel. Then, the objective
500
+
501
+ $$
502
+ \mathcal {L} = \mathbb {E} _ {\boldsymbol {\theta}, \boldsymbol {x} \sim \tilde {p} (\boldsymbol {\theta}, \boldsymbol {x})} \left[ K (\boldsymbol {x}, \boldsymbol {x} _ {o}) \log (\ell_ {\psi^ {*}} (\boldsymbol {x}, \boldsymbol {\theta})) \right] + \mathbb {E} _ {\boldsymbol {\theta}, \boldsymbol {x} \sim \tilde {p} (\boldsymbol {\theta}) p (\boldsymbol {x})} \left[ K (\boldsymbol {x}, \boldsymbol {x} _ {o}) \log (1 - \ell_ {\psi^ {*}} (\boldsymbol {x}, \boldsymbol {\theta})) \right]
503
+ $$
504
+
505
+ is minimized if and only if $\ell_{\psi}(\pmb{x},\pmb{\theta}) = \frac{\mathbb{E}_{\pmb{x}\sim p(\pmb{x})}[K(\pmb{x},\pmb{x}_o)]}{\mathbb{E}_{\pmb{x}\sim p(\pmb{x}|\pmb{\theta})}[K(\pmb{x},\pmb{x}_o)]}\frac{p(\pmb{x}|\pmb{\theta})}{p(\pmb{x})}$ for all $\pmb{\theta} \in \text{support}(\tilde{p}(\pmb{\theta}))$ .
506
+
507
+ Proof. We begin by rearranging the expectations:
508
+
509
+ $$
510
+ \begin{array}{l} \mathcal {L} = \mathbb {E} _ {\boldsymbol {\theta}, \boldsymbol {x} \sim \tilde {p} (\boldsymbol {\theta}, \boldsymbol {x})} [ K (\boldsymbol {x}, \boldsymbol {x} _ {o}) \log (\ell_ {\psi^ {*}} (\boldsymbol {x}, \boldsymbol {\theta})) ] + \mathbb {E} _ {\boldsymbol {\theta}, \boldsymbol {x} \sim \tilde {p} (\boldsymbol {\theta}) \tilde {p} (\boldsymbol {x})} [ K (\boldsymbol {x}, \boldsymbol {x} _ {o}) \log (1 - \ell_ {\psi^ {*}} (\boldsymbol {x}, \boldsymbol {\theta})) ] \\ = \iint \tilde {p} (\boldsymbol {\theta}, \boldsymbol {x}) K (\boldsymbol {x}, \boldsymbol {x} _ {o}) \log \left(\ell_ {\psi^ {*}} (\boldsymbol {x}, \boldsymbol {\theta})\right) d \boldsymbol {\theta} d \boldsymbol {x} + \\ \iint \tilde {p} (\boldsymbol {\theta}) \tilde {p} (\boldsymbol {x}) K (\boldsymbol {x}, \boldsymbol {x} _ {o}) \log (1 - \ell_ {\psi^ {*}} (\boldsymbol {x}, \boldsymbol {\theta})) d \boldsymbol {\theta} d \boldsymbol {x} \\ = \iint \frac {\tilde {p} (\boldsymbol {\theta} , \boldsymbol {x}) K (\boldsymbol {x} , \boldsymbol {x} _ {o})}{\iint \tilde {p} (\boldsymbol {\theta} , \boldsymbol {x}) K (\boldsymbol {x} , \boldsymbol {x} _ {o}) d \boldsymbol {\theta} d \boldsymbol {x}} \log \left(\ell_ {\psi^ {*}} (\boldsymbol {x}, \boldsymbol {\theta})\right) d \boldsymbol {\theta} d \boldsymbol {x} + \\ \iint \frac {\tilde {p} (\boldsymbol {\theta}) \tilde {p} (\boldsymbol {x}) K (\boldsymbol {x} , \boldsymbol {x} _ {o})}{\iint \tilde {p} (\boldsymbol {\theta}) \tilde {p} (\boldsymbol {x}) K (\boldsymbol {x} , \boldsymbol {x} _ {o}) d \boldsymbol {\theta} d \boldsymbol {x}} \log (1 - \ell_ {\psi^ {*}} (\boldsymbol {x}, \boldsymbol {\theta})) d \boldsymbol {\theta} d \boldsymbol {x} \\ = \mathbb {E} _ {\boldsymbol {\theta}, \boldsymbol {x} \sim \pi_ {\text {j o i n t}} (\boldsymbol {\theta}, \boldsymbol {x})} \left[ \log \left(\ell_ {\psi^ {*}} (\boldsymbol {x}, \boldsymbol {\theta})\right) \right] + \mathbb {E} _ {\boldsymbol {\theta}, \boldsymbol {x} \sim \pi_ {\text {m a r g i n a l}} (\boldsymbol {\theta}, \boldsymbol {x})} \left[ \log \left(1 - \ell_ {\psi^ {*}} (\boldsymbol {x}, \boldsymbol {\theta})\right) \right] \\ \end{array}
511
+ $$
512
+
513
+ where we introduced
514
+
515
+ $$
516
+ \pi_ {\text {j o i n t}} (\boldsymbol {\theta}, \boldsymbol {x}) = \frac {\tilde {p} (\boldsymbol {\theta} , \boldsymbol {x}) K (\boldsymbol {x} , \boldsymbol {x} _ {o})}{\iint \tilde {p} (\boldsymbol {\theta} , \boldsymbol {x}) K (\boldsymbol {x} , \boldsymbol {x} _ {o}) d \boldsymbol {\theta} d \boldsymbol {x}} \quad \pi_ {\text {m a r g i n a l}} (\boldsymbol {\theta}, \boldsymbol {x}) = \frac {\tilde {p} (\boldsymbol {\theta}) \tilde {p} (\boldsymbol {x}) K (\boldsymbol {x} , \boldsymbol {x} _ {o})}{\iint \tilde {p} (\boldsymbol {\theta}) \tilde {p} (\boldsymbol {x}) K (\boldsymbol {x} , \boldsymbol {x} _ {o})}
517
+ $$
518
+
519
+ Since binary classification recovers density ratios (Cranmer et al., 2015; Mohamed & Lakshminarayanan, 2016; Gutmann et al., 2018), we get
520
+
521
+ $$
522
+ \begin{array}{l} \ell_ {\psi *} (\boldsymbol {x}, \boldsymbol {\theta}) = \frac {\pi_ {\text {j o i n t}} (\boldsymbol {\theta} , \boldsymbol {x})}{\pi_ {\text {m a r g i n a l}} (\boldsymbol {\theta} , \boldsymbol {x})} \\ = \frac {\frac {1}{\iint \tilde {p} (\boldsymbol {\theta} , \boldsymbol {x}) K (\boldsymbol {x} , \boldsymbol {x} _ {o}) d \boldsymbol {\theta} d \boldsymbol {x}} \tilde {p} (\boldsymbol {\theta} , \boldsymbol {x}) K (\boldsymbol {x} , \boldsymbol {x} _ {o})}{\frac {1}{\iint \tilde {p} (\boldsymbol {\theta}) p (\boldsymbol {x}) K (\boldsymbol {x} , \boldsymbol {x} _ {o}) d \boldsymbol {\theta} d \boldsymbol {x}} \tilde {p} (\boldsymbol {\theta}) \tilde {p} (\boldsymbol {x}) K (\boldsymbol {x} , \boldsymbol {x} _ {o})} \\ = \frac {\iint \tilde {p} (\boldsymbol {\theta}) \tilde {p} (\boldsymbol {x}) K (\boldsymbol {x} , \boldsymbol {x} _ {o}) d \boldsymbol {\theta} d \boldsymbol {x}}{\iint \tilde {p} (\boldsymbol {\theta}) p (\boldsymbol {x} | \boldsymbol {\theta}) K (\boldsymbol {x} , \boldsymbol {x} _ {o}) d \boldsymbol {\theta} d \boldsymbol {x}} \frac {p (\boldsymbol {x} | \boldsymbol {\theta})}{\tilde {p} (\boldsymbol {x})} \\ = \frac {\int \tilde {p} (\boldsymbol {x}) K (\boldsymbol {x} , \boldsymbol {x} _ {o}) \int \tilde {p} (\boldsymbol {\theta}) d \boldsymbol {\theta} d \boldsymbol {x}}{\int p (\boldsymbol {x} | \boldsymbol {\theta}) K (\boldsymbol {x} , \boldsymbol {x} _ {o}) \int \tilde {p} (\boldsymbol {\theta}) d \boldsymbol {\theta} d \boldsymbol {x}} \frac {p (\boldsymbol {x} | \boldsymbol {\theta})}{\tilde {p} (\boldsymbol {x})} \\ = \frac {\mathbb {E} _ {\boldsymbol {x} \sim \tilde {p} (\boldsymbol {x})} [ K (\boldsymbol {x} , \boldsymbol {x} _ {o}) ]}{\mathbb {E} _ {\boldsymbol {x} \sim p (\boldsymbol {x} | \boldsymbol {\theta})} [ K (\boldsymbol {x} , \boldsymbol {x} _ {o}) ]} \frac {p (\boldsymbol {x} | \boldsymbol {\theta})}{\tilde {p} (\boldsymbol {x})} \\ \end{array}
523
+ $$
524
+
525
+ Lemma 3. The objective
526
+
527
+ $$
528
+ \mathcal {L} = \mathbb {E} _ {\boldsymbol {\theta}, \boldsymbol {x} \sim \tilde {p} (\boldsymbol {\theta}, \boldsymbol {x})} [ (c _ {\zeta} (\boldsymbol {\theta}) - K (\boldsymbol {x}, \boldsymbol {x} _ {o})) ^ {2} ]
529
+ $$
530
+
531
+ is minimized if and only if $c_{\zeta}(\pmb {\theta}) = \mathbb{E}_{\pmb {x}\sim p(\pmb {x}|\pmb {\theta})}[K(\pmb {x},\pmb {x}_o))]$ for all $\pmb {\theta}\in$ support $(\tilde{p} (\pmb {\theta}))$
532
+
533
+ Proof.
534
+
535
+ $$
536
+ \begin{array}{l} \mathcal {L} = \mathbb {E} _ {\boldsymbol {\theta}, \boldsymbol {x} \sim \tilde {p} (\boldsymbol {\theta}, \boldsymbol {x})} \left[ \left(c _ {\zeta} (\boldsymbol {\theta}) - K (\boldsymbol {x}, \boldsymbol {x} _ {o})\right) ^ {2} \right] \\ = \iint \tilde {p} (\boldsymbol {\theta}, \boldsymbol {x}) \left(c _ {\zeta} (\boldsymbol {\theta}) - K (\boldsymbol {x}, \boldsymbol {x} _ {o})\right) ^ {2} d \boldsymbol {x} d \boldsymbol {\theta} \\ = \int \tilde {p} (\boldsymbol {\theta}) \int p (\boldsymbol {x} | \boldsymbol {\theta}) \left(c _ {\zeta} (\boldsymbol {\theta}) - K \left(\boldsymbol {x}, \boldsymbol {x} _ {o}\right)\right) ^ {2} d \boldsymbol {x} d \boldsymbol {\theta} \\ = \int \tilde {p} (\boldsymbol {\theta}) \mathbb {E} _ {\boldsymbol {x} \sim p (\boldsymbol {x} | \boldsymbol {\theta})} [ (c _ {\zeta} (\boldsymbol {\theta}) - K (\boldsymbol {x}, \boldsymbol {x} _ {o})) ^ {2} ] d \boldsymbol {\theta} \\ \end{array}
537
+ $$
538
+
539
+ which is minimized if and only if $c_{\zeta}(\pmb {\theta}) = \mathbb{E}_{\pmb {x}\sim p(\pmb {x}|\pmb {\theta})}[K(\pmb {x},\pmb{x}_o)])$ for all $\pmb {\theta}\in \mathrm{support}(\tilde{p} (\pmb {\theta}))$
540
+
541
+ ![](images/22d016ae487deeba924ffe61f7146bc5f876ccc002677aea53a12268528fca71.jpg)
542
+
543
+ ![](images/b9e988a8b74e9bbd5c00baa03cb5d0e0c7980fd981be38f2a625d63fd0ac5ca2.jpg)
544
+ Figure 8: Comparison between SNPLA implementation of (Wiqvist et al., 2021) and SNVI with rKL.
545
+
546
+ # A.7 SNPLA
547
+
548
+ In Fig. 2 and Fig. 3, we compared SNVI to SNPLA (Wiqvist et al., 2021). To ensure comparability between SNPLA and SNVI, we implemented SNPLA ourselves and used the same likelihood- and posterior-model for both methods. The main difference between our implementation and the original implementation of SNPLA are:
549
+
550
+ 1. We do not use the proposal $\hat{p}_r(\pmb {\theta}) = \alpha p(\pmb {\theta}) + (1 - \alpha)q_\phi (\pmb {\theta})$ for $\alpha \in [0,1]$ , instead we use $\alpha = 0$ , i.e. we use the current posterior estimate as proposal.
551
+ 2. Secondly, we use a Rational Linear Spline Flow (RSF) based on pyro (Bingham et al., 2019), whereas Wiqvist et al. (2021) uses a Masked Autoregressive Flow based on nflows (Durkan et al., 2019b).
552
+
553
+ Fig. 8 compares the performance of our SNPLA implementation to the original implementation. Our implementation performs slightly better, likely due to the use of more expressive normalizing flows. We used our implementation for all experiments and nonetheless refer to the method with the name 'SNPLA'.
554
+
555
+ # A.8 EXPERIMENTS: BENCHMARK
556
+
557
+ All tasks were taken from an sbi benchmark (Lueckmann et al., 2021). For a description of the simulators, summary statistics, and prior distributions, we refer the reader to that paper.
558
+
559
+ We use the SNLE and SNRE as implemented in the sbi package (Tejero-Cantero et al., 2020). In all experiments, we learn the likelihood with a Masked Autoregressive Flow (MAF) with five autoregressive layers each with two hidden layers and 50 hidden units (Tejero-Cantero et al., 2020; Durkan et al., 2019b). For SNRE we use a two block residual network with 50 hidden units. Just as in Lueckmann et al. (2021), we implement SNRE with the loss described in Durkan et al. (2020).
560
+
561
+ The implementation of the posterior normalizing flows is based on pyro (Bingham et al., 2019), as pyro caches intermediate values during sampling and thus allow cheap density evaluation on obtained samples. We use MAFs for higher dimensional problems and Rational Linear Spline Flows (RSF) for low dimensional but complex problems (SLCP, Two moons). We always use a standard Gaussian base distribution and five autoregressive layers with a hidden size depending on input dimension ([dim·10, dim·10] for spline autoregressive nets and [dim·5+5] for affine autoregressive nets, each with ReLU activations). As the posterior support must match that of the prior, we add a bijective mapping that maps the support to that of the prior. This allows to train the normalizing flows directly on the constrained domain.
562
+
563
+ We used a total sampling budget of $N = 256$ for any VI loss. To estimate the IW-ELBO we use $N = 32$ to estimate $\mathcal{L}_{IW}^{(K = 8)}(\phi)$ (Rainforth et al., 2018). Additionally, we use the STL estimator (Roeder et al., 2017). An alternatively would be the doubly reparameterized gradient estimator, which is unbiased. We choose the STL estimator as it admits larger SNRs at the cost of introducing some bias (Tucker et al., 2018). Because for $\alpha \rightarrow 0$ we have that $\mathcal{L}_{\alpha}\to \mathcal{L}_{IW}^{(K = 1)}$ we use this
564
+
565
+ ![](images/305b865be7b760e2ebed7453944b0d6370051a6dd062b2a2b6eaf1ee63313594.jpg)
566
+
567
+ ![](images/c2794a6f9da4a21f57c23d9e348347a7ea907b7620725225feb52035c19d4a39.jpg)
568
+
569
+ ![](images/03f125c315dc11e7baa8bf083061ab56885366052b7e45931766cd4dbcc3f840.jpg)
570
+
571
+ ![](images/8f9e8939ae17cc63fc36c8e35c3f6e3536d49df3e7da29d2b61e96ff8889e577.jpg)
572
+
573
+ ![](images/17088cd05849423ec27463bee9fa2742c12c8df306cbce68de48905dbe2fee57.jpg)
574
+
575
+ ![](images/8dddbe67b3218f2d84da1fa429080dfccbc96b695b6d8b4d47c7a559009c0f0d.jpg)
576
+
577
+ ![](images/4a19a049e4363e206d7ed8547afe54eb46e25214d320a4823895c479b3d6b008.jpg)
578
+ Figure 9: Samples from the posterior distributions for SNLE with MCMC, SNVI + fKL, SNVI + rKL. First row: results for SLCP. Second row: Lotka-Volterra. Third row: Bernoulli GLM.
579
+
580
+ ![](images/615fd6e331ec61ab8685caf47c2c8c156fca7378eb13ab7b601f943f9457bd49.jpg)
581
+
582
+ ![](images/24882e11182dd7d9ca73d59b9f063c96beac2ccd3febb8ca1a0a0f73e8a85f0b.jpg)
583
+
584
+ estimator also to estimate $\mathcal{L}_{\alpha = 0.1}(\phi)$ . While the estimator can also be used for the ELBO, it requires additional computational cost i.e. we additionally need to calculate the inverse transformation, which is costly for autoregressive flows. Note that the fKL estimator also requires the inverse transform, thus we recommend to use a normalizing flow with fast forward and inverse passes in problems with many parameters, e.g. normalizing flows based on coupling layers (Dinh et al., 2017; Durkan et al., 2019a).
585
+
586
+ We trained for 10 rounds of simulations. In each round, we initialize the likelihood- and the posterior-model as their respective last estimates from the previous round. We train the posterior model for each round for at least 100 iterations and at most 1000 iterations. We evaluate convergence by tracking the decrease within the loss. For this automated benchmark, the convergence criteria are chosen conservative too avoid early stopping. More elaborate convergence criteria may improve runtime.
587
+
588
+ As metrics, we used classifier 2-sample tests (C2ST). C2ST trains a classifier to distinguish posterior samples produced by a specific method to ground truth posterior samples. Thus, a value of 0.5 means that the distributions are identical, whereas higher values indicate a mismatch between the distributions. As in Lueckmann et al. (2021), we computed the C2ST using 10,000 samples. Each figure shows the average metric value over 10 different observations, as well as the corresponding $95\%$ confidence interval.
589
+
590
+ ![](images/4b60ff33d76d6d2c99755d21a0bdb7f322a07ce64046ab8609de7063434418d3.jpg)
591
+ Figure 10: C2ST benchmark results for SNVI with ratio estimation (SNRVI) for four models, Bernoulli GLM (A), Lotka Volterra (B), Two moons (C) and SLCP (D). Each point represents the average metric value for ten different observations, as well as the confidence intervals. Bars on the right indicate the average runtime. Two reference methods: SNRE with MCMC sampling and the rKL, as well as three variants of SNVI, with forward KL (SNVI+fKL), importance-weighted ELBO (SNVI+IW) and $\alpha$ -divergence (SNVI+ $\alpha$ ). Dotted lines: performance when not using SIR.
592
+
593
+ Fig. 11 shows results for further variational objectives on the two moons (top) and on the SLCP task (bottom). The self-normalization used for the forward KL estimator improves the approximation quality (11, left, dark vs light purple). For the IW-ELBO (middle) as well as for the $\alpha$ -divergences (right), the STL estimator improves performance (Rainforth et al., 2018). The gains from the STL are stronger for $\alpha$ -divergences as for the IW-ELBO (especially when using SIR). The STL particularly improves the estimate for low values of alpha (which are more support-covering).
594
+
595
+ # A.9 EXPERIMENTS: INFERENCE IN A NEUROSCIENCE MODEL OF THE PYLORIC NETWORK
596
+
597
+ We used the same simulator as in Gonçalves et al. (2020); Deistler et al. (2021) and the 15 summary statistics originally described in Prinz et al. (2004) and also used in Gonçalves et al. (2020); Deistler et al. (2021) (notably, Gonçalves et al. (2020); Deistler et al. (2021) used 3 additional features). Below, we describe the simulator briefly, for a full description we refer the reader to Prinz et al. (2004); Gonçalves et al. (2020); Deistler et al. (2021).
598
+
599
+ The model is composed of three single-compartment neurons, AB/PD, LP, and PY, where the electrically coupled AB and PD neurons are modeled as a single neuron. Each of the model neurons contains 8 currents. In addition, the model contains 7 synapses. As in Prinz et al. (2004), these synapses are simulated using a standard model of synaptic dynamics (Abbott & Marder, 1998).
600
+
601
+ For each set of membrane and synaptic conductances, we numerically simulate the circuit for 10 seconds with a step size of $0.025\mathrm{ms}$ . At each time step, each neuron receives Gaussian noise with mean zero and standard deviation $0.001\mathrm{mV}\cdot \mathrm{ms}^{-0.5}$ .
602
+
603
+ We applied SNVI to infer the posterior over 24 membrane parameters and 7 synaptic parameters, i.e. 31 parameters in total. The 7 synaptic parameters are the maximal conductances of all synapses in the circuit, each of which is varied uniformly in logarithmic domain and the membrane parameters
604
+
605
+ ![](images/0e0bbdf7b2354b2224f47dbce93caa12ac3d006b6fb53bc8e8312c0b86fa80cc.jpg)
606
+ Figure 11: Evaluation of further variational objectives for the two moons (top) and the SLCP (bottom) task. Left: Variations of the forward KL (with and without self-normalized weights). Middle: Variations of the IW-ELBO (with and without STL). Right: Variations of the $\alpha$ -divergence (with and without STL as well as for different values of $\alpha$ .
607
+
608
+ are the maximal membrane conductances for each neuron. All membrane and synaptic conductances are varied over the same range as in Gonçalves et al. (2020); Deistler et al. (2021).
609
+
610
+ The 15 summary features proposed by Prinz et al. (2004) are salient features of the pyloric rhythm: Cycle period (s), three burst durations (s), two gap durations between bursts, two phase delays, three duty cycles, two phase gaps, and two phases of burst onsets. Note that several of these values are only defined if each neuron produces rhythmic bursting behavior. In particular we call any simulations invalid if at least one of the summary features is undefined.
611
+
612
+ The experimental data is taken from file 845_082_0044 in a publicly available dataset (Haddad & Marder, 2021).
613
+
614
+ For the likelihood-model, we use a Neural Spline Flow (NSF) with five autoregressive layers. Each layer has two hidden layers and 50 hidden neurons, as implemented in the sbi package (Tejero-Cantero et al., 2020; Durkan et al., 2019b). The posterior-model is a Masked autoregressive flow (MAF) with five autoregressive layers each with one hidden layer and 160 hidden units.
615
+
616
+ We train a total of 31 rounds. In the first round we use 50000 simulations from which only 492 are valid, and thus used to estimate the likelihood. For all other rounds we each simulated 10000 samples. To account for invalid summary features, we use the calibration kernel $K(\pmb{x},\pmb{x}_o) = I(\pmb{x}$ is valid), hence can simply exclude any invalid simulations from training the likelihood-model. By Theorem 1 we have to correct the likelihood by multiplication of $\mathbb{E}_{\pmb{x}\sim p(\pmb{x}|\pmb{\theta})}[I(\pmb{x}$ is valid)] $= P(\pmb{x}$ is valid| $\pmb{\theta}$ ). To estimate this probability we use a deep logistic regression net with 3 hidden layers each with 50 neurons and ReLU activations. We train this classifier simultaneously with the likelihood-model, that is in each round we add new data $\left\{\left(\pmb{\theta}_i,I(\pmb{\theta}_i\text{is valid})\right)\right\}_{i = 1}^N$ and retrain the classifier using the weighted binary-cross-entropy loss. We weight the loss by the estimated class probabilities to account for class imbalance especially in early rounds. We fix the number of epochs to 200 per round. We use the fKL loss with $N = 1024$ samples, as well as SIR.
617
+
618
+ ![](images/9dad66e4223057a2dc2eb2a364a18498bbf3e359aeab75261c67cfbec4aa45ef.jpg)
619
+ Figure 12: Posterior distribution for the neuroscience model of the pyloric network. In Fig. 4B we show a subset. The black point is a mean estimate using $10^{7}$ samples. The red point is a maximum a-posteriori estimate, obtained by gradient ascent.
620
+
621
+ In total, the procedure took 27 hours, with the runs of the simulator being parallelized across several nodes. Because of this, the runtime also depends greatly on availability of computing resources on the cluster.
622
+
623
+ ![](images/ef923072b0508cdc6c3228aa8df6ae000e02c46eaa048bfdc6b515ced1547076.jpg)
624
+ Figure 13: Runtime of the classifier $c_{\zeta}(\theta)$ in the model of the pyloric network (90% of simulations are invalid). Training the classifier is approximately three times cheaper than training the likelihood-model (compare left bar to second left) and thus increases the computational cost only modestly. The likelihood-model is trained only on valid simulations. The combined runtime of classifier and likelihood-model (third bar) is still far less than the time it would take to train the likelihood-model on all simulations (right bar. To estimate the runtime of the likelihood-model on all simulations, we substituted invalid simulation outputs (i.e. NaN) with an unreasonably low value and trained on all simulations).
variationalmethodsforsimulationbasedinference/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bd2e32d57d4c0b60e5043040371ddb498b55d045f5bf818250be399b5f1faf4b
3
+ size 1144636
variationalmethodsforsimulationbasedinference/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5238587f04a2c205cfa3a5df1e13f4232b86d6fc91892511c722cbdb2deebbaa
3
+ size 858809
vitgantrainingganswithvisiontransformers/f2dbc46a-fc3b-4c65-bcb7-5c78ee2242d4_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3018d7341a7a5864887621a1617f2d1721fd09a689c940ff5a18e3e25f741180
3
+ size 98494
vitgantrainingganswithvisiontransformers/f2dbc46a-fc3b-4c65-bcb7-5c78ee2242d4_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e171053c3b2b769b6b83c6e7ad7e49bf03e011767eb98872158ff90ee9141e6d
3
+ size 123509