SlowGuess commited on
Commit
c120049
·
verified ·
1 Parent(s): 9da720f

Add Batch bc1a8140-bd2d-404a-bc10-4743710a96fc

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. dugmattingdecomposeduncertaintyguidedmatting/712224a3-610b-421b-9e86-fb243ece34f3_content_list.json +3 -0
  2. dugmattingdecomposeduncertaintyguidedmatting/712224a3-610b-421b-9e86-fb243ece34f3_model.json +3 -0
  3. dugmattingdecomposeduncertaintyguidedmatting/712224a3-610b-421b-9e86-fb243ece34f3_origin.pdf +3 -0
  4. dugmattingdecomposeduncertaintyguidedmatting/full.md +494 -0
  5. dugmattingdecomposeduncertaintyguidedmatting/images.zip +3 -0
  6. dugmattingdecomposeduncertaintyguidedmatting/layout.json +3 -0
  7. mplug2amodularizedmultimodalfoundationmodelacrosstextimageandvideo/e27b8a9b-a2c2-4a23-a125-949d4d80671c_content_list.json +3 -0
  8. mplug2amodularizedmultimodalfoundationmodelacrosstextimageandvideo/e27b8a9b-a2c2-4a23-a125-949d4d80671c_model.json +3 -0
  9. mplug2amodularizedmultimodalfoundationmodelacrosstextimageandvideo/e27b8a9b-a2c2-4a23-a125-949d4d80671c_origin.pdf +3 -0
  10. mplug2amodularizedmultimodalfoundationmodelacrosstextimageandvideo/full.md +0 -0
  11. mplug2amodularizedmultimodalfoundationmodelacrosstextimageandvideo/images.zip +3 -0
  12. mplug2amodularizedmultimodalfoundationmodelacrosstextimageandvideo/layout.json +3 -0
  13. simplediffusionendtoenddiffusionforhighresolutionimages/8cd9cb19-cae7-4216-a18a-142392fe9ee0_content_list.json +3 -0
  14. simplediffusionendtoenddiffusionforhighresolutionimages/8cd9cb19-cae7-4216-a18a-142392fe9ee0_model.json +3 -0
  15. simplediffusionendtoenddiffusionforhighresolutionimages/8cd9cb19-cae7-4216-a18a-142392fe9ee0_origin.pdf +3 -0
  16. simplediffusionendtoenddiffusionforhighresolutionimages/full.md +712 -0
  17. simplediffusionendtoenddiffusionforhighresolutionimages/images.zip +3 -0
  18. simplediffusionendtoenddiffusionforhighresolutionimages/layout.json +3 -0
  19. universalmorphologycontrolviacontextualmodulation/2ca5468c-be98-4ef1-8ace-382b5f02d6bc_content_list.json +3 -0
  20. universalmorphologycontrolviacontextualmodulation/2ca5468c-be98-4ef1-8ace-382b5f02d6bc_model.json +3 -0
  21. universalmorphologycontrolviacontextualmodulation/2ca5468c-be98-4ef1-8ace-382b5f02d6bc_origin.pdf +3 -0
  22. universalmorphologycontrolviacontextualmodulation/full.md +357 -0
  23. universalmorphologycontrolviacontextualmodulation/images.zip +3 -0
  24. universalmorphologycontrolviacontextualmodulation/layout.json +3 -0
  25. universalphysicsinformedneuralnetworkssymbolicdifferentialoperatordiscoverywithsparsedata/f03c5cf1-ca24-426c-a4cf-41fc69f509fd_content_list.json +3 -0
  26. universalphysicsinformedneuralnetworkssymbolicdifferentialoperatordiscoverywithsparsedata/f03c5cf1-ca24-426c-a4cf-41fc69f509fd_model.json +3 -0
  27. universalphysicsinformedneuralnetworkssymbolicdifferentialoperatordiscoverywithsparsedata/f03c5cf1-ca24-426c-a4cf-41fc69f509fd_origin.pdf +3 -0
  28. universalphysicsinformedneuralnetworkssymbolicdifferentialoperatordiscoverywithsparsedata/full.md +333 -0
  29. universalphysicsinformedneuralnetworkssymbolicdifferentialoperatordiscoverywithsparsedata/images.zip +3 -0
  30. universalphysicsinformedneuralnetworkssymbolicdifferentialoperatordiscoverywithsparsedata/layout.json +3 -0
  31. unleashingmaskexploretheintrinsicoutofdistributiondetectioncapability/08cb0f55-471d-41a0-89ff-3fe0bf0a00cb_content_list.json +3 -0
  32. unleashingmaskexploretheintrinsicoutofdistributiondetectioncapability/08cb0f55-471d-41a0-89ff-3fe0bf0a00cb_model.json +3 -0
  33. unleashingmaskexploretheintrinsicoutofdistributiondetectioncapability/08cb0f55-471d-41a0-89ff-3fe0bf0a00cb_origin.pdf +3 -0
  34. unleashingmaskexploretheintrinsicoutofdistributiondetectioncapability/full.md +0 -0
  35. unleashingmaskexploretheintrinsicoutofdistributiondetectioncapability/images.zip +3 -0
  36. unleashingmaskexploretheintrinsicoutofdistributiondetectioncapability/layout.json +3 -0
  37. unlockingslotattentionbychangingoptimaltransportcosts/eb0bd92d-7406-4b0e-941b-c21a4d92e3ae_content_list.json +3 -0
  38. unlockingslotattentionbychangingoptimaltransportcosts/eb0bd92d-7406-4b0e-941b-c21a4d92e3ae_model.json +3 -0
  39. unlockingslotattentionbychangingoptimaltransportcosts/eb0bd92d-7406-4b0e-941b-c21a4d92e3ae_origin.pdf +3 -0
  40. unlockingslotattentionbychangingoptimaltransportcosts/full.md +548 -0
  41. unlockingslotattentionbychangingoptimaltransportcosts/images.zip +3 -0
  42. unlockingslotattentionbychangingoptimaltransportcosts/layout.json +3 -0
  43. unscentedautoencoder/9919ec0e-11db-4e67-a3af-3305e9e64e5f_content_list.json +3 -0
  44. unscentedautoencoder/9919ec0e-11db-4e67-a3af-3305e9e64e5f_model.json +3 -0
  45. unscentedautoencoder/9919ec0e-11db-4e67-a3af-3305e9e64e5f_origin.pdf +3 -0
  46. unscentedautoencoder/full.md +520 -0
  47. unscentedautoencoder/images.zip +3 -0
  48. unscentedautoencoder/layout.json +3 -0
  49. unsupervisedoutofdistributiondetectionwithdiffusioninpainting/baa6865d-100e-4e48-bb92-b5c7e697f9db_content_list.json +3 -0
  50. unsupervisedoutofdistributiondetectionwithdiffusioninpainting/baa6865d-100e-4e48-bb92-b5c7e697f9db_model.json +3 -0
dugmattingdecomposeduncertaintyguidedmatting/712224a3-610b-421b-9e86-fb243ece34f3_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca2ae62714a9bdd0899f40f84898bfd146326ba727583bff4f193625c419e90a
3
+ size 107108
dugmattingdecomposeduncertaintyguidedmatting/712224a3-610b-421b-9e86-fb243ece34f3_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2786c3c41b1d3ef74d44852ce938db2d9de3b372d463739ffda01e4122a6dff9
3
+ size 131796
dugmattingdecomposeduncertaintyguidedmatting/712224a3-610b-421b-9e86-fb243ece34f3_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0006c0435430d63a0f1d0c87e66bee5b887234578ef1ec90e813f53002427550
3
+ size 7832255
dugmattingdecomposeduncertaintyguidedmatting/full.md ADDED
@@ -0,0 +1,494 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # dugMatting: Decomposed-Uncertainty-Guided Matting
2
+
3
+ Jiawei Wu $^{1}$ Changqing Zhang $^{2}$ Zuoyong Li $^{3}$ Huazhu Fu $^{4}$ Xi Peng $^{5}$ Joey Tianyi Zhou $^{46}$
4
+
5
+ # Abstract
6
+
7
+ Cutting out an object and estimating its opacity mask, known as image matting, is a key task in image and video editing. Due to the highly ill-posed issue, additional inputs, typically user-defined trimaps or scribbles, are usually needed to reduce the uncertainty. Although effective, it is either time consuming or only suitable for experienced users who know where to place the strokes. In this work, we propose a decomposed-uncertainty-guided matting (dugMatting) algorithm, which explores the explicitly decomposed uncertainties to efficiently and effectively improve the results. Basing on the characteristic of these uncertainties, the epistemic uncertainty is reduced in the process of guiding interaction (which introduces prior knowledge), while the aleatoric uncertainty is reduced in modeling data distribution (which introduces statistics for both data and possible noise). The proposed matting framework relieves the requirement for users to determine the interaction areas by using simple and efficient labeling. Extensively quantitative and qualitative results validate that the proposed method significantly improves the original matting algorithms in terms of both efficiency and efficacy.
8
+
9
+ $^{1}$ College of Mechanical and Electrical Engineering, Fujian Agriculture and Forestry University, Fuzhou, China $^{2}$ College of Intelligence and Computing, Tianjin University, Tianjin, China $^{3}$ Fujian Provincial Key Laboratory of Information Processing and Intelligent Control, Minjiang University, Fuzhou, China $^{4}$ Institute of High Performance Computing, Agency for Science, Technology and Research, Singapore $^{5}$ College of Computer Science, Sichuan University, Chengdu, China $^{6}$ Centre for Frontier AI Research (CFAR), Agency for Science, Technology and Research (A*STAR), Singapore. Correspondence to: Changqing Zhang <zhangchangqing@tju.edu.cn>, Zuoyong Li <fzulzytdq@126.com>.
10
+
11
+ Proceedings of the $40^{th}$ International Conference on Machine Learning, Honolulu, Hawaii, USA. PMLR 202, 2023. Copyright 2023 by the author(s).
12
+
13
+ # 1. Introduction
14
+
15
+ Digital image matting is the estimation of the opacity of foreground or background from an image, which is one of the fundamental elements in many applications, e.g., composing live-action and rendered elements together, and performing local color corrections. Specifically, given an image $I$ , image matting can be regarded as a linear combination of foreground $F \in \mathbb{R}^{H \times W \times C}$ and background $B \in \mathbb{R}^{H \times W \times C}$ with the alpha matte $\mu \in [0,1]^{H \times W}$ as follows:
16
+
17
+ $$
18
+ I _ {m} = \mu_ {m} F _ {m} + (1 - \mu_ {m}) B _ {m},
19
+ $$
20
+
21
+ where $m = (x,y)$ denotes the pixel position.
22
+
23
+ Since the estimation of $\mu$ without any extra information is a highly ill-posed problem, traditional algorithms (Levin et al., 2007; Chen et al., 2013; Lutz et al., 2018; Xu et al., 2017; Li & Lu, 2020; Liu et al., 2021b; Park et al., 2022) usually introduce a trimap to confine the solution space. The trimap separates a picture into two known foreground and background regions along with an unknown transition region. Hence, the matting task is simplified as the problem of estimating the opacity in the transition region. Based on this simplification, the recently proposed matteformer (Park et al., 2022) achieves the state-of-the-art performance. However, drawing a suitable trimap is still time-consuming and tedious. For some complex cases, it will even cost more than 10 minutes (Wei et al., 2021).
24
+
25
+ Recently, some trimap-free matting algorithms attempt to eliminate the model dependence on the prior labeling. However, the performance of trimap-free methods (Li et al., 2022; Ke et al., 2022; Qin et al., 2020; Chen et al., 2018; Li et al., 2021) still lags far behind the trimap-based methods. The inherent reason is that these models cannot determine which foreground target should be extracted without the guidance of trimap. Therefore, existing trimap-free methods are only able to extract the class-specific objects (e.g., portrait, animal) or salient objects after training on large-scale matting data. Moreover, trimap-free methods is powerless when users want to choose a new category. To balance the efficiency and effectiveness, some novel interactive strategies have been introduced for matting. With user scribbles or clicks, interactive matting achieves similar performance to the trimap-based approaches in relatively low labeling cost (Wei et al., 2021). However, a promising outcome
26
+
27
+ ![](images/363e548ebe2a2207ac8bebd479e3112dc837ece80472928eec5feddb51d79f31.jpg)
28
+ Figure 1. Motivation of the proposed dugMatting. The matting performance could be significantly improved by reducing the decomposed epistemic and aleatoric uncertainties (top row), where these uncertainties are ubiquitous in learning-based image matting (middle and bottom rows). The epistemic uncertainty cannot be reduced by model but can be reduced by user interaction, while the aleatoric uncertainty is difficult to be reduced by human but can be reduced by handling the data noise. Therefore, it is attractive to decompose these uncertainties and exploit them accordingly.
29
+
30
+ usually requires multiple interactions because the interactions heavily rely on user experience, leading to long-term interaction (the shortest click interaction method still takes about 20 seconds (Wei et al., 2021)). Besides, the matting performance may be unstable due to the ambiguity of the user interaction.
31
+
32
+ To relieve the restriction of user experience, we propose a decomposed-uncertainty-guided matting (dugMatting) algorithm, which elegantly exploits the decomposed epistemic and aleatoric uncertainties. As shown in Figure 1, the epistemic uncertainty basically results from insufficient training data while the aleatoric uncertainty often appears in transition regions due to the inherent noise. Based on the observation that the absolute error is highly correlated with the these uncertainties, a natural question is can we effectively reduce the decomposed uncertainty?
33
+
34
+ Contribution. Epistemic uncertainty is often due to a lack of training data and thus it is difficult to be reduced by models themselves, while it can be reduced by interaction. Aleatoric uncertainty refers to the uncertainty inherent in the
35
+
36
+ observations, e.g., measurement noise or inaccurate labeling, which is more intricate but can be reduced by handling possible noise, e.g., using data augmentation (Ning et al., 2022; Sambyal et al., 2022). We propose a decomposed-uncertainty-guided matting framework, where the epistemic uncertainty (Kendall & Gal, 2017; Amini et al., 2020) is used to identify proposal regions for user interaction. Accordingly, users only need labeling these regions. To reduce the aleatoric uncertainty, a plug-and-play module based on the estimated data distribution is devised where the augmentation is realized. Specifically, we model the matting output as a Normal-Inverse-Gamma distribution, which hierarchically characterizes the uncertainties and accordingly promotes both regression accuracy and trustworthiness (Amini et al., 2020). Different from the standard setting, the Normal-Inverse-Gamma distribution depends on both the input image and interaction. Therefore, multiple interactions on an image yield multiple NIG distributions, where we introduce NIG summation (Ma et al., 2021; Qian, 2018) to combine these multiple NIG distributions improving the stability. The contributions of this work are summarized as follows:
37
+
38
+ - For the first time, we reveal the relationship between epistemic/aleatoric uncertainties and the matting error, and thus transform the matting promotion into the problem of epistemic/aleatoric uncertainties reduction.
39
+ - We propose a decomposed-uncertainty-guided matting algorithm, where the epistemic uncertainty is utilized to actively provide interaction proposals for users and the aleatoric uncertainty is used to guide the matte refinement in a plug-and-play module.
40
+ - We conduct extensive experiments on multiple real-world benchmarks, which demonstrate that the proposed method not only improves the performance of trimap-based matting, but also enables trimap-free matting to extract novel foreground.
41
+
42
+ # 2. Related Work
43
+
44
+ # 2.1. Image Matting
45
+
46
+ Image matting refers to extracting interesting foreground or background with fine details from an image, which can be divided into prior-based matting (Levin et al., 2007; Lutz et al., 2018; Xu et al., 2017; Yu et al., 2021c; Park et al., 2022) and prior-free matting (Li et al., 2022; Ke et al., 2022; Chen et al., 2018; Li et al., 2021; Qin et al., 2020). The prior-based matting methods require an additional prior for constraining the solution space. One typical trimap separates an image into foreground, background, and transition regions, where only the opacity of transition regions is unknown. Before the deep learning period, some well-established methods (Zheng & Kambhametty, 2009; Chen et al., 2013; Levin et al., 2007; Grady et al., 2005; Chuang et al., 2001; Feng et al., 2016; He et al., 2011) solve the matting task based on
47
+
48
+ trimap prior. For example, the closed-form matting (Levin et al., 2007) derives a cost function based on local smoothing of foreground and background colors, and the globally optimal alpha matting is accordingly induced by solving a sparse system of linear equations. In the era of deep learning, data-driven methods have emerged in matting community, exhibiting much better performance than conventional methods. For example, deep image matting (DIM) (Xu et al., 2017) uses a convolutional network to refine the alpha matte predicted under the encoder-decoder framework, allowing for higher accuracy and sharper edges. A guided contextual attention block is designed in GCANet (Li & Lu, 2020) to integrate the alpha stream information and image information, and improve the details of matting as well. LPFNet (Liu et al., 2021b) models the long-range context features outside the reception fields to improve the alpha matte results. To relieve the load in manually constructing a trimap, the prior-free methods often divide the matting task into a triamp generation and a trimap-based matting subtasks (Li et al., 2022). However, these trimap-free methods fail to handle arbitrary foreground due to the model ambiguity without guidance.
49
+
50
+ # 2.2. Uncertainty Estimation
51
+
52
+ Uncertainty estimation in deep networks has attracted significant attention (Buisson et al., 2010; Gal & Ghahramani, 2016; Kendall & Gal, 2017; Amini et al., 2020; Sensoy et al., 2018; Angelopoulos et al., 2022; Zhou & Levine, 2021), especially when the systems are deployed in safety-critical tasks such as autonomous car control and medical diagnosis. Basically, uncertainty can be roughly divided into aleatoric uncertainty and epistemic uncertainty, in which aleatoric uncertainty captures noise inherent in the observations and epistemic uncertainty captures our ignorance about which model generated our collected data (Kendall & Gal, 2017). For modeling aleatoric uncertainty, the network often outputs a Gaussian distribution with a learnable variance. For modeling epistemic uncertainty, Bayesian-based methods (Weise & Woger, 1993; Maddox et al., 2019; Oakley & O'Hagan, 2002; Daxberger et al., 2021) form a predictive distribution by marginalizing the distribution over model parameters. To reduce the computation of Bayesian network, dropout or ensemble are used to approximate variational Bayesian inference (Buisson et al., 2010; Gal & Ghahramani, 2016), but these methods require multiple forwards. In contrast, some models directly predict the parameters of conjugate prior distribution on the predicted target distribution. Then, one forward pass can estimate the target and the associated uncertainty. Most of those models focus on classification and thus usually estimate the parameters of a Dirichlet distribution (Biloš et al., 2019; Sensoy et al., 2018; Charpentier et al., 2020; Stadler et al., 2021; Nandy et al., 2020). Since image matting is an intrinsically re
53
+
54
+ gression problem, we introduce a Normal-Inverse-Gamma (NIG) distribution (Kuleshov et al., 2018) to characterize the uncertainty.
55
+
56
+ # 3. Proposed Method
57
+
58
+ # 3.1. Preliminary of Evidence-based Uncertainty
59
+
60
+ We briefly introduce the regression under the evidence-based uncertainty estimation. Regression task can be solved from a maximum likelihood perspective with Gaussian distribution. Given the training data $\mathcal{D} = \{x_i, y_i\}_{i=1}^N$ , maximum likelihood estimation (MLE) is achieved by minimizing the negative log likelihood loss function
61
+
62
+ $$
63
+ \mathcal {L} _ {i} (\theta) = \frac {(y _ {i} - \mu) ^ {2}}{2 \sigma^ {2}} + \log \sigma ,
64
+ $$
65
+
66
+ where $\theta$ denotes the parameters of matting network, $\mu$ and $\sigma$ denote the mean and variance parameters of Gaussian distribution respectively, which are typically learned through deep neural networks. Existing matting networks target at learning the alpha matte (mean $\mu$ ) only. When $\mu$ and $\sigma$ are all learnable, the likelihood function successfully models the aleatoric uncertainty (variance), also known as the data uncertainty. However, epistemic uncertainty, also known as model uncertainty, often requires additional estimation based on the Bayesian framework, e.g., MC Dropout (Gal & Ghahramani, 2016) and ensemble (Buisson et al., 2010).
67
+
68
+ To jointly model aleatoric and epistemic uncertainties, the mean $\mu$ and variance $\sigma^2$ are assumed to be drawn from Gaussian and Inverse-Gamma distributions, respectively. Then the Normal Inverse-Gamma (NIG) distribution $\mathrm{NIG}(\gamma ,\omega ,\alpha ,\beta)$ can be considered as a higher-order conjugate prior of the Gaussian distribution
69
+
70
+ $$
71
+ y _ {i} \sim \mathcal {N} (\mu , \sigma),
72
+ $$
73
+
74
+ $$
75
+ \mu \sim \mathcal {N} (\gamma , \sigma^ {2} \omega^ {- 1}), \qquad \sigma^ {2} \sim \Gamma^ {- 1} (\alpha , \beta),
76
+ $$
77
+
78
+ where $\Gamma (\cdot)$ denotes the gamma function. In this case, the distribution of $y$ takes the form of a $\mathrm{NIG}(\gamma ,\omega ,\alpha ,\beta)$ distribution
79
+
80
+ $$
81
+ \begin{array}{l} p (\mu , \sigma | \gamma , \omega , \alpha , \beta) = \frac {\beta^ {\alpha}}{\Gamma (\alpha)} \frac {\sqrt {\omega}}{\sigma \sqrt {2 \pi}} (\frac {1}{\sigma^ {2}}) ^ {\alpha + 1} \\ \exp - \frac {2 \beta + \omega (\sigma - \mu) ^ {2}}{2 \sigma^ {2}}, \\ \end{array}
82
+ $$
83
+
84
+ where $\gamma \in R, \omega > 0, \alpha > 1$ and $\beta > 0$ . The total evidence is the sum of all visual-observations counts $2\omega + \alpha$ . To solve the NIG distribution during training phase, the following loss (Amini et al., 2020) is induced to minimize the negative log likelihood
85
+
86
+ $$
87
+ \begin{array}{l} \mathcal {L} ^ {N L L} (\theta) = \frac {1}{2} \log \left(\frac {\pi}{\omega}\right) - \alpha \log (\Omega) + \tag {1} \\ \left(\alpha + \frac {1}{2}\right) \log \left(\left(y - \gamma\right) ^ {2} \omega + \Omega\right) + \log \Phi , \\ \end{array}
88
+ $$
89
+
90
+ ![](images/a65b54aa1d58e72b694c7146266570552d0101c390a812a0991bf867d1d63778.jpg)
91
+ Figure 2. Illustration of the proposed decomposed-uncertainty-guided matting framework. The matting network fits a NIG distribution, proposing interactive regions for user based on epistemic uncertainty and detail regions for refined module based on aleatoric uncertainty.
92
+
93
+ ![](images/440546c8a889b9c9f9855ceafec4a1e4650b23fc2eec261e1535d63726014f43.jpg)
94
+
95
+ where $\Omega = 2\beta (1 + \omega)$ and $\Phi = \left(\frac{\Gamma(\alpha)}{\Gamma(\alpha + \frac{1}{2})}\right)$ . To further constrain the incorrect evidence, a regularizer is introduced in the total loss
96
+
97
+ $$
98
+ \mathcal {L} _ {N I G} (\theta) = \mathcal {L} ^ {N L L} (\theta) + \lambda \mathcal {L} ^ {R} (\theta),
99
+ $$
100
+
101
+ where $\mathcal{L}^R (\theta) = |y_i - \gamma |\cdot (2\omega +\alpha)$ is the penalty for incorrect evidence, and the coefficient $\lambda >0$ balances these two loss terms.
102
+
103
+ # 3.2. Integrating Uncertainty into Matting
104
+
105
+ Image matting can be considered as a regression task, where the output is the alpha matte $\mu \in [0,1]$ conditioning on the user map $U$
106
+
107
+ $$
108
+ \mu = \mathcal {F} _ {\theta} (x _ {i} | U),
109
+ $$
110
+
111
+ where $\mathcal{F}_{\theta}$ denotes the matting network, and the user map $U$ is empty for trimap-free matting. In order to characterize uncertainty for existing matting networks, we propose to replace the deterministic output with a NIG distribution following Section 3.1
112
+
113
+ $$
114
+ N I G (\gamma , \omega , \alpha , \beta) = \mathcal {F} _ {\theta} (x _ {i} | U),
115
+ $$
116
+
117
+ where $\gamma \in [0,1],\omega >0,\alpha >1$ , and $\beta >0$ . Specifically, we first extend the last layer of matting network to output $\gamma ,\omega ,\alpha ,\beta$ by four independent linear layers with shared features as shown in Figure 2. Then, we apply activation functions sigmoid,softplus,softplus $+1$ ,softplus for $\gamma ,\omega ,\alpha ,\beta$ to ensure the proper ranges. Although simple, the modification well fits most existing matting networks. Accordingly, the aleatoric and epistemic uncertainties are
118
+
119
+ obtained as
120
+
121
+ $$
122
+ \underbrace {\mathbb {E} [ \sigma^ {2} ] = \frac {\beta}{\alpha - 1}} _ {a l e a t o r i c}, \quad \underbrace {V a r [ \gamma ] = \frac {\beta}{\omega (\alpha - 1)}} _ {e p i s t e m i c}.
123
+ $$
124
+
125
+ Algorithm 1 Uncertainty-Guided Interaction.
126
+
127
+ Input: Epistemic uncertainty $u_{epis}$ , predicted matte $\gamma$ , input image $x$ , threshold $t$ , patch number $K$ , and selection number $N$ .
128
+
129
+ Initialization: Initialize the user map $U$
130
+
131
+ Divide $u_{epis}$ into $K \times K$ patches.
132
+
133
+ Compute the patch-level uncertainty $u_{p}\in \mathbb{R}_{+}^{K\times K}$
134
+
135
+ $\mathcal{P}\gets \mathrm{Top}N$ uncertainty patches from $\{u_p|u_p > t_J\}$
136
+
137
+ for $p$ in $\mathcal{P}$ do
138
+
139
+ Calculate the index $I$ of $p$ in input image $x$ .
140
+
141
+ Users select a label from foreground, background, or transition for $x[I]$ .
142
+
143
+ Update user map $U$
144
+
145
+ end
146
+
147
+ Output:User map $U$
148
+
149
+ # 3.3. Epistemic Uncertainty-based Interaction
150
+
151
+ Traditional interaction (Wei et al., 2021; Ding et al., 2022) implicitly contains two steps: users first empirically locate the interacted regions and then conduct interactive operation by trimap, scribble, or click. In our method, we estimate the epistemic uncertainty to automatically determine the interaction regions and then users could only select labels (foreground, background, or transition) for them as shown in Figure 3. This novel interaction avoids the time-consuming region searching. Specifically, we divide the epistemic un
152
+
153
+ ![](images/bb68711cf2b64d1195b21ef1bc62575fcd2ead9e8b6398958a1057d8d35eac85.jpg)
154
+ Figure 3. The proposed interaction allows the users to focus on selection.
155
+
156
+ certainty map into $K \times K$ patches, where the patch-level epistemic uncertainty is the average on all pixels in each patch. Then, the proposal patch set for interaction is constructed satisfying two conditions: top $N$ patch-level epistemic uncertainty and greater than a threshold $t$ . Finally, users select a label for each proposal patch. The simplified interactive process is summarized in Algorithm 1.
157
+
158
+ To incorporate the results in previous interactions for stabilization, a direct way is to integrate the corresponding NIG distributions into a uniform one. A natural way is using the following additive way
159
+
160
+ $$
161
+ N I G (\gamma , \omega , \alpha , \beta) = \frac {1}{M} \sum_ {m = 1} ^ {M} N I G (\gamma_ {m}, \omega_ {m}, \alpha_ {m}, \beta_ {m}),
162
+ $$
163
+
164
+ where $M$ denotes the number of interactions. Although simple in form, unfortunately, it is intractable to infer the parameters for the fused NIG distribution since there is no closed-form solution. Therefore, inspired by multi-modal learning (Ma et al., 2021) and multi-source learning (Qian, 2018), we employ the simple NIG summation operation to approximately solve this problem
165
+
166
+ $$
167
+ \begin{array}{l} N I G (\gamma , \omega , \alpha , \beta) \triangleq N I G (\gamma_ {1}, \omega_ {1}, \alpha_ {1}, \beta_ {1}) \\ \oplus N I G \left(\gamma_ {2}, \omega_ {2}, \alpha_ {2}, \beta_ {2}\right) \tag {2} \\ \bigoplus \dots \\ \oplus N I G (\gamma_ {M}, \omega_ {M}, \alpha_ {M}, \beta_ {M}), \\ \end{array}
168
+ $$
169
+
170
+ where $M$ denotes the number of interaction, $\oplus$ denotes the summation operation of two NIG distributions as follows,
171
+
172
+ $$
173
+ \begin{array}{l} \oplus \left\{ \begin{array}{l} \gamma = (\omega_ {1} + \omega_ {2}) ^ {- 1} (\omega_ {1} \gamma_ {1} + \omega_ {2} \gamma_ {2}), \\ \omega = \omega_ {1} + \omega_ {2}, \\ \alpha = \alpha_ {1} + \alpha_ {2} + \frac {1}{2}, \\ \beta = \beta_ {1} + \beta_ {2} + \frac {1}{2} \omega_ {1} (\gamma_ {1} - \gamma) ^ {2} + \frac {1}{2} \omega_ {2} (\gamma_ {2} - \gamma) ^ {2}. \end{array} \right. \end{array}
174
+ $$
175
+
176
+ The NIG summation can reasonably make use of predictions with different qualities. Specifically, the parameter $\omega$ indicates the confidence of a NIG distribution for the mean $\gamma$ . If one matte is more confident with its prediction, then it will contribute more to the final prediction. Moreover, $\beta$ directly reflects both aleatoric uncertainty and epistemic uncertainty which consists of two parts, i.e., the sum of $\beta_{1}$ and $\beta_{2}$ from multiple mattes and the variance between the final prediction and that of every single matte.
177
+
178
+ # 3.4. Aleatoric Uncertainty-based Refinement
179
+
180
+ Some methods (Sambyal et al., 2022; Ning et al., 2022) constrain invariant predictions for the simulated inherent noise by data augmentation, i.e., enhancing the robustness by explicitly modeling noise to reduce the aleatoric uncertainty. Given the noise $\epsilon \sim \mathcal{N}(0,\varepsilon)$ for input $\chi$ , a simple way to reduce aleatoric uncertainty is constraining consistent prediction for samples from $\mathcal{N}(\chi,\varepsilon)$ (Sambyal et al., 2022). However, characterizing the noise of the data requires additional self-supervised training, such as image reconstruction. To simplify the training steps, we propose a plug-and-play module $\mathcal{R}_{\phi}$ to reduce aleatoric uncertainty and also to refine the matting details. Instead of modeling the noise during the input, we directly model the output noise in terms of the aleatoric uncertainty $\mathbb{E}(\sigma^2)$ . In other words, we regard the matting output $\gamma$ as $\chi$ , and the noise $\epsilon \sim \mathcal{N}(0,\mathbb{E}(\sigma^2))$ , and then, we attempt to keep the consistent prediction for data sampling from $\mathcal{N}(\gamma,\mathbb{E}(\sigma^2))$ . Furthermore, we use the variance $Var(\sigma^2)$ to filter out the regions whose aleatoric uncertainty $\mathbb{E}(\sigma^2)$ may be inaccurate. The $Var(\sigma^2)$ (Cook, 2008) is defined as
181
+
182
+ $$
183
+ V a r [ \sigma^ {2} ] = \frac {\beta^ {2}}{(\alpha - 1) ^ {2} (\alpha - 2)},
184
+ $$
185
+
186
+ where $\alpha > 2$ .
187
+
188
+ The objective of the refinement module is to restore high-aleatoric uncertainty matting details without redundant calculation, thus it only concentrates on local patch refinement. We first obtain the coarse matte $\gamma_{s}$ , sampling once from $\mathcal{N}(\gamma, \mathbb{E}(\sigma^2))$ due to small variance as shown in Figure 2. Then, we use OTSU (Otsu, 1979) and $Var[\sigma^2]$ to adaptively select the pixels of reliable high aleatoric uncertainty. Finally, the $32 \times 32$ patches centered on the selected pixels corresponding to $\gamma_{s}$ are fed into our refinement module $\mathcal{R}_{\phi}$ , and the obtained predictions replace the coarse matte corresponding position to obtain the refined alpha matte $\gamma_{r}$ .
189
+
190
+ # 3.5. Optimization
191
+
192
+ We train the proposed dugMatting in two stages to enhance the stability, i.e., optimizing $\mathcal{F}_{\theta}$ to empower the epistemic uncertainty-based interaction and $\mathcal{R}_{\phi}$ to refine details.
193
+
194
+ For the optimization of $\mathcal{F}_{\theta}$ , intuitively, we need to simu
195
+
196
+ Table 1. Comparison results on the benchmarks P3M-500-P (Li et al., 2022) and P3M-500-NP (Li et al., 2022). ‡, † denote predictions without and with user map, respectively. For all metrics, the smaller value indicates the better performance.
197
+
198
+ <table><tr><td rowspan="2">Method</td><td colspan="7">P3M-500-P</td><td colspan="7">P3M-500-NP</td></tr><tr><td>SAD</td><td>MSE</td><td>MAD</td><td>Grad</td><td>\( SAD_{bf} \)</td><td>\( SAD_t \)</td><td>Conn</td><td>SAD</td><td>MSE</td><td>MAD</td><td>Grad</td><td>\( SAD_{bf} \)</td><td>\( SAD_t \)</td><td>Conn</td></tr><tr><td>SHM (Chen et al., 2018)</td><td>26.84</td><td>1.26</td><td>1.65</td><td>20.18</td><td>16.90</td><td>9.94</td><td>23.30</td><td>30.20</td><td>1.46</td><td>1.93</td><td>20.31</td><td>17.99</td><td>12.21</td><td>26.06</td></tr><tr><td>\( U^2Net (Qin et al., 2020) \)</td><td>73.48</td><td>1.99</td><td>4.51</td><td>33.06</td><td>48.54</td><td>26.91</td><td>53.81</td><td>70.67</td><td>1.89</td><td>4.51</td><td>34.89</td><td>42.75</td><td>27.91</td><td>53.29</td></tr><tr><td>MODNet (Ke et al., 2022)</td><td>23.86</td><td>1.11</td><td>1.46</td><td>23.74</td><td>16.40</td><td>7.46</td><td>21.02</td><td>25.39</td><td>1.20</td><td>1.61</td><td>21.15</td><td>17.41</td><td>7.98</td><td>22.22</td></tr><tr><td>GFM (Li et al., 2022)</td><td>12.90</td><td>0.58</td><td>0.79</td><td>14.61</td><td>5.98</td><td>6.93</td><td>11.33</td><td>17.01</td><td>0.85</td><td>1.09</td><td>14.54</td><td>8.84</td><td>8.17</td><td>14.86</td></tr><tr><td>P3MNet (Li et al., 2021)</td><td>12.73</td><td>0.56</td><td>0.78</td><td>13.89</td><td>5.95</td><td>6.78</td><td>11.14</td><td>16.49</td><td>0.80</td><td>1.05</td><td>12.75</td><td>8.97</td><td>7.54</td><td>14.35</td></tr><tr><td>SHM (dugMatting) ‡</td><td>21.43</td><td>1.26</td><td>1.51</td><td>17.82</td><td>11.57</td><td>10.07</td><td>19.32</td><td>39.67</td><td>1.66</td><td>2.43</td><td>17.23</td><td>28.27</td><td>11.40</td><td>33.88</td></tr><tr><td>\( U^2Net (dugMatting) ‡ \)</td><td>60.21</td><td>1.76</td><td>4.24</td><td>28.74</td><td>31.66</td><td>28.55</td><td>47.34</td><td>82.67</td><td>2.29</td><td>5.07</td><td>31.65</td><td>51.29</td><td>31.38</td><td>60.12</td></tr><tr><td>MODNet (dugMatting) ‡</td><td>18.15</td><td>0.72</td><td>1.04</td><td>15.57</td><td>9.59</td><td>8.55</td><td>16.75</td><td>35.66</td><td>1.49</td><td>2.07</td><td>16.04</td><td>24.26</td><td>11.40</td><td>32.83</td></tr><tr><td>GFM (dugMatting) ‡</td><td>9.25</td><td>0.40</td><td>0.63</td><td>13.79</td><td>3.18</td><td>6.71</td><td>9.29</td><td>19.01</td><td>0.86</td><td>1.14</td><td>14.14</td><td>9.27</td><td>9.73</td><td>16.45</td></tr><tr><td>P3MNet (dugMatting) ‡</td><td>10.08</td><td>0.46</td><td>0.69</td><td>14.61</td><td>4.03</td><td>7.01</td><td>10.30</td><td>16.12</td><td>0.66</td><td>0.94</td><td>14.15</td><td>6.92</td><td>9.18</td><td>13.81</td></tr><tr><td>\( \triangle Average gain † \)</td><td>-2.13</td><td>-0.17</td><td>-0.21</td><td>0.13</td><td>-6.01</td><td>1.86</td><td>-1.54</td><td>14.31</td><td>0.15</td><td>0.29</td><td>1.02</td><td>6.67</td><td>5.02</td><td>7.86</td></tr><tr><td>SHM (dugMatting) †</td><td>13.87</td><td>0.36</td><td>0.85</td><td>15.21</td><td>4.83</td><td>9.04</td><td>11.42</td><td>18.22</td><td>0.51</td><td>1.11</td><td>13.99</td><td>6.57</td><td>11.65</td><td>15.16</td></tr><tr><td>\( U^2Net (dugMatting) † \)</td><td>35.23</td><td>1.35</td><td>2.16</td><td>19.32</td><td>22.78</td><td>12.45</td><td>32.76</td><td>39.86</td><td>1.67</td><td>2.44</td><td>20.12</td><td>21.26</td><td>18.60</td><td>33.91</td></tr><tr><td>MODNet (dugMatting) †</td><td>9.62</td><td>0.29</td><td>0.55</td><td>12.88</td><td>2.63</td><td>6.98</td><td>9.05</td><td>11.08</td><td>0.33</td><td>0.64</td><td>11.75</td><td>3.19</td><td>7.88</td><td>10.99</td></tr><tr><td>GFM (dugMatting) †</td><td>7.90</td><td>0.23</td><td>0.46</td><td>12.31</td><td>1.29</td><td>6.60</td><td>6.59</td><td>9.55</td><td>0.28</td><td>0.55</td><td>11.01</td><td>2.12</td><td>7.42</td><td>7.95</td></tr><tr><td>P3MNet (dugMatting) †</td><td>7.72</td><td>0.22</td><td>0.45</td><td>12.56</td><td>1.01</td><td>6.71</td><td>6.42</td><td>8.79</td><td>0.24</td><td>0.51</td><td>11.08</td><td>1.34</td><td>7.47</td><td>7.23</td></tr><tr><td>\( \triangle Average gain † \)</td><td>-15.09</td><td>-0.61</td><td>-0.94</td><td>-6.64</td><td>-12.24</td><td>-3.24</td><td>-10.87</td><td>-14.45</td><td>-0.63</td><td>-0.98</td><td>-7.13</td><td>-12.29</td><td>-2.15</td><td>-11.10</td></tr></table>
199
+
200
+ late and supervise different predictions in real interaction process, including the initial prediction, the prediction after interaction, and the fused prediction. To simplify the training process, we analyze the purpose of supervision in the three predictions. The supervision of the initial prediction aims to train the network to conduct matting without user map. The supervision of the prediction after interaction aims to relate the network predictions to interaction, which assumes the user map is generated according to epistemic uncertainty. The supervision of the fused prediction aims to stabilize the fusion result. Based on above analysis, we can jointly supervise the initial prediction and the prediction after interaction by generating random user map $U$ including the empty case. The details of user map can be found in Appendix B.1. The supervision of the fused prediction can be removed because the fusion strategy in Equation (2) is exactly for stabilization. Therefore, the simplified supervision is similar to the previous interactive matting methods (Wei et al., 2021), which only needs to pass through the model once in each iteration. The loss of the first stage can be expressed as
201
+
202
+ $$
203
+ \mathcal {L} _ {\text {s t a g e 1}} = \mathcal {L} _ {\text {N I G}} (\gamma , \omega , \alpha , \beta ; \theta) + \mathcal {L} _ {M} (\gamma ; \theta_ {\gamma}),
204
+ $$
205
+
206
+ where minimizing $\mathcal{L}_{NIG}$ optimizes the parameters of NIG distribution to replace the regression loss (e.g., $l_{1}$ loss or $l_{2}$ loss) in common matting methods, and $\mathcal{L}_M$ denotes the additional terms (e.g., Laplacian loss (Li et al., 2022)) about matte in the original matting methods.
207
+
208
+ For the optimization of $\mathcal{R}_{\phi}$ , we first freeze the parameters $\theta$ of $\mathcal{F}_{\theta}$ . Then, we can obtain the $\gamma_{s}$ and $k$ patches of interest $\{\gamma_s^p\} ^k$ according to Section 3.4. The $l_{1}$ distance with the ground truth $y$ in matte and gradient map are used for supervision. The loss of the second stage is
209
+
210
+ $$
211
+ \mathcal {L} _ {\text {s t a g e 2}} = \left\| y - \gamma_ {r} \right\| _ {1} + \left\| \nabla y - \nabla \gamma_ {r} \right\| _ {1},
212
+ $$
213
+
214
+ where $\gamma_r = \mathcal{R}_{\phi}(\gamma_s^k,\gamma_s),\gamma_s = (\gamma +\epsilon),\epsilon \sim \mathcal{N}(0,\mathbb{E}(\sigma^2))$
215
+
216
+ # 4. Experiments
217
+
218
+ # 4.1. Experimental Setup
219
+
220
+ Dataset. We conduct extensive experiments on standard natural matting dataset Composition-1k (Xu et al., 2017) and the real-world portrait dataset P3M-10K (Li et al., 2021). Composition-1k (Xu et al., 2017) contains 43,100 synthetic images for training and 1000 synthetic images for testing. P3M-10K (Li et al., 2021) consists of 10,000 anonymized high-resolution portrait images with face obfuscation, containing 9,421 images for training and 500 images denoted as P3M-500-P for testing. Besides, for P3M-10K there are additional 500 public Internet images without face obfuscation to test the matting performance on regular portrait images, denoted as P3M-500-NP.
221
+
222
+ Implementation Details. For class-specific matting, we train all models with the same data augmentations setting for a fair comparison, including random horizontal flipping, random blurring, random sharpen, random shadow, and then random cropping to $512 \times 512$ in the end. All models are optimized using the Adam optimizer (Kingma & Ba, 2014), and the base learning rate is set to $1 \times 10^{-3}$ with the cosine learning rate scheduler (He et al., 2019), 100 epochs iteration, and batch size of 16. For natural image matting, we use the standard setting as specified by MatteFormer (Park et al., 2022). Our implementation is based on the open source framework Pytorch. All the experiments were run on two GeForce RTX 3090 GPUs.
223
+
224
+ Evaluation Metrics. For Composition-1k, we employ mul
225
+
226
+ Table 2. Quantitative comparison results of natural matting on Composition-1K (Xu et al., 2017) benchmark.
227
+
228
+ <table><tr><td>Method</td><td>User Map</td><td>SAD (103) ↓</td><td>MAD↓</td><td>MSE (10-3) ↓</td><td>Grad ↓</td><td>Conn↓</td></tr><tr><td>Learning Based Matting (Zheng &amp; Kambhamettu, 2009)</td><td>Trimap</td><td>113.9</td><td>0.0501</td><td>48.0</td><td>91.6</td><td>122.2</td></tr><tr><td>Closed-Form Matting (Levin et al., 2007)</td><td>Trimap</td><td>168.1</td><td>0.0739</td><td>91.0</td><td>126.9</td><td>167.9</td></tr><tr><td>KNN Matting (Chen et al., 2013)</td><td>Trimap</td><td>175.4</td><td>0.0771</td><td>103.0</td><td>124.1</td><td>176.4</td></tr><tr><td>Deep Image Matting (Xu et al., 2017)</td><td>Trimap</td><td>50.4</td><td>0.0221</td><td>14.0</td><td>31.0</td><td>50.8</td></tr><tr><td>AlphaGan (Lutz et al., 2018)</td><td>Trimap</td><td>52.4</td><td>0.0231</td><td>30.0</td><td>38.0</td><td>-</td></tr><tr><td>IndexNet (Lu et al., 2019)</td><td>Trimap</td><td>45.8</td><td>0.0201</td><td>13.0</td><td>25.9</td><td>43.7</td></tr><tr><td>HAttMatting (Qiao et al., 2020)</td><td>Trimap</td><td>44.0</td><td>0.0193</td><td>7.0</td><td>29.3</td><td>46.4</td></tr><tr><td>AdaMatting (Cai et al., 2019)</td><td>Trimap</td><td>41.7</td><td>0.0183</td><td>10.0</td><td>16.8</td><td>-</td></tr><tr><td>sampleNet (Tang et al., 2019)</td><td>Trimap</td><td>40.4</td><td>0.0177</td><td>9.9</td><td>-</td><td>-</td></tr><tr><td>Fine-Grained Matting (Liu et al., 2021a)</td><td>Trimap</td><td>37.6</td><td>0.0165</td><td>9.0</td><td>18.3</td><td>35.4</td></tr><tr><td>Context-Aware Matting (Hou &amp; Liu, 2019)</td><td>Trimap</td><td>35.8</td><td>0.0157</td><td>8.2</td><td>17.3</td><td>33.2</td></tr><tr><td>GCA Matting (Li &amp; Lu, 2020)</td><td>Trimap</td><td>35.3</td><td>0.0155</td><td>9.1</td><td>16.9</td><td>32.5</td></tr><tr><td>HDMatt (Yu et al., 2021b)</td><td>Trimap</td><td>33.5</td><td>0.0147</td><td>7.3</td><td>14.5</td><td>29.9</td></tr><tr><td>MG Matting (Yu et al., 2021c)</td><td>Mask</td><td>31.5</td><td>0.0138</td><td>6.8</td><td>13.5</td><td>27.3</td></tr><tr><td>TIMNet (Liu et al., 2021c)</td><td>Trimap</td><td>29.1</td><td>0.0128</td><td>6.0</td><td>11.5</td><td>25.4</td></tr><tr><td>SIM (Sun et al., 2021)</td><td>Mask</td><td>28.0</td><td>0.0123</td><td>5.8</td><td>10.8</td><td>24.8</td></tr><tr><td>MatteFormer (Park et al., 2022)</td><td>Trimap</td><td>23.8</td><td>0.0104</td><td>4.0</td><td>8.7</td><td>18.9</td></tr><tr><td>MG Matting (dugMatting)</td><td>w/o</td><td>36.5</td><td>0.0161</td><td>8.5</td><td>17.8</td><td>33.6</td></tr><tr><td>MG Matting (dugMatting)</td><td>1-Selection</td><td>32.3</td><td>0.0142</td><td>7.1</td><td>14.2</td><td>28.6</td></tr><tr><td>MG Matting (dugMatting)</td><td>2-Selection</td><td>30.2</td><td>0.0132</td><td>6.4</td><td>11.8</td><td>26.1</td></tr><tr><td>MatteFormer (dugMatting)</td><td>w/o</td><td>34.1</td><td>0.0149</td><td>5.7</td><td>15.6</td><td>31.2</td></tr><tr><td>MatteFormer (dugMatting)</td><td>1-Selection</td><td>25.8</td><td>0.0112</td><td>4.3</td><td>9.7</td><td>22.3</td></tr><tr><td>MatteFormer (dugMatting)</td><td>2-Selection</td><td>23.4</td><td>0.0102</td><td>3.9</td><td>7.2</td><td>18.8</td></tr></table>
229
+
230
+ tiple quantitative metrics, i.e., sum of absolute differences (SAD), mean absolute difference (MAD), mean squared error (MSE), gradient (Grad), and connectivity (Conn). For P3M-10K, we also adopt the above metrics and report the additional $\mathrm{SAD}_{bf}$ and $\mathrm{SAD}_t$ to compute the SAD within the foreground-background regions and transition regions.
231
+
232
+ # 4.2. Quantitative Analysis
233
+
234
+ Class-specific Matting. To validate our methods on class-specific matting task, we compare our algorithm with state-of-the-art trimap-free methods (Chen et al., 2018; Qin et al., 2020; Ke et al., 2022; Li et al., 2022; 2021) on real-world portrait dataset (Li et al., 2021). As shown in Table 1, dugMatting without interaction outperforms the original trimap-free methods on P3M-500-P, demonstrating that the way of modeling uncertainty can improve the matting performance. In addition, dugMatting significantly improves performance when introducing once interaction, particularly by roughly $50\%$ on P3M-500-NP, demonstrating that the interaction is still useful even when dealing with data from different domains.
235
+
236
+ Natural Image Matting. The natural image matting expects to extract the interesting foreground with the guidance of user interaction. We first investigate the natural matting methods (Zheng & Kambhamettu, 2009; Chen et al., 2013; Xu et al., 2017; Levin et al., 2007; Lutz et al., 2018; Lu et al., 2019; Qiao et al., 2020; Cai et al., 2019; Tang et al., 2019; Liu et al., 2021a; Hou & Liu, 2019; Li & Lu, 2020; Yu et al., 2021b;c) on Composition-1k (Xu et al., 2017). Then,
237
+
238
+ we employ the effective MG Matting (Yu et al., 2021c) and MatteFormer (Park et al., 2022) as foundation models, integrating our method to validate the performance on natural matting task. Since the Composition-1k is a synthetic set, it allows for the extraction of target objects without any initial interaction. However, when dealing with arbitrary images in real-world, we suggest providing an initial user map through a single click and then utilizing our method for further interaction. The quantitative results are shown in Table 2. With only one or two interactions, our dugMatting outperforms advanced trimap-based matting algorithms. The reason is that reducing the decomposed uncertainties can accurately improve the matte. We also conduct experiments to compare the efficiency of existing interaction methods in Appendix C.1.
239
+
240
+ # 4.3. Qualitative Analysis
241
+
242
+ Visual Comparison with State-of-the-art Methods. In Figure 4, we visualize some results for intuitive comparison. Although dugMatting uses a weaker prior, the results is comparable to other trimap-based methods. In addition, benefiting from modeling data noise, dugMatting produces a matte that is more uniform and smooth. For instance, the ground truth of the second example has some local opacity mutations that do not occur in the real world, but dugMatting also achieves a smooth outcome.
243
+
244
+ Visualization of Step-by-step Results in dugMatting. Figure 5 visualizes the step-by-step results of our dugMatting. Our interaction can effectively improve the incorrect matting
245
+
246
+ ![](images/45bb2772d13ebe78040176a25bb57e9d4356484c16fd905cfb947c46326ac969.jpg)
247
+ Input
248
+
249
+ ![](images/7fd34752f9b0cdcb99d3fa1b4b211018b62a52ee2056d439a6afb8b896384bd1.jpg)
250
+ Trimap
251
+
252
+ ![](images/20dc0af44edf442d2993256d31ce8a764c0b5b427af52544f81fb555958dc9b4.jpg)
253
+ GT
254
+
255
+ ![](images/09f6909a694fda722684eee475102105bfefefa2cdc786940f55aa172245c425.jpg)
256
+ Closed-Form
257
+
258
+ ![](images/6e20da15357a453816f3130d2c7d0f3b82f4aecd060470e28d69111191c64bfd.jpg)
259
+ Learning
260
+
261
+ ![](images/097a29e99cff001e755279eb19a48049d78eeff850457cc659074f99ef539dca.jpg)
262
+ DIM
263
+
264
+ ![](images/a7c133f45ea03f8f65ca66f372fefe59c22bccad369cdeedf70da0cd37b4369f.jpg)
265
+ IndexNet
266
+
267
+ ![](images/ebbbc8a08b757f458f61613219db17492714777b4beb982f1afb52a4740177c6.jpg)
268
+ CAM
269
+
270
+ ![](images/e4d9a145f7499b08984d124b8a00a9b12faca2ca1a04ea0b29b58b787b94399c.jpg)
271
+ GCA Matting
272
+
273
+ ![](images/beedcd30067e0fd4bfc67f3d919e1df69a16dd35099a011e96e52adc5d335e8b.jpg)
274
+ MG Matting
275
+
276
+ ![](images/c1a78eacb02068043c1a141c0f8ff0580f647c1a081d3dbf056191e9635caec1.jpg)
277
+ MatteFormer
278
+
279
+ ![](images/1edc9e6a9da8f5060dbc4c76f0b0953f1aadc30989cad20c153e2760da21c3e8.jpg)
280
+ Ours
281
+
282
+ ![](images/f258c730a466a903e30cd43168ea2057e94788e47e182d1f194fe5a8b1c1aba9.jpg)
283
+ Input
284
+
285
+ ![](images/c325737ef56009b405091e9eb955930a85e92f5f92b4bc9f00018491e35b07ee.jpg)
286
+ Trimap
287
+
288
+ ![](images/290a8da2504562775af4aab936f97102ba5405cdc603fcb2d4c5e258295c80c7.jpg)
289
+ GT
290
+
291
+ ![](images/6427dfbe1fc25b9a7209991424f1acad64515a6f472ebff270d0112f472dfae8.jpg)
292
+ Closed-Form
293
+
294
+ ![](images/ceceff7e35cf7d0dfc52601ad52b117b30f237f5e5b3347b6ed36debfbef8956.jpg)
295
+ Learning
296
+
297
+ ![](images/9e5ee008b051134d5f9745cb9314797c60563f1324ab1af2bfcf92ac4d635b05.jpg)
298
+ DIM
299
+
300
+ ![](images/6c1857b488d4f41f596eddd8a54036534803f3a55fd63a5cc162f44c8df67e15.jpg)
301
+ IndexNet
302
+
303
+ ![](images/5dc2cf61d3986f320c42c073723185aee6c591ed128bb15c057d5bcfe20663e7.jpg)
304
+ CAM
305
+
306
+ ![](images/021683d9c09f00eac2ed9d1f397e11837f02aca5d0bc19c5e390046bdd9345aa.jpg)
307
+ GCA Matting
308
+
309
+ ![](images/fd0334e11b7b047b9093722e23d5625f63799b3c6eccec14063fe8a5df1f992e.jpg)
310
+ MG Matting
311
+
312
+ ![](images/d231d8b88e45cc4a8a43f971498423062c843760742fbf70f0f363aec04b827b.jpg)
313
+ MatteFormer
314
+ Figure 4. Qualitative examples on the Composition-1k (Xu et al., 2017) test set.
315
+
316
+ ![](images/621ae576e614c5ce28056c0223e444c159dfd402f84a99a991cc40b22f0ca426.jpg)
317
+ Ours
318
+
319
+ regions, and our refinement module can improve the details. The reason is that external knowledge by user interaction significantly reduces epistemic uncertainty, complementing the unlearned foreground and background patches. Meanwhile, our refinement of modeling high-frequency noise reduces the aleatoric uncertainty, enhancing the robustness in patches containing more details.
320
+
321
+ Uncertainty Evaluation. We evaluate the uncertainty from two aspects. The first one is to verify the region proposal of our interaction and refinement, while the second one is to validate the ability of uncertainty estimation which is detailed in Appendix C.2. As shown in Figure 6, there are much higher proportion of foreground and background regions with large epistemic uncertainty (a). Thus selecting patches with top $K$ patch-levels epistemic uncertainty enables the user to concentrate on the annotation of foreground and background. We further evaluate the ROC curve between the regions obtained by two strategies and the real transition (b). Our refined aleatoric uncertainty-based algorithm significantly improves the AUC, demonstrating the refined aleatoric uncertainty can improve more details.
322
+
323
+ # 4.4. Ablation Study
324
+
325
+ In this subsection, we first investigate the proposed components and then independently analyze our plug-and-play module. Furthermore, we perform additional experiment to
326
+
327
+ Table 3. Ablation study (SAD↓) of the NIG distribution and the proposed module on the P3M-500-P dataset.
328
+
329
+ <table><tr><td>Method</td><td>Original</td><td>w/ NIG</td><td>w/ NIG &amp; Module</td></tr><tr><td>SHM (Chen et al., 2018)</td><td>26.84</td><td>24.65</td><td>21.43</td></tr><tr><td>U2Net (Qin et al., 2020)</td><td>73.48</td><td>69.76</td><td>60.21</td></tr><tr><td>MODNet (Ke et al., 2022)</td><td>23.86</td><td>20.04</td><td>18.15</td></tr><tr><td>GFM (Li et al., 2022)</td><td>12.90</td><td>10.89</td><td>9.25</td></tr><tr><td>P3MNet (Li et al., 2021)</td><td>12.73</td><td>12.03</td><td>10.38</td></tr></table>
330
+
331
+ Table 4. Ablation study (SAD↓) on our refined module on the P3M-500-P dataset. Baseline uses the original trimap-free methods.
332
+
333
+ <table><tr><td>Method</td><td>Baseline (Ke et al., 2022)</td><td>Gaussian</td><td>Module (our)</td></tr><tr><td>SADf</td><td>3.69</td><td>3.36</td><td>3.36</td></tr><tr><td>SADb</td><td>6.46</td><td>6.55</td><td>6.23</td></tr><tr><td>SADt</td><td>9.88</td><td>8.75</td><td>8.55</td></tr><tr><td>Aleatoric</td><td>0.0021</td><td>0.0015</td><td>0.0013</td></tr></table>
334
+
335
+ investigate the hyper-parameter of interaction numbers.
336
+
337
+ The Effectiveness of Each Component. We first evaluate the uncertainty integration in matting, i.e., replacing the deterministic output with a Normal-Inverse-Gamma distribution, and then adding the proposed plug-and-play module. As shown in Table 3, both NIG distribution and our refinement module can improve the matting performance over original methods, demonstrating the efficacy of the key components in dugMatting.
338
+
339
+ The Effectiveness of Reducing Aleatoric Uncertainty.
340
+
341
+ ![](images/c3b3d72c4fcfb68331674383cef55b2a3cb7f8b82ccfc63ac370012e3f37aef6.jpg)
342
+ Figure 5. Visualization of step-by-step results in dugMatting. From left to right are input image, initial prediction, epistemic uncertainty, user map, prediction after interaction, prediction after refinement, respectively.
343
+
344
+ ![](images/1fd3f363d8e1625bf7f1374ee4a78f3c7138fef45cbe3a835ace2a5688242a45.jpg)
345
+ (a)
346
+
347
+ ![](images/47b02e318215a64da3a26a14a45612006dbc451de8431c4581e178e1babc2b0f.jpg)
348
+ (b)
349
+
350
+ Following (Sambyal et al., 2022), we compare the augmentation of our module and a Gaussian noise. The variance of Gaussian noise is fixed, determined by the average aleatoric uncertainty of all pixels. The augmentation of our module also belongs to a Gaussian noise, but the variance is dynamic and determined by the aleatoric uncertainty of the current pixel. The result of reducing the aleatoric uncertainty is shown in Table 4. The proposed module achieves the best performance, significantly decreasing the aleatoric uncertainty and improving the performance.
351
+
352
+ The Hyper-parameter of Interaction Numbers. As shown in Figure 7, regardless of SAD or epistemic uncertainty, the most obvious improvement occurs in the first interaction, and the performance improvement is slight improved after the second interaction. Therefore, in order to balance the performance and interaction time, the interaction number is set as 1 unless otherwise specified.
353
+
354
+ # 5. Conclusion
355
+
356
+ In this paper, we propose a decomposed-uncertainty-guided matting (dugMatting) algorithm for both trimap-free and trimap-based matting. We first introduce epistemic uncer
357
+
358
+ ![](images/7969e9c51a47cb4b34d4d113c6e8b08f94699abcc658a4e1baddbfaaeed2afe8.jpg)
359
+ Figure 6. The correlation regions of decomposed uncertainties. The proportion of foreground and background regions is higher in high epistemic uncertainty. ROC of the obtained regions and the real transition regions, refined aleatoric uncertainty-based algorithm achieves better performance.
360
+ Figure 7. SAD and epistemic uncertainty at different number of interaction.
361
+
362
+ tainty to actively propose interactive regions, which simplifies the search of difficult regions by user for trimap-based matting. Besides, we propose a plug-and-play module, which not only reduces the aleatoric uncertainty but also improves the matting details. This is exciting because it first explores different types of uncertainties in an explainable and elegant way in matting. Extensive experiments are conducted on natural matting and class-specific matting which validates that the existing matting methods equipped with dugMatting achieve superior performance than the original ones. It would be interesting to further explore the image structures (e.g., segments) for the goal of further computational efficiency and performance improvement. Another direction for further research is to apply the proposed dugMatting to other related domains such as interactive image segmentation.
363
+
364
+ # Acknowledgements
365
+
366
+ This work was supported by the National Key Research and Development Program of China (No. 2022YFC3302200), the National Natural Science Foundation of China (No. 61972187, 61976151), and the A*STAR Central Research Fund. The authors appreciate the comments from reviewers.
367
+
368
+ # References
369
+
370
+ Amini, A., Schwarting, W., Soleimany, A., and Rus, D. Deep evidential regression. Advances in Neural Information Processing Systems, 33:14927-14937, 2020.
371
+ Angelopoulos, A. N., Kohli, A. P., Bates, S., Jordan, M., Malik, J., Alshaabi, T., Upadhyayula, S., and Romano, Y. Image-to-image regression with distribution-free uncertainty quantification and applications in imaging. In International Conference on Machine Learning, pp. 717-730. PMLR, 2022.
372
+ Biloš, M., Charpentier, B., and Gunnemann, S. Uncertainty on asynchronous time event prediction. Advances in Neural Information Processing Systems, 32, 2019.
373
+ Buisson, L., Thuiller, W., Casajus, N., Lek, S., and Grenouillet, G. Uncertainty in ensemble forecasting of species distribution. Global Change Biology, 16(4):1145-1157, 2010.
374
+ Cai, S., Zhang, X., Fan, H., Huang, H., Liu, J., Liu, J., Liu, J., Wang, J., and Sun, J. Disentangled image matting. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 8819-8828, 2019.
375
+ Charpentier, B., Zügner, D., and Gunnemann, S. Posterior network: Uncertainty estimation without ood samples via density-based pseudo-counts. Advances in Neural Information Processing Systems, 33:1356-1367, 2020.
376
+ Chen, Q., Li, D., and Tang, C.-K. Knn matting. IEEE transactions on pattern analysis and machine intelligence, 35(9):2175-2188, 2013.
377
+ Chen, Q., Ge, T., Xu, Y., Zhang, Z., Yang, X., and Gai, K. Semantic human matting. In Proceedings of the 26th ACM international conference on Multimedia, pp. 618-626, 2018.
378
+ Chuang, Y.-Y., Curless, B., Salesin, D. H., and Szeliski, R. A bayesian approach to digital matting. In Proceedings of the 2001 IEEE Computer Society Conference on Computer Vision and Pattern Recognition. CVPR 2001, volume 2, pp. II-II. IEEE, 2001.
379
+ Cook, J. D. Inverse gamma distribution. online: http://www.johndcook.com/inversegamma.pdf, Tech. Rep, 2008.
380
+ Daxberger, E., Nalisnick, E., Allingham, J. U., Antorán, J., and Hernández-Lobato, J. M. Bayesian deep learning via subnetwork inference. In International Conference on Machine Learning, pp. 2510-2521. PMLR, 2021.
381
+ Ding, H., Zhang, H., Liu, C., and Jiang, X. Deep interactive image matting with feature propagation. IEEE Transactions on Image Processing, 31:2421-2432, 2022.
382
+
383
+ Feng, X., Liang, X., and Zhang, Z. A cluster sampling method for image matting via sparse coding. In European Conference on Computer Vision, pp. 204-219. Springer, 2016.
384
+ Gal, Y. and Ghahramani, Z. Dropout as a bayesian approximation: Representing model uncertainty in deep learning. In international conference on machine learning, pp. 1050-1059. PMLR, 2016.
385
+ Grady, L., Schiwietz, T., Aharon, S., and Westermann, R. Random walks for interactive alpha-matting. In Proceedings of VIIP, volume 2005, pp. 423-429, 2005.
386
+ He, K., Rhemann, C., Rother, C., Tang, X., and Sun, J. A global sampling method for alpha matting. In CVPR 2011, pp. 2049-2056. IEEE, 2011.
387
+ He, T., Zhang, Z., Zhang, H., Zhang, Z., Xie, J., and Li, M. Bag of tricks for image classification with convolutional neural networks. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 558-567, 2019.
388
+ Hou, Q. and Liu, F. Context-aware image matting for simultaneous foreground and alpha estimation. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 4130-4139, 2019.
389
+ Ke, Z., Sun, J., Li, K., Yan, Q., and Lau, R. W. Mod-net: Real-time trimap-free portrait matting via objective decomposition. AAAI, 2022.
390
+ Kendall, A. and Gal, Y. What uncertainties do we need in bayesian deep learning for computer vision? Advances in neural information processing systems, 30, 2017.
391
+ Kingma, D. P. and Ba, J. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
392
+ Kuleshov, V., Fenner, N., and Ermon, S. Accurate uncertainties for deep learning using calibrated regression. In International conference on machine learning, pp. 2796-2804. PMLR, 2018.
393
+ Levin, A., Lischinski, D., and Weiss, Y. A closed-form solution to natural image matting. IEEE transactions on pattern analysis and machine intelligence, 30(2):228-242, 2007.
394
+ Li, J., Ma, S., Zhang, J., and Tao, D. Privacy-preserving portrait matting. In Proceedings of the 29th ACM International Conference on Multimedia, pp. 3501-3509, 2021.
395
+ Li, J., Zhang, J., Maybank, S. J., and Tao, D. Bridging composite and real: towards end-to-end deep image matting. International Journal of Computer Vision, pp. 1-21, 2022.
396
+
397
+ Li, Y. and Lu, H. Natural image matting via guided contextual attention. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 34, pp. 11450-11457, 2020.
398
+ Liu, C., Ding, H., and Jiang, X. Towards enhancing fine-grained details for image matting. In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pp. 385-393, 2021a.
399
+ Liu, Q., Xie, H., Zhang, S., Zhong, B., and Ji, R. Long-range feature propagating for natural image matting. In Proceedings of the 29th ACM International Conference on Multimedia, pp. 526-534, 2021b.
400
+ Liu, Y., Xie, J., Shi, X., Qiao, Y., Huang, Y., Tang, Y., and Yang, X. Tripartite information mining and integration for image matting. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 7555-7564, 2021c.
401
+ Lu, H., Dai, Y., Shen, C., and Xu, S. Indices matter: Learning to index for deep image matting. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pp. 3266-3275, 2019.
402
+ Lutz, S., Amplanitis, K., and Smolic, A. Alphagan: Generative adversarial networks for natural image matting. arXiv preprint arXiv:1807.10088, 2018.
403
+ Ma, H., Han, Z., Zhang, C., Fu, H., Zhou, J. T., and Hu, Q. Trustworthy multimodal regression with mixture of normal-inverse gamma distributions. Advances in Neural Information Processing Systems, 34:6881-6893, 2021.
404
+ Maddox, W. J., Izmailov, P., Garipov, T., Vetrov, D. P., and Wilson, A. G. A simple baseline for bayesian uncertainty in deep learning. Advances in Neural Information Processing Systems, 32, 2019.
405
+ Nandy, J., Hsu, W., and Lee, M. L. Towards maximizing the representation gap between in-domain & out-of-distribution examples. Advances in Neural Information Processing Systems, 33:9239-9250, 2020.
406
+ Ning, Q., Tang, J., Wu, F., Dong, W., Li, X., and Shi, G. Learning degradation uncertainty for unsupervised real-world image super-resolution. In Raedt, L. D. (ed.), Proceedings of the Thirty-First International Joint Conference on Artificial Intelligence, IJCAI-22, pp. 1261-1267. International Joint Conferences on Artificial Intelligence Organization, 7 2022. doi: 10.24963/ijcai.2022/176. URL https://doi.org/10.24963/ijcai.2022/176. Main Track.
407
+ Oakley, J. and O'Hagan, A. Bayesian inference for the uncertainty distribution of computer model outputs. Biometrika, 89(4):769-784, 2002.
408
+
409
+ Otsu, N. A threshold selection method from gray-level histograms. IEEE transactions on systems, man, and cybernetics, 9(1):62-66, 1979.
410
+ Park, G., Son, S., Yoo, J., Kim, S., and Kwak, N. Matteformer: Transformer-based image matting via prior-tokens. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11696-11706, 2022.
411
+ Qian, H. Big data bayesian linear regression and variable selection by normal-inverse-gamma summation. Bayesian Analysis, 13(4):1011-1035, 2018.
412
+ Qiao, Y., Liu, Y., Yang, X., Zhou, D., Xu, M., Zhang, Q., and Wei, X. Attention-guided hierarchical structure aggregation for image matting. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 13676-13685, 2020.
413
+ Qin, X., Zhang, Z., Huang, C., Dehghan, M., Zaiane, O. R., and Jagersand, M. U2-net: Going deeper with nested u-structure for salient object detection. Pattern Recognition, 106:107404, 2020.
414
+ Sambyal, A. S., Krishnan, N. C., and Bathula, D. R. Towards reducing aleatoric uncertainty for medical imaging tasks. In 2022 IEEE 19th International Symposium on Biomedical Imaging (ISBI), pp. 1-4. IEEE, 2022.
415
+ Sensoy, M., Kaplan, L., and Kandemir, M. Evidential deep learning to quantify classification uncertainty. Advances in neural information processing systems, 31, 2018.
416
+ Stadler, M., Charpentier, B., Geisler, S., Zügner, D., and Gunnemann, S. Graph posterior network: Bayesian predictive uncertainty for node classification. Advances in Neural Information Processing Systems, 34:18033-18048, 2021.
417
+ Sun, Y., Tang, C.-K., and Tai, Y.-W. Semantic image matting. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11120-11129, 2021.
418
+ Tang, J., Aksoy, Y., Oztireli, C., Gross, M., and Aydin, T. O. Learning-based sampling for natural image matting. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 3055-3063, 2019.
419
+ Wei, T., Chen, D., Zhou, W., Liao, J., Zhao, H., Zhang, W., and Yu, N. Improved image matting via real-time user clicks and uncertainty estimation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 15374-15383, 2021.
420
+ Weise, K. and Woger, W. A bayesian theory of measurement uncertainty. Measurement Science and Technology, 4(1): 1, 1993.
421
+
422
+ Xu, N., Price, B., Cohen, S., and Huang, T. Deep image matting. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 2970-2979, 2017.
423
+ Yu, C., Xiao, B., Gao, C., Yuan, L., Zhang, L., Sang, N., and Wang, J. Lite-hrnet: A lightweight high-resolution network. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10440-10450, 2021a.
424
+ Yu, H., Xu, N., Huang, Z., Zhou, Y., and Shi, H. High-resolution deep image matting. In Proceedings of the AAAI Conference on Artificial Intelligence, volume 35, pp. 3217-3224, 2021b.
425
+ Yu, Q., Zhang, J., Zhang, H., Wang, Y., Lin, Z., Xu, N., Bai, Y., and Yuille, A. Mask guided matting via progressive refinement network. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 1154-1163, 2021c.
426
+ Zheng, Y. and Kambhamettu, C. Learning based digital matting. In 2009 IEEE 12th international conference on computer vision, pp. 889-896. IEEE, 2009.
427
+ Zhou, A. and Levine, S. Amortized conditional normalized maximum likelihood: Reliable out of distribution uncertainty estimation. In International Conference on Machine Learning, pp. 12803-12812. PMLR, 2021.
428
+
429
+ # A. Proof
430
+
431
+ The marginal likelihood of Normal-Inverse-Gamma distribution by Type-II maximum likelihood technique is defined by
432
+
433
+ $$
434
+ \begin{array}{l} p (y | \tau) = \int_ {\zeta} p (y | \zeta) p (\zeta | \tau) d \zeta \\ = \int_ {\sigma^ {2}} ^ {\infty} \int_ {\mu = - \infty} ^ {\infty} p (y | \mu , \sigma^ {2}) p (\mu , \sigma^ {2} | \tau) d \mu d \sigma^ {2} \\ = \int_ {\sigma^ {2}} ^ {\infty} \int_ {\mu = - \infty} ^ {\infty} p (y | \mu , \sigma^ {2}) p (\mu , \sigma^ {2} | \gamma , \omega , \alpha , \beta) d \mu d \sigma^ {2} \\ = \int_ {\sigma^ {2}} ^ {\infty} \int_ {\mu = - \infty} ^ {\infty} \left[ \sqrt {\frac {1}{2 \pi \sigma^ {2}}} \exp \left\{- \frac {(y - \mu) ^ {2}}{2 \sigma^ {2}} \right\} \right] \left[ \frac {\beta}{\omega \alpha} \frac {\sqrt {\omega}}{\sqrt {2 \pi \sigma^ {2}}} \left(\frac {1}{\sigma^ {2}}\right) ^ {\alpha + 1} \exp \left\{- \frac {2 \beta + \omega (\gamma - \mu)}{2 \sigma^ {2}} \right\} \right] d \mu d \sigma^ {2} \\ = \int_ {\sigma^ {2}} ^ {\infty} \frac {\beta^ {\alpha} \sigma^ {- 3 - 2 \alpha}}{\sqrt {2 \pi} \sqrt {1 + 1 / \omega} \Gamma (\alpha)} \exp \left\{- \frac {2 \beta + \frac {\omega (y - \gamma) ^ {2}}{1 + \omega}}{2 \sigma^ {2}} \right\} d \sigma^ {2} \\ = \frac {\Gamma (1 / 2 + \alpha)}{\Gamma (\alpha)} \sqrt {\frac {\omega}{\pi}} (2 \beta (1 + \omega)) ^ {\alpha} \left(\omega (y - \gamma) ^ {2} + 2 \beta (1 + \omega)\right) ^ {- (\frac {1}{2} + \alpha)} \\ = S t \left(y; \gamma , \frac {\beta (1 + \omega)}{\omega \alpha}, 2 \alpha\right). \\ \end{array}
435
+ $$
436
+
437
+ Maximizing the likelihood as Equation (1) by using the standard parameterization for Student t distribution makes our model fit the data.
438
+
439
+ According to $\sigma^2\sim \Gamma^{-1}(\alpha ,\beta)$ , the $Var(\sigma^2)$ is derived from
440
+
441
+ $$
442
+ V a r \left(\sigma^ {2}\right) = \mathbb {E} \left(\left(\sigma^ {2}\right) ^ {2}\right) - \mathbb {E} \left(\left(\sigma^ {2}\right)\right) ^ {2},
443
+ $$
444
+
445
+ where
446
+
447
+ $$
448
+ \begin{array}{l} \mathbb {E} ((\sigma^ {2}) ^ {n}) = \frac {\beta}{\Gamma (\alpha)} \int_ {0} ^ {\infty} \sigma^ {n - 2 \alpha - 2} \exp (- \beta / \sigma^ {2}) d \sigma^ {2} \\ = \frac {\beta^ {\alpha}}{\Gamma (\alpha)} \frac {\Gamma (\alpha - n)}{\beta^ {\alpha - n}} \\ = \frac {\beta^ {n} \Gamma (\alpha - n)}{(\alpha - 1) \cdots (\alpha - n) \Gamma (\alpha - n)} \\ = \frac {\beta^ {n}}{(\alpha - 1) \cdots (\alpha - n)}, \\ \end{array}
449
+ $$
450
+
451
+ For $\alpha > 1$ , we have
452
+
453
+ $$
454
+ \mathbb {E} (\sigma^ {2}) = \frac {\beta}{\alpha - 1},
455
+ $$
456
+
457
+ and for $\alpha > 2$ , we have
458
+
459
+ $$
460
+ \mathbb {E} ((\sigma^ {2}) ^ {2}) = \frac {\beta^ {2}}{(\alpha - 1) (\alpha - 2)}.
461
+ $$
462
+
463
+ Accordingly, we can obtain the variance as
464
+
465
+ $$
466
+ V a r (\sigma^ {2}) = \frac {\beta^ {2}}{(\alpha - 1) ^ {2} (\alpha - 2)}.
467
+ $$
468
+
469
+ # B. More Details
470
+
471
+ # B.1. Details of User Map
472
+
473
+ For the construction of user map $U$ , we randomly sample $L$ patches with $15 \times 15$ , where $L$ is drawn from a geometric distribution with $p = \frac{1}{6}$ . The user map $U \in [-1,0,0.5,1]^{1 \times H \times W}$ where foreground is 1, background is -1, transition is 0.5 and unknown is 0.
474
+
475
+ # B.2. Details of Refinement Module
476
+
477
+ Since the refinement module aims to recover the high-frequency details, we use the Naive Lite-HRNet-18 (Yu et al., 2021a) and bilinear interpolation as the refinement module. The Naive Lite-HRNet-18 can efficiently preserve high-resolution features with only 0.7M parameters.
478
+
479
+ # C. More Experiments
480
+
481
+ # C.1. Resource Comparison of Major Interaction
482
+
483
+ We also conduct a comparison experiment to explore the resource consumption of the major interaction methods. As shown in Table 5, the trimap, scribble, and click methods do not require extra parameters while they need to take times between 17 and 260 seconds. In contrast, our method only takes 8 seconds and requires almost no extra parameters. The reason is that our interaction method actively proposes the interaction area based on the epistemic uncertainty, allowing the user to focus on the annotation. It significantly enhances the interaction efficiency.
484
+
485
+ Table 5. Comparison results of resource consuming on 10 samples of the Conposition-1K (Xu et al., 2017) benchmark.
486
+
487
+ <table><tr><td>Interaction method</td><td>Times</td><td>Extra Parameters</td></tr><tr><td>Trimap</td><td>261s</td><td>-</td></tr><tr><td>Mask</td><td>234s</td><td>-</td></tr><tr><td>scribble</td><td>171s</td><td>-</td></tr><tr><td>Click</td><td>17s</td><td>-</td></tr><tr><td>Selection (ours)</td><td>8s</td><td>0.7M</td></tr></table>
488
+
489
+ # C.2. Uncertainty Estimation
490
+
491
+ We evaluate the epistemic uncertainty and aleatoric uncertainty on unseen P3M-500-NP test dataset using MODNet. The input, absolute error, evaluation of epistemic uncertainty and aleatoric uncertainty are depicted in Figure 8. For the evaluation of epistemic uncertainty, we use calibration curves to evaluate the estimation. Calibration curves are computed according to (Kuleshov et al., 2018), and ideally follows $y = x$ to represent, for example, that a target falls in a $90\%$ confidence interval approximately $90\%$ of the time. It is observed that epistemic uncertainty matches error regions in most time. For the evaluation of aleatoric uncertainty, we can find that the aleatoric uncertainty is misestimated in some cases, and the variance of the aleatoric uncertainty can serve as an additional metric to identify these regions. Thus, it is appropriate for our strategy to utilize epistemic uncertainty to identify areas of user interaction and aleatoric uncertainty to guide the refinement of details.
492
+
493
+ ![](images/2bb5293be68c908bfb53a14cef3861910c226240d48917ced1631af0d314836d.jpg)
494
+ Figure 8. Uncertainty evaluation of MODNet. Epistemic uncertainty matches error regions in most time. Aleatoric uncertainty may capture erroneous transition regions, the variance of aleatoric uncertainty can help to more precisely indicate transition regions.
dugmattingdecomposeduncertaintyguidedmatting/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0097c25b4404c724e97903ff1aaf3efcd69ba2a50a6934c0a53eb63552a70907
3
+ size 980931
dugmattingdecomposeduncertaintyguidedmatting/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d4c1e21c28ba1f5bcc964cb16e2bc99eca31f6ea262234d27b1ca0c1ab648d7
3
+ size 570590
mplug2amodularizedmultimodalfoundationmodelacrosstextimageandvideo/e27b8a9b-a2c2-4a23-a125-949d4d80671c_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0652d1a3afcb5486d0bcafb0f2430fdae371f8c1468f3c7a659fb595b7ffd72
3
+ size 162116
mplug2amodularizedmultimodalfoundationmodelacrosstextimageandvideo/e27b8a9b-a2c2-4a23-a125-949d4d80671c_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e6b24b000fc921ef21920c863ce3a7edb1a1bd8d5d56e6f51bd0632aee2fabe7
3
+ size 204637
mplug2amodularizedmultimodalfoundationmodelacrosstextimageandvideo/e27b8a9b-a2c2-4a23-a125-949d4d80671c_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8934c6ccb18b84dccc8457b9055a1b6a73137b338d643e02e58aede24816a505
3
+ size 3555327
mplug2amodularizedmultimodalfoundationmodelacrosstextimageandvideo/full.md ADDED
The diff for this file is too large to render. See raw diff
 
mplug2amodularizedmultimodalfoundationmodelacrosstextimageandvideo/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0b1415b8d9b17b8539d3180d7a30f4891f198cbedb8adb55f2da32f89d2a5b4a
3
+ size 1242482
mplug2amodularizedmultimodalfoundationmodelacrosstextimageandvideo/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bb0e359e69cfda44457465e5efb83c17203a93bee4c22e6d4d52030638d01db9
3
+ size 722891
simplediffusionendtoenddiffusionforhighresolutionimages/8cd9cb19-cae7-4216-a18a-142392fe9ee0_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:81699d13cb4270865df34a17f0214f2d0999d13e7146e5183d877e78ab29962d
3
+ size 124176
simplediffusionendtoenddiffusionforhighresolutionimages/8cd9cb19-cae7-4216-a18a-142392fe9ee0_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9c8313ce7e352d2d17a6eae724153b5b650ab2f7f70f442efe905a542319b320
3
+ size 143550
simplediffusionendtoenddiffusionforhighresolutionimages/8cd9cb19-cae7-4216-a18a-142392fe9ee0_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a0c431ab1f10aee8d7c419b04aa26ea593bef9b5810a8695591ee416e5e504a
3
+ size 2913865
simplediffusionendtoenddiffusionforhighresolutionimages/full.md ADDED
@@ -0,0 +1,712 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # simple diffusion: End-to-end diffusion for high resolution images
2
+
3
+ Emiel Hoogeboom *1 Jonathan Heek *1 Tim Salimans
4
+
5
+ # Abstract
6
+
7
+ Currently, applying diffusion models in pixel space of high resolution images is difficult. Instead, existing approaches focus on diffusion in lower dimensional spaces (latent diffusion), or have multiple super-resolution levels of generation referred to as cascades. The downside is that these approaches add additional complexity to the diffusion framework.
8
+
9
+ This paper aims to improve denoising diffusion for high resolution images while keeping the model as simple as possible. The paper is centered around the research question: How can one train standard diffusion models on high resolution images, and still obtain performance comparable to these alternate approaches?
10
+
11
+ The four main findings are: 1) the noise schedule should be adjusted for high resolution images, 2) It is sufficient to scale only a particular part of the architecture, 3) dropout should be added at specific locations in the architecture, and 4) downsampling is an effective strategy to avoid high resolution feature maps. Combining these simple yet effective techniques, we achieve state-of-the-art on image generation among diffusion models without sampling modifiers on ImageNet.
12
+
13
+ # 1. Introduction
14
+
15
+ Score-based diffusion models have become increasingly popular for data generation. In essence the idea is simple: one pre-defines a diffusion process, which gradually destroys information by adding random noise. Then, the opposite direction defines the denoising process, which is approximated with a neural network.
16
+
17
+ *Equal contribution ¹Google Research, Brain Team, Amsterdam, Netherlands. Correspondence to: Emiel Hoogeboom <emielh@google.com>.
18
+
19
+ Proceedings of the $40^{th}$ International Conference on Machine Learning, Honolulu, Hawaii, USA. PMLR 202, 2023. Copyright 2023 by the author(s).
20
+
21
+ ![](images/e06057b4601fb527519b77a87fa866f8902984ab2940c8770db0f1419a2a3724.jpg)
22
+
23
+ ![](images/2a01a474f74d6fea399767a56a3e19b0bf2695a1c3867e5c80951110d4b49b16.jpg)
24
+
25
+ ![](images/05240123b2b2042b1bc725182d3e43e27202bb24422c76900f668b99ccc0e9de.jpg)
26
+ Figure 1: A dslr photo of a frog wearing a sweater, An owl playing the piano, vivid, fantasy art, and two robots playing chess with New York in the background. Except for the frozen text encoder, simple diffusion is trained end-to-end and images are generated in full pixel space.
27
+
28
+ Diffusion models have shown to be extremely effective for image, audio, and video generation. However, for higher resolutions the literature typically operates on lower dimensional latent spaces (latent diffusion) (Rombach et al., 2022) or divides the generative process into multiple sub-problems, for instance via super-resolution (cascaded diffusion) (Ho et al., 2022) or mixtures-of-denoising-experts (Balaji et al., 2022). The disadvantage is that these approaches introduce additional complexity and usually do not support a single end-to-end training setup.
29
+
30
+ In this paper, we aim to improve standard denoising diffusion for higher resolutions while keeping the model as
31
+
32
+ ![](images/44f8ce1da6d506c916533ed03f32001fa506b5b003a7e5d1ba1e227c1e50a61b.jpg)
33
+ $512 \times 512$
34
+
35
+ ![](images/ca140987167d80a3671649fc7c7068fec1eef8ec5c471d3150124c3f26439d4f.jpg)
36
+ $256 \times 256$
37
+
38
+ ![](images/f67979589b130e9a0964a25626f9989d168df8e23d88afe6b722044cfeac8f26.jpg)
39
+ $128\times 128$
40
+ Figure 2: Generated images with simple diffusion. Importantly, each image is generated in full image space by a single diffusion model without any cascades (super-resolution) or mixtures of experts. Samples are drawn from the U-Net model with guidance scale 4.
41
+
42
+ simple as possible. Our four main findings are that 1) the noise schedule should be adjusted for larger images, adding more noise as the resolution increases. 2) It is sufficient to scale the U-Net architecture on the $16 \times 16$ resolution to improve performance. Taking this one step further is the U-ViT architecture, a U-Net with a transformer backbone. 3) Dropout should be added for improved performance, but not on the highest resolution feature maps. And finally 4) for higher resolutions, one can down-sample without performance degradation. Most importantly, these results are obtained using just a single model and an end-to-end training setup. After using existing distillation techniques which now only have to be applied to a single stage, the model can generate an image in 0.4 seconds.
43
+
44
+ # 2. Background: Diffusion Models
45
+
46
+ A diffusion model generates data by learning the reverse of a destruction process. Commonly, the diffusion process gradually adds Gaussian noise over time. It is convenient to express the process directly in the marginals $q(\boldsymbol{z}_t|\boldsymbol{x})$ which is given by:
47
+
48
+ $$
49
+ q \left(\boldsymbol {z} _ {t} \mid \boldsymbol {x}\right) = \mathcal {N} \left(\boldsymbol {z} _ {t} \mid \alpha_ {t} \boldsymbol {x}, \sigma_ {t} ^ {2} \mathbf {I}\right) \tag {1}
50
+ $$
51
+
52
+ where $\alpha_{t},\sigma_{t}\in (0,1)$ are hyperparameters that determine how much signal is destroyed at a timestep $t$ , which can be continuous for instance $t\in [0,1]$ . Here, $\alpha_{t}$ is decreasing and $\sigma_{t}$ is increasing, both larger than zero. We consider a variance preserving process, which fixes the relation between $\alpha_{t},\sigma_{t}$ to be $\alpha_t^2 = 1 - \sigma_t^2$ . Assuming the diffusion process is Markov, the transition distributions are given by:
53
+
54
+ $$
55
+ q \left(\boldsymbol {z} _ {t} \mid \boldsymbol {z} _ {s}\right) = \mathcal {N} \left(\boldsymbol {z} _ {t} \mid \alpha_ {t s} \boldsymbol {z} _ {s}, \sigma_ {t s} ^ {2} \mathbf {I}\right) \tag {2}
56
+ $$
57
+
58
+ where $\alpha_{ts} = \alpha_t / \alpha_s$ and $\sigma_{ts}^2 = \sigma_t^2 -\alpha_{t|s}^2\sigma_s^2$ and $t > s$
59
+
60
+ Noise schedule An often used noise schedule is the $\alpha$ -cosine schedule where $\alpha_{t} = \cos (\pi t / 2)$ which under the variance preserving assumption implies $\sigma_t = \sin (\pi t / 2)$ . An important finding from (Kingma et al., 2021) is that it is the signal-to-noise ratio $\alpha_{t} / \sigma_{t}$ that matters, which is then $1 / \tan (\pi t / 2)$ or in log space $\log \frac{\alpha_t}{\sigma_t} = -\log \tan (\pi t / 2)$ .
61
+
62
+ Denoising Conditioned on a single datapoint $\pmb{x}$ , the denoising process can be written as:
63
+
64
+ $$
65
+ q \left(\boldsymbol {z} _ {s} \mid \boldsymbol {z} _ {t}, \boldsymbol {x}\right) = \mathcal {N} \left(\boldsymbol {z} _ {t} \mid \boldsymbol {\mu} _ {t \rightarrow s}, \sigma_ {t \rightarrow s} ^ {2} \mathbf {I}\right). \tag {3}
66
+ $$
67
+
68
+ where $\pmb{\mu}_{t\rightarrow s} = \frac{\alpha_{ts}\sigma_s^2}{\sigma_t^2}\pmb{z}_t + \frac{\alpha_s\sigma_{ts}^2}{\sigma_t^2}\pmb{x}$ and $\sigma_{t\to s} = \frac{\sigma_{ts}^2\sigma_s^2}{\sigma_t^2}$ . An important and surprising result in literature is that when $\pmb{x}$ is approximated by a neural network $\hat{\pmb{x}} = f_{\theta}(\pmb{z}_t)$ , then one can define the learned distribution $p(\pmb{z}_s|\pmb{z}_t) = q(\pmb{z}_s|\pmb{z}_t,\pmb{x} = \hat{\pmb{x}})$ without loss of generality as $s\rightarrow t$ . This works because as $s\rightarrow t$ , the true denoising distribution for all datapoints $q(\pmb{z}_s|\pmb{z}_t)$ (which is typically unknown) will become equal to $q(\pmb{z}_s|\pmb{z}_t,\pmb{x} = \mathbb{E}[\pmb{x}|\pmb{z}_t])$ (Song et al., 2021).
69
+
70
+ Parametrization The network does not need to approximate $\hat{\pmb{x}}$ directly, and experimentally it has been found that other predictions produce higher visual quality. Studying the re-parametrization of the marginal $q(\pmb{z}_t|\pmb{x})$ which is $\pmb{z}_t = \alpha_t\pmb{x} + \sigma_t\pmb{\epsilon}_t$ where $\pmb{\epsilon}_t \sim \mathcal{N}(0,1)$ , one can for instance choose the epsilon parametrization where the neural net predicts $\hat{\pmb{\epsilon}}_t$ . To obtain $\hat{\pmb{x}}$ , one computes $\hat{\pmb{x}} = \pmb{z}_t / \alpha_t - \sigma_t\hat{\pmb{\epsilon}}_t / \alpha_t$ . The problem with the epsilon parametrization is that it gives unstable sampling near $t = 1$ . An alternative parametrization without this issue is called $\nu$ prediction and was proposed in (Salimans & Ho, 2022), it is defined as $\hat{\pmb{v}}_t = \alpha_t\hat{\pmb{\epsilon}}_t - \sigma_t\hat{\pmb{x}}$ .
71
+
72
+ Note that given $\pmb{z}_t$ one can obtain $\hat{\pmb{x}}$ and $\hat{\pmb{\epsilon}}_t$ via the identities $\sigma_t\pmb {z}_t + \alpha_t\hat{\pmb{v}}_t = (\sigma_t^2 +\alpha_t^2)\hat{\pmb{\epsilon}}_t = \hat{\pmb{\epsilon}}_t$ and $\alpha_{t}\pmb {z}_{t} - \sigma_{t}\hat{\pmb{v}}_{t} = (\alpha_{t}^{2} + \sigma_{t}^{2})\hat{\pmb{x}} = \hat{\pmb{x}}$ . In initial experiments we found $v$ prediction to train more reliably, especially for larger resolutions, and therefore we use this parametrization throughout this paper.
73
+
74
+ ![](images/b586ee7155ddd587ba4732edd35a6aa63c329d34358bb8bddf40906817071326.jpg)
75
+
76
+ ![](images/05ce4ba9d993d574766655d50039676509a4a34a237be1e18b9f4922e38a41cb.jpg)
77
+
78
+ ![](images/62ecf09a06632c75055f6e3759ebbaa5be99e051a399ee89584e268eedbe3819.jpg)
79
+
80
+ ![](images/8fa822946bf92f41cd41825813e4a09a9d18b6f43eb31b7f5f98da6856605dc5.jpg)
81
+
82
+ ![](images/c70d35a53dd3429615329b36d95b77367a547f9b632a62a2787f4bbe71ef64ae.jpg)
83
+
84
+ ![](images/42f56d7c242d6a9180f5752340b3eab05e66aa4103c9fcd556768e29d0d088d0.jpg)
85
+
86
+ ![](images/dd182dbf96cc7703fa90e08ae626075b54984ccea7ffd02f37596f8b8c77e133.jpg)
87
+ t=0
88
+
89
+ ![](images/f28d5b71698542245e59225720c72d95983a63e21c65be0ac164d27bedc050a1.jpg)
90
+ Figure 3: The standard and shifted diffusion noise on an image of $512 \times 512$ , that is visualized by average pooling to a resolution of $64 \times 64$ . The top row shows a conventional cosine schedule, the bottom row shows our proposed shifted schedule.
91
+
92
+ ![](images/177c611e8a6035450e90646361c1393b870d028dd2f33c2156e9e081f704be5b.jpg)
93
+
94
+ ![](images/25a85cf15ccb44b53f10ab7f359c7199b0b378812e01c8846463a038728f90f0.jpg)
95
+
96
+ ![](images/ba34d33008386aca72000bfa854a2cfd733ab1a69f354f4e4b84c070dcb9a486.jpg)
97
+
98
+ ![](images/f1afb7552a6f2babb9a295e792339322a4fc865a2b22d9cacdbed515cfd02841.jpg)
99
+
100
+ Optimization To train the model, we use the standard epsilon loss from (Ho et al., 2020). A way to motivate this choice of loss, is that using variational inference one can derive a lowerbound (in continuous time) on the model log-likelihood as done in (Kingma et al., 2021):
101
+
102
+ $$
103
+ \begin{array}{l} \log p (\boldsymbol {x}) = \log \mathbb {E} _ {q} \frac {p (\boldsymbol {x} , \boldsymbol {z} _ {0} , \dots , \boldsymbol {z} _ {1})}{q (\boldsymbol {z} _ {0} , \dots , \boldsymbol {z} _ {1} | \boldsymbol {x})} \geq \mathbb {E} _ {q} \log \frac {p (\boldsymbol {x} , \boldsymbol {z} _ {0} , \dots , \boldsymbol {z} _ {1})}{q (\boldsymbol {z} _ {0} , \dots , \boldsymbol {z} _ {1} | \boldsymbol {x})} \\ = \mathcal {L} _ {x} + \mathcal {L} _ {T} - \mathbb {E} _ {t \sim \mathcal {U} (0, 1)} \left[ w (t) | | \boldsymbol {\epsilon} _ {t} - \hat {\boldsymbol {\epsilon}} _ {t} | | ^ {2} \right], \\ \end{array}
104
+ $$
105
+
106
+ where for a well-defined process $\mathcal{L}_x = -\log p(\pmb{x}|\pmb{z}_0) \approx 0$ for discrete $\pmb{x}$ , $\mathcal{L}_T = -\mathrm{KL}(q(\pmb{z}_T|\pmb{x})|p(\pmb{z}_T)) \approx 0$ , and where $w(t)$ is a weighting function which for the equation to be true needs to be $w(t) = -\frac{\mathrm{d}}{\mathrm{d}t}\log \mathrm{SNR}(t)$ where $\mathrm{SNR}(t) = \alpha_t^2 / \sigma_t^2$ . In practice, we generally use the unweighted loss on $\epsilon_t$ (meaning that $w(t) = 1$ ) which in (Ho et al., 2020) was found to give superior sample quality. See Appendix A for additional useful background information.
107
+
108
+ # 3. Method: simple diffusion
109
+
110
+ In this section, we introduce several modifications that enable denoising diffusion to work well on high resolutions.
111
+
112
+ # 3.1. Adjusting Noise Schedules
113
+
114
+ One of the modifications is the noise schedule that is typically used for diffusion models. The most common schedules are the $\alpha$ -cosine schedule, which under the variance preserving assumption amounts to $\frac{\sigma_t}{\alpha t} = \tan(\pi t / 2)$ (ignoring the boundaries around $t = 0$ and $t = 1$ for this analysis) (Nichol & Dhariwal, 2021). This schedule was originally proposed to improve the performance on CIFAR10 which has a resolution of $32 \times 32$ and ImageNet $64 \times 64$ .
115
+
116
+ However, for high resolutions not enough noise is added. For instance, inspecting the top row of Figure 3 shows that for the standard cosine schedule, the global structure of the image is largely defined already for a wide range in
117
+
118
+ time. This is problematic because the generative denoising process only has a small time window to decide on the global structure of the image. We argue that for higher resolutions, this schedule can be changed in a predictable way to retain good visual sample quality.
119
+
120
+ To illustrate this need in more detail, let us study a $128 \times 128$ problem. Given an input image $\pmb{x}$ the diffusion distribution for pixel $i$ is given by $q(z_{t}^{(i)}|\pmb{x}) = \mathcal{N}(z_{t}^{(i)}|\alpha_{t}x_{i},\sigma_{t})$ . Commonly, diffusion models use network architectures that use downsampling to operate on lower resolution feature maps, in our case with average pooling. Suppose we average pool $z_{t}$ , where we let indices $1,2,3,4$ denote the pixels in a $2 \times 2$ square that is being pooled. This new pixel is $z_{t}^{64 \times 64} = (z_{t}^{(1)} + z_{t}^{(2)} + z_{t}^{(3)} + z_{t}^{(4)}) / 4$ . Recall that for variance of independent random variables is additive meaning that $\mathrm{Var}[X_1 + X_2] = \mathrm{Var}[X_1] + \mathrm{Var}[X_2]$ and that $\mathrm{Var}[aX] = a^2\mathrm{Var}[X]$ for a constant $a$ . Letting $x^{64 \times 64}$ denote the first pixel of the average pooled input image, we find that $z_{t}^{64 \times 64} \sim \mathcal{N}(\alpha_{t}x^{64 \times 64},\sigma_{t} / 2)$ . The lower resolution pixel $z_{t}^{64 \times 64}$ only has half the amount of noise. We hypothesize that as resolutions increase this is problematic, as much less diffusion time is spent on the lower resolution, a stage at which the global consistency is generated.
121
+
122
+ One can further derive that the $\alpha_{t}$ to $\sigma_{t}$ ratio at this lower resolution is twice as high, meaning that the signal to noise ratio is $2^{2}$ as high. And so $\mathrm{SNR}^{64\times 64}(t) = \mathrm{SNR}^{128\times 128}(t)\cdot 2^{2}$ , or in general:
123
+
124
+ $$
125
+ \operatorname {S N R} ^ {d / s \times d / s} (t) = \operatorname {S N R} ^ {d \times d} (t) \cdot s ^ {2} \tag {4}
126
+ $$
127
+
128
+ In summary, after averaging over a window of size $s \times s$ , the ratio $\alpha_{t}$ to $\sigma_{t}$ increases by a factor $s$ (and thus the SNR by $s^2$ ). Hence, we argue that the noise schedule could be defined with respect to some reference resolution, say $32 \times 32$ or $64 \times 64$ for which the schedules were initially designed and successfully tested. In our approach one first chooses a reference resolution, for example
129
+
130
+ ![](images/0d534c2d827a60bf6ee9e63a9db1e027bc5299cf513b08531855b29728cb16e9.jpg)
131
+ (a) A dog riding a bicycle through Amsterdam
132
+
133
+ ![](images/687932960fabc808cd4b8a66fd5d83e2245669c2464ee594f26cf7471ee34ec7.jpg)
134
+ (b) A futuristic car driving through the desert
135
+
136
+ ![](images/01bced6a067f32bb996a80e784033104c647f198b28480268f975ff164bff432.jpg)
137
+
138
+ ![](images/456f43572f03e5c2ff3c4c10e61d7eaad1727dd513125efa077144cc228ce652.jpg)
139
+
140
+ ![](images/aedf1c94979b303524914f50720a69a6ba7600253b325c6eb694b4ccf1e2e276.jpg)
141
+ (c) A distillation machine on a table creating gold
142
+
143
+ ![](images/5780d6477c805241b736e690c8601add218dd9cefe6b77e6fd081312db1cda25.jpg)
144
+
145
+ ![](images/d967dcb4299e702fd78f9a6b3078f4123b6461a1a3e13c392bd305431039e2cd.jpg)
146
+ (d) An abstract painting of an elephant
147
+ (g) A city inside a glass pearl
148
+ Figure 4: Text to image samples at resolution $256 \times 256$ , generated by a single stage diffusion model
149
+
150
+ ![](images/65462149bc55174c69faa2e976f056cb1530d666093d3da5d0be134f8e9eb562.jpg)
151
+ (e) A futuristic city overgrown by nature
152
+ (h) A horse wearing a hat
153
+
154
+ ![](images/72cd6faaa458dc6dc95039ab488211a30f91d1871006902ce77c975e230b999d.jpg)
155
+ (f) A Van Gogh painting of a lion
156
+ (i) A balloon in the shape of the Google Brain logo
157
+
158
+ ![](images/6b84b5211e794cbf75f4c8b2d2086c22fe7eabf7eeebd552ca7fe7cc8658a282.jpg)
159
+ Figure 5: Log signal to noise ratio for the original and shifted cosine schedule.
160
+
161
+ $64 \times 64$ (a reasonable choice as we will see empirically). At the reference resolution we define the noise schedule $\mathrm{SNR}^{64 \times 64}(t) = 1 / \tan (\pi t / 2)^2$ which in turn defines the desired SNR at full resolution $d \times d$ :
162
+
163
+ $$
164
+ \operatorname {S N R} _ {\text {s h i f t} 6 4} ^ {d \times d} (t) = \operatorname {S N R} ^ {6 4 \times 6 4} (t) \cdot (6 4 / d) ^ {2}, \tag {5}
165
+ $$
166
+
167
+ the signal to noise ratio is simply multiplied by $(64 / d)^2$ , which for our setting $d > 64$ reduces the signal-to-noise ratio at high resolution. In log-space, this implies a simple shift of $2 \cdot \log (64 / d)$ (see Figure 5). For example, the equation of a noise schedule for images of $128 \times 128$ and a reference resolution of 64 the schedule is:
168
+
169
+ $$
170
+ \log \mathrm {S N R} _ {\text {s h i f t 6 4}} ^ {1 2 8 \times 1 2 8} (t) = - 2 \log \tan (\pi t / 2) + 2 \log (6 4 / 1 2 8).
171
+ $$
172
+
173
+ Recall that under a variance preserving process, the diffusion parameters can be computed as $\alpha_{t}^{2} =$ sigmoid(log SNR(t)) and $\sigma_t^2 =$ sigmoid(- log SNR(t)).
174
+
175
+ Finally, it may be worthwhile to study the concurrent and complementary work (Chen, 2023) which also analyzes adjusted noise schedules for higher resolution images and describes several other improvements as well.
176
+
177
+ Interpolating schedules A potential downside of shifting the schedule is that high frequency details are now generated much later in the diffusion process due to the increased per-pixel noise. However, we postulate that high-frequency details are weakly correlated when conditioning on the global/low-frequency features that are already generated. It should therefore be possible to generate the high-frequency details in few diffusion steps. Alternatively, one can interpolate different shift schedules, for example for a resolution of 512 one could include higher frequency details by starting at shift 32 and interpolating in log-space to shift 256. The schedule for $\log \mathrm{SNR}_{\mathrm{interpolate}(32\to 256)}(t)$ equals:
178
+
179
+ $$
180
+ t \log \mathrm {S N R} _ {\text {s h i f t} 2 5 6} ^ {5 1 2 \times 5 1 2} (t) + (1 - t) \log \mathrm {S N R} _ {\text {s h i f t} 3 2} ^ {5 1 2 \times 5 1 2} (t) \tag {6}
181
+ $$
182
+
183
+ which has more equal weighting over low, mid and high frequency details. When sampling guidance is desired (for example in our text to image experiments) we recommend using this interpolated schedule. We found that shifted schedules can only tolerate little guidance, and interpolated schedules get better results with higher guidance weights.
184
+
185
+ # 3.2. Multiscale training loss
186
+
187
+ In the last section we argued that the noise schedule of our diffusion model should be adjusted when training on high resolution images so that the signal-to-noise ratio at our base resolution is held constant. However, even when adjusting the noise schedule in this way, the training loss on images of increasingly high resolution is dominated by high frequency details. To correct for this we propose replacing the standard training loss by a multiscale version that evaluates the standard training loss at downsampled resolutions with a weighting factor that increases for the lower resolutions. We find that the multiscale loss enables quicker convergence especially at resolutions greater than $256 \times 256$ . The training loss at the $d \times d$ resolution can be written as:
188
+
189
+ $$
190
+ L _ {\theta} ^ {d \times d} (\pmb {x}) = \frac {1}{d ^ {2}} \mathbb {E} _ {\pmb {\epsilon}, t} \| \mathbf {D} ^ {d \times d} [ \pmb {\epsilon} ] - \mathbf {D} ^ {d \times d} [ \hat {\pmb {\epsilon}} _ {\theta} (\alpha_ {t} \pmb {x} + \sigma_ {t} \pmb {\epsilon}, t) ] \| _ {2} ^ {2},
191
+ $$
192
+
193
+ where $\mathrm{D}^{d\times d}$ denotes downsampling to the $d\times d$ resolution. If this resolution is identical to the native resolution of our model $\hat{\epsilon}_{\theta}$ and data $\pmb{x}$ , the downsampling does not do anything and can be removed from this equation. Otherwise, $\mathrm{D}^{d\times d}[\hat{\epsilon}_{\theta}]$ can be considered as an adjusted denoising model for data at non-native resolution $d\times d$ . Since downsampling an image is a linear operation, we have that $\mathrm{D}^{d\times d}[\mathbb{E}(\epsilon |x)] = \mathbb{E}(\mathrm{D}^{d\times d}[\epsilon ]|x)$ , and this way of constructing the lower-resolution model is thus indeed consistent with our original model.
194
+
195
+ We then propose training our high resolution model against the multiscale training loss comprising of multiple resolutions. For instance for the resolutions 32, 64, ..., $d$ the loss would be: $\tilde{L}_{\theta}^{d\times d}(\pmb {x}) = \sum_{s\in \{32,64,128,\dots ,d\}}\frac{1}{s} L_{\theta}^{s\times s}(\pmb {x})$
196
+
197
+ That is, we train against a weighted sum of training losses for resolutions starting at a base resolution (in this case $32 \times 32$ ) and always including the final resolution of $d \times d$ . We find that losses for higher resolution are noisier on average, and we therefore decrease the relative weight of the loss as we increase the resolution.
198
+
199
+ # 3.3. Scaling the Architecture
200
+
201
+ Another question is how to scale the architecture. Typical model architectures half the channels each time the resolution is doubled such that the flops per operation is the same but the number of features doubles. The computational intensity (flops / features) also halves each time the resolution doubles. Low computational intensity leads to poor utilization of the accelerator and large activations result in out-of-memory issues. As such, we prefer to scale on the lower resolutions feature maps. Our hypothesis is that mainly scaling on a particular resolution, namely the $16 \times 16$ resolution is sufficient to improve performance within a range of network sizes we consider. Typically, low resolution operations have relatively small feature maps. To
202
+
203
+ Table 1: Memory and compute for a convolutional layer at the typical sizes encountered in diffusion architectures. Using more channels is usually much cheaper at lower resolutions in terms of memory, $B = 1024$ for this example.
204
+
205
+ <table><tr><td>Size</td><td>(B × 2562 × 128)</td><td>(B × 162 × 1024)</td></tr><tr><td>Conv Kernel Memory</td><td>2.8MB</td><td>180MB</td></tr><tr><td>Feature Map Memory</td><td>16GB</td><td>0.5GB</td></tr><tr><td>Total Memory</td><td>16GB</td><td>0.7GB</td></tr><tr><td>Compute (TFLOPS)</td><td>9</td><td>2.3</td></tr></table>
206
+
207
+ illustrate this, consider for example
208
+
209
+ $$
210
+ 1 0 2 4 \text {(b a t c h)} \times 1 6 \times 1 6 \times 1 0 2 4 \text {(c h a n n e l)} \cdot 2 \text {b y t e s} / \dim
211
+ $$
212
+
213
+ costs 0.5 GB for a feature map whereas for a $256 \times 256$ feature map with 128 channels, a feature map costs 16 GB, given they are stored in a 16 bit float format.
214
+
215
+ Parameters have a smaller memory footprint: The typical size of a convolutional kernel is $3^{2} \times 128^{2}$ dimensions · 4 bytes/dims · 5 replications = 2.8MB and 180MB for 1024 channels, with 5 replications for the gradient, optimizer state and exponential moving average. The point is, at a resolution of $16 \times 16$ both the size of feature maps are manageable at $16^{2}$ and the required space for the parameters is manageable. Summarizing this back-of-the-envelope calculation in Table 1 one can see that for the same memory constraint, one can fit $16\mathrm{GB} / 0.7\mathrm{GB} \approx 23$ layers at $16 \times 16$ versus only 1 at $256 \times 256$ .
216
+
217
+ Other reasons to choose this resolution is because it is the one at which self-attention starts being used in many existing works in the diffusion literature (Ho et al., 2020; Nichol & Dhariwal, 2021). Furthermore, it is the $16 \times 16$ resolution at which vision transformers for classification can operate successfully (Dosovitskiy et al., 2021). Although this may not be the ideal way to scale the architecture, we will show empirically that scaling the $16 \times 16$ level works well.
218
+
219
+ An observant ML practitioner may have realized that when using multiple devices naively, parameters are replicated (typical in JAX and Flax) or stored on the first device (PyTorch). Both cases result in a situation where the memory requirements per device for the feature maps decreases with $1/$ devices as desired, but the parameter requirement is unaffected and requires a lot of memory. We scale mostly at a low resolution where activations are relatively small but parameter matrices are large $O(\text{features}^2)$ . We found that sharding the weights allows us to scale to much larger models without requiring more complicated parallelization approaches like model parallelism.
220
+
221
+ Avoiding high resolution feature maps High resolution feature maps are memory expensive. If the number of FLOPs is kept constant, memory still scales linearly with the resolution.
222
+
223
+ ![](images/72f8d04b0cda46feea83e080a3b1bdfb44f38661fb7f3f1cbe3fa65465f9cd6a.jpg)
224
+ Figure 6: The '5/3' DWT transform transforms an image to low and high frequency responses. Left: original image. Right: The different frequency responses of a two-level DWT, outputs are four $128 \times 128$ maps and three $256 \times 256$ maps. Best viewed electronically.
225
+
226
+ ![](images/157482bf6b356bea7c5e2acf08243666453b1b9554efe7e33d38cc4ec7158031.jpg)
227
+
228
+ In practise, it is not possible to decrease the channels beyond a certain size without sacrificing accelerator utilization. Modern accelerators have a very high ratio between compute and memory bandwidth. Therefore, a low channel count can make operation memory bound, causing a mostly idling accelerator and worse than expected wall-clock performance.
229
+
230
+ To avoid doing computations on the highest resolutions, we down-sample images immediately as a the first step of the neural network, and up-sample as the last step. Surprisingly, even though the neural networks are cheaper computationally and in terms of memory, we find empirically that they also achieve better performance. We have two approaches to choose from.
231
+
232
+ One approach is to use the invertible and linear 5/3 wavelet (as used in JPEG2000) to transform the image to lower resolution frequency responses as demonstrated in Figure 6. Here, the different feature responses are concatenated spatially for visual purposes. In the network, the responses are concatenated over the channel axis. When more than one level of DWT is applied (here there are two), then the responses differ in resolution. This is resolved by finding the lowest resolution (in the figure $128^{2}$ ) and reshaping pixels for the higher resolution feature maps, in the case of $256^{2}$ they are reshaped $128^{2} \times 4$ , as a typical space to depth operations. A guide on the implementation of the DWT can be found here<sup>1</sup>.
233
+
234
+ If the above seems to be complicated, there also exists a simpler solution if one is willing to pay a small performance penalty. As a first layer one can use a $d \times d$ convolutional layer with stride $d$ , and an identically shaped transposed convolutional layer as a last layer. This is equivalent to what is called patching in transformer literature. Empirically we show this performs similarly, albeit slightly worse.
235
+
236
+ # 3.4.Dropout
237
+
238
+ In architecture typically used in diffusion, a global dropout hyperparameter is used for the residual blocks, at all resolutions. In CDM (Ho et al., 2022), dropout is used to generate images at lower resolutions. For the conditional higher resolution images, no dropout is used. However, various other forms of augmentation are performed on the data. This indicates that regularization is important, even for models operating on high resolutions. However, as we will demonstrate empirically, the naive method of adding dropout in all residual blocks does not give desired results.
239
+
240
+ Since our network design only scales the network size at lower resolutions, we hypothesize that it should be sufficient to only add dropout add the lower resolutions. This avoids regularizing the high resolution layers which are memory-wise expensive, while still using the dropout regularization that has been successful for models trained on lower resolution images.
241
+
242
+ # 3.5. The U-ViT architecture
243
+
244
+ Taken the above described changes to the architecture one step further, one can replace convolutional layers with MLP blocks if the architecture already uses self-attention at that resolution. This bridges the transformers for diffusion introduced by (Peebles & Xie, 2022) with U-Nets, replacing its backbone with a transformer. Consequently, this relatively small change means that we now are using transformer blocks at these resolutions. The main benefit is that the combination of self-attention and MLP blocks has high accelerator utilization, and thus large models train somewhat faster. See Appendix B for details regarding this architecture. In essence, this U-Vision Transformer (U-ViT) architecture can be seen as a small convolutional U-Net which through multiple levels down-samples to the $16 \times 16$ resolution. At this stage a large transformer is applied after which the upsampling is again done via the convolutional U-Net.
245
+
246
+ # 3.6. Text to image generation
247
+
248
+ As a proof of concept, we also train a simple diffusion model conditioned on text data. Following (Saharia et al., 2022) we use the T5 XXL (Raffel et al., 2020) text encoder as conditioning. For further details see Appendix B. We train three models: One on images of resolution $256 \times 256$ for a direct comparison to models in literature, one on $512 \times 512$ and one on $384 \times 640$ . For the last, non-square resolution, images are rotated during prepossessing if their width is smaller than their height, along which a 'portrait mode' flag is set to true. As a result, this model can generate natively in a 5:3 aspect ratio for both landscape and portrait orientation.
249
+
250
+ Table 2: Noise Schedule on ImageNet 128 and 256.
251
+
252
+ <table><tr><td>Noise Schedule</td><td>FID train</td><td>FID eval</td></tr><tr><td colspan="3">128 × 128 resolution</td></tr><tr><td>cosine (original at 128)</td><td>2.96</td><td>3.38</td></tr><tr><td>cosine (shifted to 64)</td><td>2.41</td><td>3.03</td></tr><tr><td>cosine (shifted to 32)</td><td>2.26</td><td>2.88</td></tr><tr><td colspan="3">256 × 256 resolution</td></tr><tr><td>cosine (original at 256)</td><td>7.65</td><td>6.87</td></tr><tr><td>cosine (shifted to 128)</td><td>5.05</td><td>4.74</td></tr><tr><td>cosine (shifted to 64)</td><td>3.94</td><td>3.89</td></tr><tr><td>cosine (shifted to 32)</td><td>3.76</td><td>3.71</td></tr></table>
253
+
254
+ # 4. Related Work
255
+
256
+ Score-based diffusion models (Sohl-Dickstein et al., 2015; Song & Ermon, 2019; Ho et al., 2020) are a generative model that pre-defines a stochastic destruction process. The generative process is learned by approximating the reverse process with the help of neural networks.
257
+
258
+ Diffusion models have been successfully applied to image generation (Ho et al., 2020; 2022), speech generation (Chen et al., 2020; Kong et al., 2021), video generation (Singer et al., 2022; Sahara et al., 2022). Other types of generative models have also been successfully applied to image generation (Chang et al., 2022; Sauer et al., 2022; Anonymous, 2023), although modifications such as guidance and low temperature sampling can make it difficult to compare these models fairly. Diffusion models for high resolutions (for example $512^{2}$ , $256^{2}$ , $128^{2}$ ) on complicated data (such as ImageNet) are generally not learned directly. Instead, approaches in literature divide the generative process into subproblems via super-resolution (Ho et al., 2022), or mixtures-of-denoisers (Feng et al., 2022; Balaji et al., 2022). Alternatively, other approaches project high resolution data down to a lower dimensional latent space (Rombach et al., 2022). Although this sub-division makes optimization easier, the engineering complexity increases: Instead of dealing with a single model, one needs to train and keep track of multiple models. In (Gu et al., 2022) a different approach to adapt noise to resolution is proposed, although this method seems to generate lower quality samples with a more complicated scheme. We show that it is possible to train a single denoising diffusion model for resolutions up to $512 \times 512$ with only a small number of modifications with respect to the original (modern) formulation in (Ho et al., 2020).
259
+
260
+ # 5. Experiments
261
+
262
+ # 5.1. Effects of the proposed modifications
263
+
264
+ Noise schedule In this experiment it is studied how the noise schedule effects the quality of generated images, evaluated on FID50K score on both train and eval data splits. Recall that our hypothesis was that the cosine schedule does not add
265
+
266
+ Table 3: Dropout Ablation on ImageNet 128
267
+
268
+ <table><tr><td>Starting from Resolution</td><td>FID train</td><td>FID eval</td></tr><tr><td>128</td><td>3.19</td><td>3.85</td></tr><tr><td>64</td><td>2.27</td><td>2.85</td></tr><tr><td>32</td><td>2.31</td><td>2.87</td></tr><tr><td>16</td><td>2.41</td><td>3.03</td></tr><tr><td>no dropout (at 700K iters)</td><td>3.74</td><td>3.91</td></tr></table>
269
+
270
+ sufficient noise, but can be adjusted by 'shifting' its log SNR curve using the ratio between the image resolution and the noise resolution. In these experiments, the noise resolution is varied from the original image resolution (corresponding to the conventional cosine schedule) all the way down to 32 by factors of two.
271
+
272
+ As can be seen in Table 2 for ImageNet at resolution $128 \times 128$ and resolution $256 \times 256$ , shifting the noise schedule considerably improves performance. The difference is especially noticeable at the higher resolution, where the difference is 7.65 for the original cosine schedule against 3.76 for the shifted schedule in FID on the train data. Notice that the difference in performance between the shift towards either 64 and 32 is relatively small, albeit slightly better for the 32 shift. Given that the difference is small and that the shift 64 schedule performed slightly better in early iterations, we generally recommend the shift 64 schedule.
273
+
274
+ Dropout The ImageNet dataset has roughly 1 million images. As noted by prior work, it is important to regularize the networks to avoid overfitting (Ho et al., 2022; Dhariwal & Nichol, 2021). Although dropout has been successfully applied to networks at resolutions of $64 \times 64$ , it is often disabled for models operating on high resolutions. In this experiment we enable dropout only on a subset of the network layers: Only for resolutions below the given 'starting resolution' hyperparameter. For example, if the starting resolution is 32, then dropout is applied to modules operating on resolutions $32 \times 32$ , $16 \times 16$ and $8 \times 8$ .
275
+
276
+ Recall our hypothesis that it should be sufficient to regularize the modules of the network that operate on the lower resolution feature maps. As presented in Table 3, this hypothesis holds. For this experiment on images of $128 \times 128$ , adding dropout from resolutions 64, 32, 16 all perform comparatively. Although adding dropout from $16 \times 16$ performed a little worse, we use this setting throughout the remainder of the experiments because it converged faster in early iterations.
277
+
278
+ The experiment also shows two settings that do not work and should be avoided: either adding no dropout, or adding dropout starting from the same resolution as the data. This may explain why dropout for high resolution diffusion has not been widely used thus far: Typically dropout is set as a global parameter for all feature maps at all resolutions, but this experiment shows that such a regularization is too
279
+
280
+ Table 4: Scaling the U-Net architecture
281
+
282
+ <table><tr><td># blocks at 16 × 16</td><td>FID train</td><td>FID eval</td><td>steps / sec</td></tr><tr><td>2 + 3</td><td>3.42</td><td>3.59</td><td>114%</td></tr><tr><td>4 + 5</td><td>2.98</td><td>3.29</td><td>100%</td></tr><tr><td>8 + 9</td><td>2.46</td><td>3.00</td><td>76%</td></tr><tr><td>12 + 13</td><td>2.41</td><td>3.03</td><td>62%</td></tr></table>
283
+
284
+ Table 5: Downsampling strategies on ImageNet ${512} \times {512}$ .
285
+
286
+ <table><tr><td>Strategy</td><td>FID train</td><td>FID eval</td><td>steps / sec</td></tr><tr><td>None</td><td>5.60</td><td>5.23</td><td>100%</td></tr><tr><td>DWT-1</td><td>5.42</td><td>4.97</td><td>139%</td></tr><tr><td>DWT-2</td><td>4.85</td><td>4.58</td><td>146%</td></tr><tr><td>Conv-(2 × 2)</td><td>5.99</td><td>5.33</td><td>137%</td></tr><tr><td>Conv-(4 × 4)</td><td>5.04</td><td>4.80</td><td>146%</td></tr></table>
287
+
288
+ aggressive.
289
+
290
+ Architecture scaling In this section we study the effect of increasing the amount of $16 \times 16$ network modules. In U-Nets, the number of blocks hyperparameter typically refers to the number of blocks on the 'down' path. In many implementations, the 'up' blocks use one additional block. When the table reads $2 + 3$ ' blocks, that means 2 down blocks and 3 up blocks, which would in literature be referred to as 2 blocks.
291
+
292
+ Generally, increasing the number of modules improves the performance as can be seen in Table 4. An interesting exception to this is the eval FID going from 8 to 12 blocks, which decreases slightly. We believe that this may indicate that the network should be more strongly regularized as it grows. This effect will later be observed to be amplified for the larger U-ViT architectures.
293
+
294
+ Avoiding higher resolution feature maps In this experiment, we want to study the effect of downsampling techniques to avoid high resolution feature maps. For this experiment we first have a standard U-Net for images of resolution 512. Then, when we downsample (either to 256 or to 128) using conventional layers or the DWT. For this study the total number of blocks is kept the same, by distributing the high resolution blocks that are skipped over the lower res
295
+
296
+ Table 6: Multiscale loss. Note that the 256 models use the shift 32 and the 512 use shift 64. This loss modifications is helpful for the highest resolution, but diminishes performance slightly for lower resolutions.
297
+
298
+ <table><tr><td>Resolution</td><td>FID train</td><td>FID eval</td><td>IS</td></tr><tr><td>256</td><td>3.76</td><td>3.71</td><td>171.6</td></tr><tr><td>+ multiscale loss (32)</td><td>4.00</td><td>3.89</td><td>171.0</td></tr><tr><td>512</td><td>4.85</td><td>4.58</td><td>156.1</td></tr><tr><td>+ multiscale loss (32)</td><td>4.30</td><td>4.28</td><td>171.0</td></tr></table>
299
+
300
+ Table 7: Comparison to generative models in the literature on ImageNet without any guidance or other sampling modifications, except $(^{*})$ which use temperature scaling.
301
+
302
+ <table><tr><td rowspan="2">Method</td><td colspan="2">FID</td><td rowspan="2">IS</td></tr><tr><td>train</td><td>eval</td></tr><tr><td colspan="4">128 × 128 resolution</td></tr><tr><td>ADM (Dhariwal &amp; Nichol, 2021)</td><td>5.91</td><td></td><td></td></tr><tr><td>CDM (32, 64, 128) (Ho et al., 2022)</td><td>3.52</td><td>3.76</td><td>128.8 ± 2.51</td></tr><tr><td>RIN (Jabri et al., 2022)</td><td>2.75</td><td></td><td>144.1</td></tr><tr><td>simple diffusion (U-Net) (ours)</td><td>2.26</td><td>2.88</td><td>137.3 ± 2.03</td></tr><tr><td>simple diffusion (U-ViT 2B) (ours)</td><td>1.94</td><td>3.23</td><td>171.9 ± 3.24</td></tr><tr><td colspan="4">256 × 256 resolution</td></tr><tr><td>BigGAN-deep (no truncation)</td><td>6.9</td><td></td><td>171.4 ± 2</td></tr><tr><td>MaskGIT (Chang et al., 2022)</td><td>6.18</td><td></td><td>182.1</td></tr><tr><td>DPC* (full 5) (Anonymous, 2023)</td><td>4.45</td><td></td><td>244.8</td></tr><tr><td colspan="4">Denoising diffusion models</td></tr><tr><td>ADM (Dhariwal &amp; Nichol, 2021)</td><td>10.94</td><td></td><td></td></tr><tr><td>CDM (32, 64, 256) (Ho et al., 2022)</td><td>4.88</td><td>4.63</td><td>158.71 ± 2.26</td></tr><tr><td>LDM-4 (Rombach et al., 2022)</td><td>10.56</td><td></td><td>103.49</td></tr><tr><td>RIN (Jabri et al., 2022)</td><td>4.51</td><td></td><td>161.0</td></tr><tr><td>DiT-XL/2 (Peebles &amp; Xie, 2022)</td><td>9.62</td><td></td><td>121.5</td></tr><tr><td>simple diffusion (U-Net) (ours)</td><td>3.76</td><td>3.71</td><td>171.6 ± 3.07</td></tr><tr><td>simple diffusion (U-ViT 2B) (ours)</td><td>2.77</td><td>3.75</td><td>211.8 ± 2.93</td></tr><tr><td colspan="4">512 × 512 resolution</td></tr><tr><td>MaskGIT (Chang et al., 2022)</td><td>7.32</td><td></td><td>156.0</td></tr><tr><td>DPC (U)* (Anonymous, 2023)</td><td>3.62</td><td></td><td>249.4</td></tr><tr><td colspan="4">Denoising diffusion models</td></tr><tr><td>ADM (Dhariwal &amp; Nichol, 2021)</td><td>23.24</td><td></td><td></td></tr><tr><td>DiT-XL/2 (Peebles &amp; Xie, 2022)</td><td>12.03</td><td></td><td>105.3</td></tr><tr><td>simple diffusion (U-Net) (ours)</td><td>4.30</td><td>4.28</td><td>171.0 ± 3.00</td></tr><tr><td>simple diffusion (U-ViT 2B) (ours)</td><td>3.54</td><td>4.53</td><td>205.3± 2.65</td></tr></table>
303
+
304
+ olution blocks (see Appendix B for more details). Recall our hypothesis that downsampling should not cost much in sample quality, while considerably making the model faster. Surprisingly, in addition to being faster, models that use downsampling strategies also obtain better sample quality. It seems that downsampling for such a high resolution enables the network to optimize better for sample quality. Most importantly, it allows training without absurdly large feature maps without performance degradation.
305
+
306
+ Multiscale Loss For this final experiment, we test the difference between the standard loss and the multiscale loss, which adds more emphasis on lower frequencies in the image. For the resolutions 256 and 512 we report the sample quality in FID score for a model trained with the multiscale
307
+
308
+ Table 8: Text to image result on zero-shot COCO
309
+
310
+ <table><tr><td>Method</td><td>FID@30K 256</td></tr><tr><td>GLIDE (Nichol et al., 2022)</td><td>12.24</td></tr><tr><td>Dalle-2 (Ramesh et al., 2022)</td><td>10.39</td></tr><tr><td>Imagen (Saharia et al., 2022)</td><td>7.27</td></tr><tr><td>Muse (Chang et al., 2023)</td><td>7.88</td></tr><tr><td>Parti (Yu et al., 2022)</td><td>7.23</td></tr><tr><td>eDiff-I (Balaji et al., 2022)</td><td>6.95</td></tr><tr><td>simple diffusion (U-ViT 2B) (ours)</td><td>8.30</td></tr></table>
311
+
312
+ loss enabled or disabled. As can be seen in Figure 6, for 256 the loss does not seem to have much effect and performs slightly worse. However, for the larger 512 resolution the loss has an impact and reduces FID score.
313
+
314
+ # 5.2. Comparison with literature
315
+
316
+ In this section, simple diffusion is compared to existing approaches in literature. Although very useful for generating beautiful images, we specifically choose to only compare to methods without guidance (or other sampling modifications such as rejection sampling) to see how well the model is fitted. These sampling modifications may produce inflated scores on visual quality metrics (Ho & Salimans, 2022).
317
+
318
+ Interestingly, the larger U-ViT models perform very well on train FID and Inception Score (IS), outperforming all existing methods in literature (Table 7). However, the U-Net models perform better on eval FID. We believe this to be an extrapolation of the effect we observed before in Table 4, where increasing the architecture size did not necessarily result in better eval FID. For samples from the models see Figures 2 & 10. In summary, simple diffusion achieves SOTA FID scores on class-conditional ImageNet generation among all other types of approaches without sampling modifications. We think this is an incredibly promising result: by adjusting the diffusion schedule and modifying the loss, simple diffusion is a single stage model that operates on resolutions as large as $512 \times 512$ with high performance. See Appendix C for additional results.
319
+
320
+ Text to image In this experiment we train a text-to-image model following (Saharia et al., 2022). In addition to the self-attention and mlp block, this network also has cross-attention in the transformer that operates on T5 XXL text embeddings. For these experiments we also replaced convolutional layers with self-attention at the 32 resolution feature maps to improve detail generation. As can be seen in Table 8, simple diffusion is a little better than some recent text-to-image models such as DALLE-2, although it still lacks behind Imagen. For the resolution $512 \times 512$ , the FID@30K score is 9.57. Importantly, our model is the first model that can generate images of this quality using only a single diffusion model that is trained end-to-end.
321
+
322
+ # 6. Conclusion
323
+
324
+ In summary, we have introduced several simple modifications of the original denoising diffusion formulation that work well for high resolution images. Without sampling modifiers, simple diffusion achieves state-of-the-art performance on ImageNet in FID score and can be easily trained in an end-to-end setup. Furthermore, to the best of our knowledge this is the first single-stage text to image model that can generate images with such high visual quality.
325
+
326
+ # References
327
+
328
+ Anonymous. Discrete predictor-corrector diffusion models for image synthesis. In Submitted to The Eleventh International Conference on Learning Representations, 2023. URL https://openreview.net/forum?id=VM8batVBWvg. under review.
329
+ Balaji, Y., Nah, S., Huang, X., Vahdat, A., Song, J., Kreis, K., Aittala, M., Aila, T., Laine, S., Catanzaro, B., Karras, T., and Liu, M. ediff-i: Text-to-image diffusion models with an ensemble of expert denoisers. CoRR, abs/2211.01324, 2022.
330
+ Chang, H., Zhang, H., Jiang, L., Liu, C., and Freeman, W. T. Maskgit: Masked generative image transformer. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, CVPR 2022, New Orleans, LA, USA, June 18-24, 2022, pp. 11305-11315. IEEE, 2022.
331
+ Chang, H., Zhang, H., Barber, J., Maschinot, A., Lezama, J., Jiang, L., Yang, M., Murphy, K., Freeman, W. T., Rubinstein, M., Li, Y., and Krishnan, D. Muse: Text-to-image generation via masked generative transformers. CoRR, abs/2301.00704, 2023.
332
+ Chen, N., Zhang, Y., Zen, H., Weiss, R. J., Norouzi, M., and Chan, W. WaveGrad: Estimating gradients for waveform generation. arXiv preprint arXiv:2009.00713, 2020.
333
+ Chen, T. On the importance of noise scheduling for diffusion models. *arxiv*, 2023.
334
+ Dhariwal, P. and Nichol, A. Diffusion models beat gans on image synthesis. CoRR, abs/2105.05233, 2021.
335
+ Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., Unterthiner, T., Dehghani, M., Minderer, M., Heigold, G., Gelly, S., Uszkoreit, J., and Houlsby, N. An image is worth 16x16 words: Transformers for image recognition at scale. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net, 2021.
336
+ Feng, Z., Zhang, Z., Yu, X., Fang, Y., Li, L., Chen, X., Lu, Y., Liu, J., Yin, W., Feng, S., Sun, Y., Tian, H., Wu, H., and Wang, H. Ernie-vilg 2.0: Improving text-to-image diffusion model with knowledge-enhanced mixture-of-denoising-experts. CoRR, abs/2210.15257, 2022.
337
+ Gu, J., Zhai, S., Zhang, Y., Bautista, M. Á., and Susskind, J. M. f-dm: A multi-stage diffusion model via progressive signal transformation. CoRR, abs/2210.04955, 2022.
338
+ Ho, J. and Salimans, T. Classifier-free diffusion guidance. CoRR, abs/2207.12598, 2022. doi: 10.48550/arXiv.2207.12598. URL https://doi.org/10.48550/arXiv.2207.12598.
339
+
340
+ Ho, J., Jain, A., and Abbeel, P. Denoising diffusion probabilistic models. In Larochelle, H., Ranzato, M., Hadsell, R., Balcan, M., and Lin, H. (eds.), Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS, 2020.
341
+ Ho, J., Sahara, C., Chan, W., Fleet, D. J., Norouzi, M., and Salimans, T. Cascaded diffusion models for high fidelity image generation. J. Mach. Learn. Res., 23:47:1-47:33, 2022.
342
+ Jabri, A., Fleet, D. J., and Chen, T. Scalable adaptive computation for iterative generation. CoRR, abs/2212.11972, 2022.
343
+ Kingma, D. P., Salimans, T., Poole, B., and Ho, J. Variational diffusion models. CoRR, abs/2107.00630, 2021.
344
+ Kong, Z., Ping, W., Huang, J., Zhao, K., and Catanzaro, B. DiffWave: A versatile diffusion model for audio synthesis. In 9th International Conference on Learning Representations, ICLR, 2021.
345
+ Meng, C., Gao, R., Kingma, D. P., Ermon, S., Ho, J., and Salimans, T. On distillation of guided diffusion models. CoRR, abs/2210.03142, 2022.
346
+ Nichol, A. Q. and Dhariwal, P. Improved denoising diffusion probabilistic models. In Meila, M. and Zhang, T. (eds.), Proceedings of the 38th International Conference on Machine Learning, ICML, 2021.
347
+ Nichol, A. Q., Dhariwal, P., Ramesh, A., Shyam, P., Mishkin, P., McGrew, B., Sutskever, I., and Chen, M. GLIDE: towards photorealistic image generation and editing with text-guided diffusion models. In Chaudhuri, K., Jegelka, S., Song, L., Szepesvári, C., Niu, G., and Sabato, S. (eds.), International Conference on Machine Learning, ICML 2022, 17-23 July 2022, Baltimore, Maryland, USA, volume 162 of Proceedings of Machine Learning Research, pp. 16784-16804. PMLR, 2022. URL https://proceedings.mlr.press/v162/nichol22a.html.
348
+ Peebles, W. and Xie, S. Scalable diffusion models with transformers. CoRR, abs/2212.09748, 2022.
349
+ Raffel, C., Shazeer, N., Roberts, A., Lee, K., Narang, S., Matena, M., Zhou, Y., Li, W., and Liu, P. J. Exploring the limits of transfer learning with a unified text-to-text transformer. J. Mach. Learn. Res., 21:140:1-140:67, 2020.
350
+ Ramesh, A., Dhariwal, P., Nichol, A., Chu, C., and Chen, M. Hierarchical text-conditional image generation with CLIP latents. CoRR, abs/2204.06125, 2022.
351
+ Rombach, R., Blattmann, A., Lorenz, D., Esser, P., and Ommer, B. High-resolution image synthesis with latent
352
+
353
+ diffusion models. In IEEE/CVF Conference on Computer Vision and Pattern Recognition, CVPR 2022, New Orleans, LA, USA, June 18-24, 2022, pp. 10674-10685. IEEE, 2022.
354
+ Saharia, C., Chan, W., Saxena, S., Li, L., Whang, J., Denton, E., Ghasemipour, S. K. S., Ayan, B. K., Mahdavi, S. S., Lopes, R. G., Salimans, T., Ho, J., Fleet, D. J., and Norouzi, M. Photorealistic text-to-image diffusion models with deep language understanding. CoRR, abs/2205.11487, 2022.
355
+ Salimans, T. and Ho, J. Progressive distillation for fast sampling of diffusion models. In The Tenth International Conference on Learning Representations, ICLR. OpenReview.net, 2022.
356
+ Sauer, A., Schwarz, K., and Geiger, A. Stylegan-xl: Scaling stylegan to large diverse datasets. In Nandigjav, M., Mitra, N. J., and Hertzmann, A. (eds.), SIGGRAPH '22: Special Interest Group on Computer Graphics and Interactive Techniques Conference, pp. 49:1-49:10. ACM, 2022.
357
+ Singer, U., Polyak, A., Hayes, T., Yin, X., An, J., Zhang, S., Hu, Q., Yang, H., Ashual, O., Gafni, O., Parikh, D., Gupta, S., and Taigman, Y. Make-a-video: Text-to-video generation without text-video data. CoRR, abs/2209.14792, 2022.
358
+ Sohl-Dickstein, J., Weiss, E. A., Maheswaranathan, N., and Ganguli, S. Deep unsupervised learning using nonequilibrium thermodynamics. In Bach, F. R. and Blei, D. M. (eds.), Proceedings of the 32nd International Conference on Machine Learning, ICML, 2015.
359
+ Song, Y. and Ermon, S. Generative modeling by estimating gradients of the data distribution. In Advances in Neural Information Processing Systems 32: Annual Conference on Neural Information Processing Systems 2019, NeurIPS, 2019.
360
+ Song, Y., Sohl-Dickstein, J., Kingma, D. P., Kumar, A., Ermon, S., and Poole, B. Score-based generative modeling through stochastic differential equations. In 9th International Conference on Learning Representations, ICLR 2021, Virtual Event, Austria, May 3-7, 2021. OpenReview.net, 2021.
361
+ Yu, J., Xu, Y., Koh, J. Y., Luong, T., Baid, G., Wang, Z., Vasudevan, V., Ku, A., Yang, Y., Ayan, B. K., Hutchinson, B., Han, W., Parekh, Z., Li, X., Zhang, H., Baldridge, J., and Wu, Y. Scaling autoregressive models for content-rich text-to-image generation. CoRR, abs/2206.10789, 2022.
362
+
363
+ # A. Additional Background Information on Diffusion Models
364
+
365
+ This section is a more detailed summary of relevant background information on denoising diffusion. For one, it can be helpful to understand how modern denoising diffusion models (Ho et al., 2020) are trained using the formulations from (Kingma et al., 2021) First we define how signal is destroyed (diffused), which is the algorithmic equivalent to sampling $z_{t} \sim q(z_{t}|\boldsymbol{x})$ :
366
+
367
+ ```python
368
+ def diffuse(x, alpha_t, sigma_t):
369
+ eps_t = noise_normal_like(x)
370
+ z_t = alpha_t * x + sigma_t * eps_t
371
+ return z_t, eps_t
372
+ ```
373
+
374
+ For the specific optimization setting we generally use (v-prediction, epsilon loss) the loss can be computed as defined below. This is the algorithmic equivalent of $\mathbb{E}_{t\sim \mathcal{U}(0,1),z_t\sim q(z_t|x)}||f(\pmb {z}_t,t) - \epsilon_t||^2$ as proposed by (Ho et al., 2020; Kingma et al., 2021):
375
+
376
+ ```python
377
+ def loss(x):
378
+ t = noise.uniform(size=x.shape[0]) # Sample a batch of timesteps.
379
+ logsnr_t = logsnr_schedule(t)
380
+ alpha_t = sqrt(sigmoid(logsnr))
381
+ sigma_t = sqrt(sigmoid(-logsnr))
382
+ z_t, eps_t = diffuse(x, alpha_t, sigma_t)
383
+ v_pred = uvit(z_t, logsnr_t)
384
+ eps_pred = sigma_t * z_t + alpha_t * v_t
385
+ return mse(eps_pred, eps_t)
386
+ ```
387
+
388
+ In case of conditioning (for example ImageNet class number of a text embedding), these are added as an input to the uvit call, but do not influence the diffusion process in other ways. The conditioning is dropped out $10\%$ of the time, so that the models can additionally be used with classifier-free guidance.
389
+
390
+ The standard cosine logsnr schedule (taking care of boundaries) can be defined as:
391
+
392
+ ```python
393
+ def logsnr_schedule_cosine(t, logsnr_min=-15, logsnr_max=+15):
394
+ t_min = atan(exp(-0.5 * logsnr_max))
395
+ t_max = atan(exp(-0.5 * logsnr_min))
396
+ return -2 * log(tan(t_min + t * (t_max - t_min)))
397
+ ```
398
+
399
+ One can then define the shifted schedule as:
400
+
401
+ ```python
402
+ def logsnr_schedule_cosine_shifted(t, image_d, noise_d):
403
+ return logsnr_schedule_cosine(t) + 2 log(noise_d / image_d)
404
+ ```
405
+
406
+ And the interpolated schedule as:
407
+
408
+ ```python
409
+ def logsnr_schedule_cosine_shifted(t, image_d, noise_d_low, noise_d_high):
410
+ logsnr_low = logsnr_schedule_cosine_shifted(t, image_d, noise_d_low)
411
+ logsnr_high = logsnr_schedule(cosine_shifted(t, image_d, noise_d_high))
412
+ return t * logsnr_low + (1 - t) * logsnr_high
413
+ ```
414
+
415
+ Care needs to be taken that the minimum and maximum logsnr hyperparameters are shifted along with the entire schedule, so care needs to be taken when these endpoints are used to define the embedding in the architecture.
416
+
417
+ Sampling In this work we use the standard ddpm sampler unless noted otherwise. Below is the algorithmic equivalent of the generative process of sampling $\mathbf{z}_T \sim \mathcal{N}(0, \mathbf{I})$ and then repeatedly sampling $\mathbf{z}_s \sim p(\mathbf{z}_s | \mathbf{z}_t)$ :
418
+
419
+ ```python
420
+ def sample(x_shape):
421
+ # lowestidx can be 0 or 1.
422
+ z_t = noise_normal(x_shape)
423
+ for t in reversed(range(lowestidx+1, num_steps+1)):
424
+ u_t = t / num_steps
425
+ u_s = (t - 1) / num_steps
426
+ logsnr_t = logsnr_schedule(u_t)
427
+ logsnr_s = logsnr_schedule(u_s)
428
+ ```
429
+
430
+ ```python
431
+ v_pred = uvit(z_t, logsnr_t)
432
+ z_t = sampler_step(z_t, v_pred, logsnr_t, logsnr_s)
433
+ # Final prediction, do not sample x ~ p(x | z Lowest) but take the mean prediction:
434
+ logsnr_lowest = logsnr_schedule(lowestidx / num_steps)
435
+ v_pred = uvit(z_t, logsnr_lowest)
436
+ x_pred = alpha_t * z_t - sigma_t * v_pred
437
+ x_pred = clip_x(x_pred)
438
+ return x_pred
439
+ def ddpmSampler_step(z_t, v_pred, logsnr_t, logsnr_s):
440
+ x_pred = alpha_t * z_t - sigma_t * v_pred
441
+ x_pred = clip_x(x_pred)
442
+ mu = exp(logsnr_t - logsnr_s) * alpha_st * z_t + (1 - exp(logsnr_t - logsnr_s)) * alpha_s * x
443
+ # Variance can be any interpolation of the following two in log-space:
444
+ min_lvar = (1 - exp(logsnr_t - logsnr_s)) + log_sigmoid(-logsnr_s)
445
+ max_lvar = (1 - exp(logsnr_t - logsnr_s)) + log_sigmoid(-logsnr_t)
446
+ noise_param = 0.2
447
+ sigma = sqrt(exp(noise-param * max_logvar + (1 - noise-param) * min_logvar))
448
+ return mu + sigma * normal_noise_like(z_t)
449
+ ```
450
+
451
+ where noise param is set to 0.2 with the exception of MSCOCO FID evaluation, where it is set to 1.0.
452
+
453
+ An important but not often discussed detail is that during sampling it is helpful to clip the predictions in x-space, below gives an example for static clipping, for dynamic clipping see (Saharia et al., 2022):
454
+
455
+ ```python
456
+ def clip_x(x):
457
+ # x should be between -1 and 1.
458
+ return clip(x, -1, 1)
459
+ ```
460
+
461
+ Classifier-free guidance In classifier-free guidance (Ho & Salimans, 2022), one drops out the conditioning signal occasionally during training (Usually about $10\%$ of the time). This allows one to train models, $p(\boldsymbol{x})$ in addition to the model one normally trains which is $p(\boldsymbol{x}|\mathrm{cond})$ . The epsilon predictions of these models can then be recombined with a guidance scale. For $\eta > 0$ :
462
+
463
+ $$
464
+ \hat {\boldsymbol {\epsilon}} (\boldsymbol {x}) = (1 + \eta) \hat {\boldsymbol {\epsilon}} (\boldsymbol {x}, \operatorname {c o n d}) - \eta \hat {\boldsymbol {\epsilon}} (\boldsymbol {x}). \tag {7}
465
+ $$
466
+
467
+ One can substitute $\hat{\epsilon}$ by $\hat{v}$ or $\hat{x}$ and the result ends up being equivalent due to linearity and terms cancelling out. Note we will report the guidance scale as $(1 + \eta)$ as is done often in literature, not to be confused by reporting $\eta$ itself.
468
+
469
+ Distillation Like many diffusion models, simple diffusion can also be distilled to reduce the number of sampling steps and neural net evaluations (Meng et al., 2022) to reduce the number of sampling steps. For a distilled U-ViT model, generating a single image takes 0.42 seconds on a TPUv4. Similarly, generating a batch of 8 images takes 2.00 seconds.
470
+
471
+ # B. Experimental details
472
+
473
+ In this section, specific details on the experiments are given. Firstly, the standard optimizer settings for the U-Net experiments.
474
+
475
+ # B.1. U-Net settings
476
+
477
+ ```python
478
+ unet default optimization settings:
479
+ batch_size=512,
480
+ optimizer='adam',
481
+ adam_beta1=0.9,
482
+ adam_beta2=0.99, except for ImageNet 128 which is adam_beta2=0.999
483
+ adam_epochs=1.e-12,
484
+ learning_rate=5e-5,
485
+ learning_rate_warmup_steps=10_000,
486
+ weight Decay=0.0,
487
+ ema_Decay=0.9999,
488
+ grad.clip=1.0,
489
+ ```
490
+
491
+ ```python
492
+ Specific settings for the UNet on ImageNet 128 experiment:
493
+ base_channels=128,
494
+ emb_channels=1024, (for diffusion time, image class)
495
+ channelmultiplier=[1, 2, 4, 8, 8],
496
+ num_res_blocks=[3, 4, 4, 12, 4], (unless noted otherwise)
497
+ attn_resolution=[8, 16],
498
+ num_heads=4,
499
+ dropout_from_resolution=16, (unless noted otherwise)
500
+ dropout=0.1,
501
+ patching_type='none'
502
+ schedule={'name':'cosine_shifted,'shift':64} (unless noted otherwise)
503
+ num_train_steps=1_500_000
504
+ ```
505
+
506
+ ```python
507
+ Specific settings for the UNet on ImageNet 256 experiment:
508
+ base_channels=128,
509
+ emb_channels=1024, (for diffusion time, image class)
510
+ channelmultiplier=[1, 1, 2, 4, 8, 8],
511
+ num_res_blocks=[1, 2, 2, 4, 12, 4],
512
+ attn_resolution=[8, 16],
513
+ num_heads=4,
514
+ dropout_from_resolution=16,
515
+ dropout=0.1,
516
+ patching_type='none'
517
+ schedule={'name':'cosine_shifted,'shift':64} (unless noted otherwise)
518
+ num_train_steps=2_000_000
519
+ ```
520
+
521
+ ```python
522
+ Setting for the UNet on ImageNet 512 experiment:
523
+ base_channels=128,
524
+ emb_channels=1024,
525
+ attn_resolutions=[8, 16],
526
+ num_heads=4,
527
+ dropout_from_resolution=16,
528
+ dropout=0.1,
529
+ patching_type='dwt_2'
530
+ schedule={'name':'cosine_shifed,'shift':64} (unless noted otherwise)
531
+ num_train_steps=2_000_000
532
+ ```
533
+
534
+ To keep the number of residual blocks the same, high resolution blocks that are skipped by down-sampling are added to the lower resolution levels. With no downsampling, the architecture uses:
535
+
536
+ channelmultiplier $=$ [1,1,1,2,4,8,8],num_res_blocks $= [1$ ,1,2,2,4,12,4],
537
+
538
+ In case of $2\times$ downsampling the architecture uses:
539
+
540
+ channelmultiplier $=$ [1,2,2,4,8,8],num_res_blocks $= [2$ ,2,2,4,12,4],
541
+
542
+ In case of $4\times$ downsampling the architecture uses:
543
+
544
+ channelmultiplier $=$ [2,3,4,8,8],num_res_blocks $= [3$ ,3,4,12,4],
545
+
546
+ # B.2. U-ViT settings
547
+
548
+ The U-ViT is a very similar architecture to the U-Net (see Figure 7). The two major differences are that 1) When a module has self-attention, it uses an MLP block instead of a convolutional layer, making their combination a transformer block. And 2) the transformer blocks in the middle do not use skip connections, only residual connections. The default optimization settings for ImageNet for the U-ViT are:
549
+
550
+ ```python
551
+ uvit default optimization settings: optimizer='adam', adam_beta1=0.9, adam_beta2=0.99, adam eps=1.e-12, learning_rate=1e-4, learning_rate_warmup_steps=10_000,
552
+ ```
553
+
554
+ ![](images/6c3a835481ee50f0f3d0284ba88b2710b4b08160c2af9642aef721561baad072.jpg)
555
+
556
+ ![](images/a11e8c9c2748d1e47b8a041f646538f74318f05fa64e73b82091c2b22310a328.jpg)
557
+ Figure 7: The difference between the U-Net and U-ViT architecture. In essence, the convolutional layers are replaced by MLP blocks on levels with self-attention. These now form transformer blocks which are connected via residual connections, only the ResBlocks on higher levels use skip connections. Circular arrows denote that such a block can be repeated multiple times.
558
+
559
+ ```txt
560
+ weight Decay $= 0.0$
561
+ ema decay $= 0.9999$
562
+ grad clip $= 1.0$
563
+ batch size $= 2048$
564
+ num_train_steps $= 500_{-}000$
565
+ ```
566
+
567
+ And the architecture settings are almost the same for all resolutions 128, 256 and 512.
568
+
569
+ ```txt
570
+ uvit default architecture settings for optimizer='adam',adam_beta1=0.9,adam_beta2=0.99,adam血脂 $= 1$ e-12,learning_rate $\equiv$ 1e-4,learning_rate_warmup_steps $\equiv$ 10_000,weight Decay $\equiv$ 0.0,ema Decay $\equiv$ 0.9999,gradclip $\equiv$ 1.0,batch_size $\equiv$ 2048,base_channels $\equiv$ 128,emb_channels $\equiv$ 1024,channelmultiplier $\equiv$ [1,2,4,16],num_res_blocks=[2,2,2],num_transformer_blocks $= 36$ num_heads $= 4$ ,transformer_dropout $= 0.2$ logsnr_input_type $\equiv$ 'linear'
571
+ ```
572
+
573
+ ```javascript
574
+ patching_type='dwt_5/3_2', mean_type='v', mean_loss_type='v_mse',
575
+ ```
576
+
577
+ where the patching type is either 'none' for 128, 'dwt_1' for 256 and 'dwt_2' for 512. Note also that the loss is computed on v instead of epsilon. This may not be very important: in small experiments we observed only minor performance differences between the two. Note also that the batch size is larger (2048) which does affect FID and IS performance considerably. The text to image model was trained for 700K steps.
578
+
579
+ # B.2.1. PSEUDO-CODE FOR U-VIT MODULES
580
+
581
+ The Transformer blocks consist of a self-attention and mlp block. These are defined as one would expect, for completeness given below in pseudo-code:
582
+
583
+ ```python
584
+ def mlp_block(x, emb, expansion_factor=4):
585
+ B, HW, C = x.shape
586
+ x =Normalize(x)
587
+ mlp_h = Dense(x,expansion_factor * C)
588
+ scale = DenseGeneral(emb,mlp_h.shape[2:])
589
+ shift = DenseGeneral(emb,mlp_h.shape[2:])
590
+ mlp_h = swish(mlp_h)
591
+ mlp_h = mlp_h * (1. + scale[:, None]) + shift[:, None]
592
+ if config.transformer_dropout > 0:
593
+ mlp_h = Dropout(mlp_h, config.transformer_dropout)
594
+ out = Dense(mlp_h, C, kernel_init=zeros)
595
+ return out
596
+ def selfattention(x,text_emb):
597
+ B,HW,C = x.shape
598
+ B,T,TC = text_emb.shape
599
+ head_dim = C // config.num_heads
600
+ x_norm =Normalize(x)
601
+ q = DenseGeneral(x_norm,(num_heads,head_dim))
602
+ k = DenseGeneral(x_norm,(num_heads,head_dim))
603
+ v = DenseGeneral(x_norm,(num_heads,head_dim))
604
+ q =NormalizeWithBias(q)
605
+ k =NormalizeWithBias(k)
606
+ q = q * q.shape[-1] ** -0.5
607
+ weights = einsum("bqhd,bkhd->bhqk",q,k)
608
+ weights = softmax(weights)
609
+ attn_vals = einsum("bhqk,bkhd->bqhdr",weights,v)
610
+ out = DenseGeneral.attn_vals, C, axis=(-2,-1), kernel_init=zeros)
611
+ return out
612
+ def transformer_block(x,text_emb,emb):
613
+ x += mlp_block(x,emb)
614
+ x += selfattention(x,text_emb)
615
+ return x
616
+ ```
617
+
618
+ Another important block is the standard ResBlock, pseudo-code given below:
619
+
620
+ ```python
621
+ def resnet_block(x,emb,skip_h=None): B,H,W,C=x.shape h $=$ NormalizeWithBias(x) if skip_h is not None: skip_h $\equiv$ NormalizeWithBias skip_h) h $\equiv$ (h $^+$ skip_h)/sqrt(2) h $=$ swish(h)
622
+ ```
623
+
624
+ ```latex
625
+ $\begin{array}{rl} & \mathrm{h} = \mathrm{Conv2D(h,}\mathrm{out\_ch},\mathrm{(3,3),}\mathrm{(1,1)}\mathrm{)}\\ & \mathrm{emb\_out} = \mathrm{Dense(emb,2*out\_ch)[:,None,}\mathrm{None,}:]\end{array}$
626
+ scale,shift $=$ split(emb_out,2,axis=-1)
627
+ $\begin{array}{rl}{\mathbf{h}}&{=}\end{array}$ NormalizeWithBias(h)\*(1+scale)+shift
628
+ $\mathbf{h} =$ swish(h)
629
+ $\mathbf{h} =$ Conv2D(h,out_ch,(3,3),(1,1),kernel_init=zeros)
630
+ return $\mathbf{x} + \mathbf{h}$
631
+ ```
632
+
633
+ Given these building blocks, one can define the U-ViT architecture:
634
+
635
+ ```python
636
+ def uvit(x, logsnr):
637
+ B, H, W, C = x.shape
638
+ emb = get_logsnr_emb(logsnr)
639
+ h0 = EmbedInput(config.base_channels * config.channel-multiplier[0])(x)
640
+ hs = []
641
+ last_h = h0
642
+ # Down path.
643
+ for i_level in range(len(config.num_res_blocks)):
644
+ for i_block in range(config.num_res_blocks[i_level]):
645
+ last_h = resnet_block(last_h, emb)
646
+ hs.append(last_h)
647
+ last_h = downsample(
648
+ last_h, config.base_channels * config.channel-multiplier[i_level+1])
649
+ # The transformer.
650
+ last_h = last_h.reshape(B, H * W, C)
651
+ last_h += param("pos_emb", initializers.normal(0.01), last_h.shape[1:])[None]
652
+ for _ in range(config.num_transformer_blocks):
653
+ last_h = transformer_block(last_h, text_emb, emb)
654
+ last_h = last_hreshape(B, H, W, C)
655
+ # Up path.
656
+ for i_level in reversed(range(len(config(num_res_blocks)))):
657
+ last_h = upsample(last_h, config.base_channels * config.channel-multiplier[i_level])
658
+ for i_block in range(config.num_res_blocks[i_level]):
659
+ last_h = reshape(last_h, emb, skip_h=hs.pop())
660
+ out = ProjectOutput(last_h, C)
661
+ return out
662
+ ```
663
+
664
+ As one can see, it's very similar to the UNet, the middle part is now a transformer which does not have convolutional layers but mlp blocks with only residual connections.
665
+
666
+ Computational resources The smaller U-Net models can be trained on 64 TPUv2 devices with 1.15 steps per second (for a resolution of 256 without patching, small differences between different model variants) with a batch size of 512 for 2000K steps (unless specified otherwise). The large U-ViT models are all trained using 128 TPUv4 devices with 1.5 steps per second with a batch size of 2048 for 500K steps.
667
+
668
+ # C. Additional Experiments
669
+
670
+ Guidance scale In Table 9 we show the effect of guidance on the ImageNet models. For relatively small levels of guidance, samples immediately gain a lot in IS at the cost of especially eval FID. Furthermore, Figure 8 shows the Clip versus MSCOCO FID30K score for the text to image model. Following others such as (Saharia et al., 2022), images are sampled by conditioning on 30K randomly sampled texts from the MSCOCO validation set, computed against the full validation set as a reference.
671
+
672
+ Table 9: Guidance scale, the shifted schedule is quite sensitive to guidance.
673
+
674
+ <table><tr><td>U-ViT</td><td colspan="3">ImageNet 128</td><td colspan="3">ImageNet 256</td><td colspan="3">ImageNet 512</td></tr><tr><td>guidance</td><td>FID train</td><td>FID eval</td><td>IS</td><td>FID train</td><td>FID eval</td><td>IS</td><td>FID train</td><td>FID eval</td><td>IS</td></tr><tr><td>1.00</td><td>1.94</td><td>3.23</td><td>171.9 ± 3.2</td><td>2.77</td><td>3.75</td><td>211.8 ± 2.9</td><td>3.54</td><td>4.53</td><td>205.3± 2.7</td></tr><tr><td>1.05</td><td>2.05</td><td>3.57</td><td>189.9± 3.5</td><td>2.46</td><td>3.80</td><td>235.3 ± 4.9</td><td>3.14</td><td>4.43</td><td>228.5± 4.2</td></tr><tr><td>1.10</td><td>2.35</td><td>4.10</td><td>207.0± 3.5</td><td>2.44</td><td>4.08</td><td>256.3 ± 5.0</td><td>3.02</td><td>4.60</td><td>248.7± 3.4</td></tr><tr><td>1.20</td><td>3.24</td><td>5.36</td><td>237.6± 3.6</td><td>2.96</td><td>5.10</td><td>289.8 ± 4.1</td><td>3.33</td><td>5.43</td><td>284.6± 2.8</td></tr><tr><td>1.40</td><td>5.58</td><td>8.26</td><td>285.2± 2.0</td><td>4.69</td><td>7.50</td><td>342.2 ± 5.1</td><td>4.97</td><td>7.89</td><td>339.9± 3.8</td></tr><tr><td>1.80</td><td>9.77</td><td>13.06</td><td>340.1± 3.6</td><td>8.21</td><td>11.81</td><td>398.0 ± 5.4</td><td>8.38</td><td>12.15</td><td>401.7± 5.2</td></tr><tr><td>2.00</td><td>11.47</td><td>14.96</td><td>359.2± 5.6</td><td>9.59</td><td>13.44</td><td>416.4 ± 4.7</td><td>9.68</td><td>13.68</td><td>416.2± 4.8</td></tr><tr><td>3.00</td><td>15.85</td><td>19.75</td><td>399.2± 2.9</td><td>13.61</td><td>18.00</td><td>455.7 ± 4.2</td><td>13.79</td><td>18.42</td><td>461.4± 5.0</td></tr></table>
675
+
676
+ ![](images/bf1d407e596fe3bae237b25f1828598746cd8d67f2cb2913e165321bc8355777.jpg)
677
+ Figure 8: Clip vs FID30K score on zero-shot MSCOCO at resolution $256 \times 256$ . For guidance scales 1.00, 1.25, 1.40, 1.50, 2.0, 3.0, 4.0.
678
+
679
+ Experiments on 1024 To study the effects of scaling beyond 512, we run a similar experiment with U-Nets on ImageNet resized to 1024 by 1024, even though most images are smaller than that resolution. Here, the multiscale loss has an even more pronounced effect, resulting in a train FID that is considerably improved by using the downsample loss (6.06 versus 8.10 without). Moreover, this model is more expensive because 4 by 4 patching gives 256 resolution feature maps.
680
+
681
+ ![](images/8df7c28f4a47e0c616989e03b0a8b17ddaabd82334a447ec29a28df3da3c381b.jpg)
682
+ (a) A render of a bright and colorful city under a dome
683
+
684
+ ![](images/ca4f22ef70b9ab68bc2148b4bc3a82c815c2cdf2ba608ec16aca97e0c8ab97e5.jpg)
685
+ (b) A raccoon playing the saxophone
686
+
687
+ ![](images/b359a35a9be9f1a10f53e55573273c5de99186f9525e2a04e3327b8840e09abd.jpg)
688
+
689
+ ![](images/484aa6db6ec6fc3be3a53350288dae441c59984f247540e3de3a998c3b494348.jpg)
690
+ (d) A cartoon of a strawberry drinking a smoothie
691
+
692
+ ![](images/e7546c14b2d04b8cca8292ec435efad38b3f45af3a7e6cd9f606745f251ca9b9.jpg)
693
+ (c) A panda walking through the Jungle, futuristic art
694
+
695
+ ![](images/b14cfca2fb4c5b7e614f9518b2965140c85661c7f56eb99792d49a50b057b863.jpg)
696
+ (f) A statue of a frog made of wood
697
+
698
+ ![](images/a0301627ed90b5f784bfa7e5a0ec2c38dea0a3046b789c97ae9c49f49fa59712.jpg)
699
+ (e) A surrealistic painting of a robot riding a skateboard
700
+ (g) A sunflower wearing sunglasses
701
+ Figure 9: Text to image samples at resolution $512 \times 512$ . This model was distilled and as a result generating a single image takes 0.42 seconds on a TPUv4 (excluding the text encoder). Similarly, generating a batch of 8 images takes 2.00 seconds.
702
+
703
+ ![](images/525281ca184d4df123ce60d6dce953c6e8dbef1c919d80fe336c389d20c85287.jpg)
704
+ (h) A neon sign of a butterfly
705
+ (i) A painting of futuristic coffee machine, vivid colors
706
+
707
+ ![](images/8088bef74b58cd957df7dd4bdc9242c4059f44f4512b2c00909c0709a684ce4f.jpg)
708
+
709
+ ![](images/46f4f54b8f65adf1368def355261462464391bc3cd007676a161add2500eace9.jpg)
710
+ (a) Guidance scale 4
711
+ (b) Guidance scale 1 (No guidance)
712
+ Figure 10: Random (not cherry picked) samples from the U-ViT on ImageNet $256 \times 256$ .
simplediffusionendtoenddiffusionforhighresolutionimages/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fef76b019b844286ba7728913dfaa5049789e34bf00ddb0962e09aef44e13489
3
+ size 1708618
simplediffusionendtoenddiffusionforhighresolutionimages/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f3aecaec78f2c4abbadda934646943442352b893caf40f5a83454bb61864148
3
+ size 692541
universalmorphologycontrolviacontextualmodulation/2ca5468c-be98-4ef1-8ace-382b5f02d6bc_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b69675cae75bd21dae9e27d558eae6a98d1f3c76597563178c27cdb250e02d60
3
+ size 98029
universalmorphologycontrolviacontextualmodulation/2ca5468c-be98-4ef1-8ace-382b5f02d6bc_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a63e43bfe86c5aaa3ba0eed19ffc217ca99c6d4011dc96de1531edf690b497d0
3
+ size 117028
universalmorphologycontrolviacontextualmodulation/2ca5468c-be98-4ef1-8ace-382b5f02d6bc_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4212872d399e62fbb49964dd4c9f12886c32e6b8fc3293b93aa4eca5dc7502c9
3
+ size 2922539
universalmorphologycontrolviacontextualmodulation/full.md ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Universal Morphology Control via Contextual Modulation
2
+
3
+ Zheng Xiong<sup>1</sup> Jacob Beck<sup>1</sup> Shimon Whiteson<sup>1</sup>
4
+
5
+ # Abstract
6
+
7
+ Learning a universal policy across different robot morphologies can significantly improve learning efficiency and generalization in continuous control. However, it poses a challenging multi-task reinforcement learning problem, as the optimal policy may be quite different across robots and critically depend on the morphology. Existing methods utilize graph neural networks or transformers to handle heterogeneous state and action spaces across different morphologies, but pay little attention to the dependency of a robot's control policy on its morphology context. In this paper, we propose a hierarchical architecture to better model this dependency via contextual modulation, which includes two key submodules: (1) Instead of enforcing hard parameter sharing across robots, we use hypernetworks to generate morphology-dependent control parameters; (2) We propose a fixed attention mechanism that solely depends on the morphology to modulate the interactions between different limbs in a robot. Experimental results show that our method not only improves learning performance on a diverse set of training robots, but also generalizes better to unseen morphologies in a zero-shot fashion. The code is publicly available at https://github.com/MasterXiong/ModuMorph.
8
+
9
+ # 1. Introduction
10
+
11
+ Reinforcement learning (RL) for robotic control has made great progress in recent years (Levine et al., 2016; Kalashnikov et al., 2018; Andrychowicz et al., 2020; Brohan et al., 2022). However, the control policy learned on one robot usually cannot transfer to another robot with a different morphology due to their incompatible state and action spaces. Given the huge number of possible robot morphologies and
12
+
13
+ $^{1}$ Department of Computer Science, University of Oxford, Oxford, United Kingdom. Correspondence to: Zheng Xiong <zheng.xiong@cs.ox.ac.uk>.
14
+
15
+ Proceedings of the $40^{th}$ International Conference on Machine Learning, Honolulu, Hawaii, USA. PMLR 202, 2023. Copyright 2023 by the author(s).
16
+
17
+ the high sample complexity of RL, the currently dominant paradigm of learning a new policy from scratch for each robot morphology is not scalable, and universal controllers that can generalize across different morphologies are desirable to improve learning efficiency, i.e., we want to learn a universal controller with much less environment interactions compared to the total samples required to learn a separate controller for each robot to control.
18
+
19
+ Multi-task RL (MTRL) (Vithayathil Varghese & Mahmoud, 2020) provides a promising solution to this challenge by treating the control of each robot as a unique task. Instead of learning a separate policy for each morphology, MTRL learns a single policy, conditioned on both the robot state and the morphology, to generalize across different robots. From this MTRL perspective, the robot morphology is important context that helps identify the task, as the optimal control policy of a robot critically depends on its morphology. For example, if an animal injures a leg, which changes its morphology, then a different gait may be required for locomotion. Similarly, an animal's tail can significantly influence its locomotion even if all the other body parts remain unchanged (Jagnandan & Higham, 2017).
20
+
21
+ However, previous work on universal morphology control mainly focuses on policy architecture design, such as using graph neural networks (GNNs) (Wang et al., 2018; Huang et al., 2020) or transformers (Kurin et al., 2021; Gupta et al., 2022), to enable generalization over heterogeneous state and action spaces, as the number of limbs differs across morphologies. By contrast, little attention has been paid to how to effectively utilize the morphology context in the control policy. While some recent works propose to feed morphology context as an additional input to the policy network (Gupta et al., 2022), or add a morphology-aware positional encoding (PE) to the state representation (Gupta et al., 2022; Hong et al., 2022), in effect they are equivalent to just adding a context-conditioned bias term to the node embedding layer in the network. This may lack sufficient model capacity to represent the diverse policies required to control different morphologies, as supported by both theoretical (Galanti & Wolf, 2020) and empirical evidence (Ben-Iwhiwhu et al., 2022; Beck et al., 2022) from previous work in multi-task learning and meta-learning.
22
+
23
+ To better utilize task context for morphology control, we
24
+
25
+ propose a hierarchical policy architecture consisting of a base controller, and a context modulator that regulates the control policy according to the characteristics of different morphologies. We name our method as ModuMorph to highlight its architecture novelty in contextual modulation. Specifically, ModuMorph includes two submodules. First, we modulate network parameters in the base controller with hypernetworks (HN) (Ha et al., 2016). Conditioned on the morphology context, HN can generate different policy parameters for different robots, which helps improve behavior diversity across morphologies. Second, we modulate the attention weight matrices in the transformer layers of the base controller with morphology context alone, which introduces a structure-aware inductive bias on how each limb in a robot should attend to the others to update its own behaviors.
26
+
27
+ In principle, the proposed contextual modulator can be incorporated into any transformer-based architectures for morphology control, while the HN module can also work with GNN-based architectures. In this paper, we use a recently proposed transformer-based method, MetaMorph (Gupta et al., 2022), as the backbone algorithm for experiments due to its superior performance and efficient implementation. Our experiments on a challenging morphology control benchmark called UNIMAL (Gupta et al., 2021), which includes hundreds of diverse morphologies, show that using contextual modulation improves not only the learning performance on training morphologies, but also the zero-shot generalization performance on unseen test morphologies, which validates the effectiveness of our method.
28
+
29
+ # 2. Background
30
+
31
+ # 2.1. Problem Formulation
32
+
33
+ Consider the problem of learning a universal policy to control a set of $K$ robots with different morphologies. For each robot $k$ , the control problem can be seen as a contextual Markov Decision Process (CMDP) (Hallak et al., 2015) defined as a tuple $(S_{k},\mathcal{A}_{k},\mathcal{C}_{k},T_{k},R_{k})$ , where $S_{k},\mathcal{A}_{k},\mathcal{C}_{k},T_{k},R_{k}$ are the state space, action space, task context, transition function and reward function respectively.
34
+
35
+ We assume that all the robots are drawn from a modular design space, i.e., each robot can be seen as a morphology tree over a set of basic nodes (limbs), and all the nodes share the same node-level state and action space. Based on this assumption, we have $\mathcal{S}_k = \{\mathcal{S}_k^i | i = 1, \dots, N_k\}$ and $\mathcal{A}_k = \{\mathcal{A}_k^i | i = 1, \dots, N_k\}$ , where $N_k$ is the number of nodes in robot $k$ . The task context includes morphology information about the robot, consisting of node-wise context $\{\mathcal{C}_k^i | i = 1, \dots, N_k\}$ (such as the size and mass of the limb and its initial position relative to its parent node), and an adjacency matrix that defines the topology of the morphology tree.
36
+
37
+ We use $s_{k,t}, a_{k,t}, r_{k,t}$ to represent the state, action and re
38
+
39
+ ![](images/4be3ab7801abd78c9a45fa4040651e29b8e2998fe98c8cb20f176a738a44ec1b.jpg)
40
+ Figure 1. The framework of MetaMorph (Gupta et al., 2022). On this two-leg robot for example, its nodes are ordered by depth-first tree search, with the torso node as the tree root. MetaMorph concatenates proprioceptive observations and morphology context as node inputs, processes them with a shared embedding layer, a transformer encoder and a shared decoder sequentially. Exteroceptive observations are concatenated as decoder inputs if needed.
41
+
42
+ ward at time step $t$ for robot $k$ . The training objective is to learn a universal policy $\pi_{\theta}(a_{k,t}|s_{k,t},c_k)$ to maximize the average return over all the training morphologies, i.e., $\max_{\theta}\left[\frac{1}{K}\sum_{k = 1}^{K}\sum_{t = 0}^{H}r_{k,t}\right]$ , where $H$ is the task horizon for all different robots. In addition to good training performance, we also expect the learned policy to generalize well on unseen test morphologies in a zero-shot manner.
43
+
44
+ # 2.2. Transformers for Universal Morphology Control
45
+
46
+ Transformers (Vaswani et al., 2017) can model the interactions between a set of elements of arbitrary size, thus are well suited to process different morphologies with various number of limbs.
47
+
48
+ For morphology control, the attention module in transformers determines how each node attends to the others to update its own node representation. It requires three input vectors from each node $i$ , i.e., a query $\pmb{q}_i$ , a key $\pmb{k}_i$ of dimension $d_k$ , and a value vector $\pmb{v}_i$ of dimension $d_v$ . The three vectors for each node are stacked into matrices $Q, K, V$ , and the attention module updates the node representation as
49
+
50
+ $$
51
+ \operatorname {A t t e n t i o n} (Q, K, V) = \operatorname {s o f t m a x} (\frac {Q K ^ {T}}{\sqrt {d _ {k}}}) V,
52
+ $$
53
+
54
+ i.e., the dot product of $\pmb{q}_i$ and $k_j$ determines how much attention node $i$ pays to node $j$ to update its node representation. Usually multiple attention heads are trained independently to learn different node interactions. The attention block is then followed by feedforward layers to form a whole transformer module, with normalization and skip connection operations in between. Several layers of transformer modules can be stacked to further improve model capacity.
55
+
56
+ # 2.2.1.METAMORPH
57
+
58
+ MetaMorph (Gupta et al., 2022) is a transformer-based method for universal morphology control (Figure 1). It concatenates the time-variant proprioceptive observation
59
+
60
+ $s_{k,t}^{i}$ and the time-invariant morphology context $c_k^i$ as the input vector of node $i$ . The node input first goes through an embedding layer shared across all nodes to get node embedding $\pmb{e}_i$ . Then the node embeddings are updated by a transformer encoder. The key, query and value inputs to the transformer are all determined by the node embedding, i.e., $\pmb{k}_i = W_k\pmb {e}_i$ , $\pmb{q}_i = W_q\pmb {e}_i$ , $\pmb{v}_i = W_v\pmb {e}_i$ , where $W_{k},W_{q},W_{v}$ are learnable weight matrices. After transformer encoding, if there are globally exteroceptive observations, such as a height map of the agent's surroundings in a changing terrain, then they are processed by a multi-layer perceptron (MLP) and concatenated to the node features. Incorporating exteroceptive observations is essential to enable the agent to take different actions in different environmental conditions. Finally, the concatenated features go through a decoder shared across all nodes to generate the actions for each node.
61
+
62
+ In MetaMorph, the morphology context $c_k$ is only utilized as an additional node input, which is equivalent to adding a context-conditioned bias to the node embedding, as $c_k$ remains unchanged on each robot. However, the optimal control policy can significantly vary across robots. Simply adding context-conditioned bias terms to the node embeddings, while sharing all the other model parameters, thus may not have sufficient expressive power to represent the diverse policies required for different morphologies (Galanti & Wolf, 2020; Ben-Iwhiwu et al., 2022; Beck et al., 2022). To tackle this limitation, we propose two contextual modulation approaches to learn more diverse context-conditioned policies across different morphologies in Section 3.
63
+
64
+ MetaMorph also adds a learned positional encoding (PE) to the node embedding, i.e., $e_i = \text{Encoder}(s_{k,t}^i, c_k^i) + \text{PE}_i$ , where $\text{PE}_i$ is a learnable vector that is shared across all the nodes with index $i$ across different morphologies. PE is a common way to inject positional information back into transformers, as the attention module alone is order-invariant (Vaswani et al., 2017; Dufter et al., 2022). However, we find that PE actually provides little help in universal morphology control and thus omit it in Figure 1 for simplicity. We analyze why it does not work in Appendix C.
65
+
66
+ # 2.3. Hypernetworks
67
+
68
+ A hypernetwork (Ha et al., 2016) is a network that generates the parameters of a base network $\theta$ conditioned on some meta variables $c$ , i.e., $\theta = \mathrm{HN}_{\phi}(c)$ , where $\phi$ is the HN parameters to learn. Under the MTRL setting, the meta variables correspond to the task context. With HN, $\theta$ turns into a context-dependent function that may better reflect the dependency between the task context and the base network's parameters. Compared to the common practice of integrating task context into the base network by concatenating it to the base network's input vector, modeling their relationships via HN enjoys better parameter complexity (Galanti & Wolf,
69
+
70
+ ![](images/81d2ea6416f4bfffe4b20ae232b48d6a2d5008a47a634f38f2fff6c44d200d50.jpg)
71
+ Figure 2. The hierarchical framework of our proposed method. The morphology context modulates the base controller in two ways: (1) Generating context-conditioned embedding and decoder parameters via an HN. We use dotted edges to highlight that these two modules are not shared across different nodes and morphologies as in MetaMorph. (2) Generating morphology-conditioned attention matrices by using context embeddings as the key and query inputs to the transformer encoder. Note that we use two separate context encoders for these two submodules, but show only a single shared context encoder in this figure for ease of illustration.
72
+
73
+ 2020) and lower gradient variance during learning (Sarafian et al., 2021). However, HN is also known to be harder to optimize due to its more complicated hierarchical network architecture, and proper initialization of HN is critical to stabilize its training (Chang et al., 2019; Beck et al., 2022).
74
+
75
+ # 3. Universal Morphology Control via Contextual Modulation
76
+
77
+ In this section, we introduce two novel approaches to modulate the controller with morphology context. The framework of our proposed method is shown in Figure 2, which includes a base controller that generally follows the same architecture as MetaMorph, and a context network that modulates the base controller in two ways: (1) Instead of using shared embedding layer and decoder across all nodes, we generate node-wise embedding and decoder parameters with an HN conditioned on the morphology context. (2) The node embedding in the base controller is only used to generate the value input to the transformer encoder, while the key and query are conditioned on the morphology context to generate a fixed attention matrix. We call these two approaches hypernetworks (HN) and fixed attention (FA).
78
+
79
+ ![](images/30e10b052e71c7271fd7d27834b9912531870a9a9feb572544c34aa541b91b98.jpg)
80
+ Figure 3. Single-robot learning curves averaged over 20 robots.
81
+
82
+ # 3.1. Context Conditioning via Hypernetworks
83
+
84
+ While GNN and transformer-based controllers enable generalization across different morphologies, they also introduce a structural constraint that all nodes, both within a single robot and across different morphologies, have to share the same modular control policy. This hard parameter sharing mechanism (Ruder, 2017) may limit the behavior diversity across different nodes and the controller's model capacity to learn the optimal policy, as we usually expect different limbs to follow different control strategies based on their roles in the morphology. There is even evidence from neuroscience that the muscles in human body are controlled by different types of motor neurons based on their identities (Stifani, 2014).
85
+
86
+ Consequently, we hypothesize that instead of learning parameters shared across all nodes, learning node-wise parameters may improve behavior diversity and learning performance. We first conduct a proof-of-concept experiment to validate our hypothesis, then show how to generate context-conditioned parameters for each node via HN modulation.
87
+
88
+ # 3.1.1. A PROOF-OF-CONCEPT EXPERIMENT
89
+
90
+ We design a motivating experiment to show that enabling behavior diversity across nodes via learning node-wise parameters can improve training performance.
91
+
92
+ We train a MetaMorph model on a single robot. However, instead of learning a single embedding layer shared across all the nodes, we learn a separate embedding for each node. Similarly, we train another MetaMorph variant with node-wise decoders. We randomly sample 20 morphologies from the UNIMAL benchmark and run single-task training on each of them for 10M steps. As shown in Figure 3, the node-wise embedding and node-wise decoder variants both
93
+
94
+ outperform MetaMorph, which shows that enabling behavior diversity across the nodes of a single robot is helpful.
95
+
96
+ However, the approach used in our proof-of-concept experiment is impractical for two reasons: (1) It cannot generalize to new morphologies unseen during training; (2) Learning separate parameters for each node is not scalable, as the number of parameters to learn grows linearly with the number of morphologies. Consequently, we next introduce HN modulation to enable behavior diversity while maintaining generalization and scalability of the learned model.
97
+
98
+ # 3.1.2. CONTEXT-CONDITIONED PARAMETER GENERATION VIA HYPERNETWORKS
99
+
100
+ Learning separate parameters for each node has generalization and scalability issues, as it does not utilize the similarity between nodes. Intuitively, if two nodes play similar roles in two different morphologies (e.g., they are both the left thigh in their robots), then we may expect them to also have similar node-wise parameters. As the morphology context of each node can provide rich information about the similarities between nodes, we propose to generate node-wise parameters via a context-conditioned HN, i.e., $\theta_{k}^{i} = \mathrm{HN}_{\phi}(c_{k}^{i})$ where $\theta_{k}^{i}$ is the node-wise parameters for node $i$ of robot $k$ , and $\mathrm{HN}_{\phi}$ is the learned HN shared across all nodes. Generating node-wise parameters via HN is scalable, as we only need to additionally learn one set of HN parameters $\phi$ regardless of the number of morphologies, and generalizable, as we can directly feed new node context on unseen morphologies into the HN to generate its control parameters.
101
+
102
+ To better illustrate how HN-generated parameters work, we take the node embedding layer as an example. In MetaMorph, the embedding layer consists of a single set of weights $W$ and bias $b$ shared across all the nodes, i.e., $e_k^i = Wx_k^i + b$ , where $x_{k}^{i}$ and $e_k^i$ are the node input and node embedding of node $i$ in robot $k$ respectively. For our HN approach, however, the embedding layer's parameters are different across nodes, i.e., $e_k^i = W_k^i x_k^i + b_k^i$ , where $W_{k}^{i} = \mathrm{HN}_{W}(c_{k}^{i})$ and $b_{k}^{i} = \mathrm{HN}_{b}(c_{k}^{i})$ are node-wise weights and bias generated by HN conditioned on the node context.
103
+
104
+ In practice, we only generate linear layers' parameters in the base network with HN, i.e., the embedding layer and the decoder. The transformer encoder is still shared across all morphologies, as there are too many weight matrices in a transformer layer to efficiently generate them via HN.
105
+
106
+ # 3.2. Morphology-Conditioned Fixed Attention
107
+
108
+ The attention weight matrix plays an important role in transformers as it determines how each node should attend to the others to update its own representation.
109
+
110
+ Existing methods use the node embedding in the base controller as the key and query inputs to generate the attention
111
+
112
+ weights, which change dynamically at every time step due to the time-variant proprioceptive observations. However, determining attention weights in such a dynamic way may not well reflect how different nodes interact. Instead, it may be the case that the attention of one node to the others should depend solely on the morphology of the agent. For example, when you want to grasp an object within your reach, you pay more attention to the state of your arm than your leg to determine the movement of your hand. Similarly, whether you are standing or sitting, which changes the proprioceptive observations of body parts, has little influence on your attention strategy for grasping.
113
+
114
+ Consequently, we hypothesize that it may be beneficial to incorporate such intuitions as inductive biases into the controller architecture, i.e., each node should attend to the other nodes in a static way, and the attention weights should be determined by the morphology context alone. To realize these inductive biases, we pass the node context through a context encoder, and use the context embedding as the key and query to modulate the transformer in the base controller, while the node embedding in the base network is only used as the value input (Figure 2). As the morphology context remains unchanged, the attention matrix is fixed on each robot to reflect the structural relationships between nodes.
115
+
116
+ # 3.3. Computational Cost
117
+
118
+ HN learning will increase computational cost during training. However, there is no additional cost during deployment, as we can generate node-wise parameters with HN on each robot in advance. On the other hand, except for context encoding, FA will introduce no additional computation during training, as it just changes the query and key inputs to the transformer. Furthermore, FA could even reduce the computation during evaluation, as we need to compute the FA weights only once for each robot and then can reuse it afterwards. See Appendix A for more implementation details of our contextual modulation method.
119
+
120
+ # 4. Experimental Setup
121
+
122
+ **Environments** We experiment on the UNIMAL task set as used in MetaMorph (Gupta et al., 2022), which includes 100 training robots and 100 test robots with diverse morphologies (Gupta et al., 2021).
123
+
124
+ We consider five different environments from Gupta et al. (2021) for our experiments (Figure 4): (1) Flat terrain (FT): maximize locomotion distance on a flat floor; (2) Incline: maximize locomotion distance on an incline of 10 degrees; (3) Exploration: maximize the number of distinct grids visited on a flat arena discretized into grids; (4) Variable terrain (VT): maximize locomotion distance on a variable terrain with three different terrain types. For each episode, a new
125
+
126
+ terrain is generated by randomly sampling a sequence of terrain types and interleaving them with flat terrain. (5) Obstacles: maximize locomotion distance on a flat terrain with randomly positioned obstacles. The first three environments only require proprioceptive observations and morphology context as model input, while the last two require height map information surrounding the robot as additional exteroceptive observation input to the controller, so that the agent can perceive and react to different terrains or obstacles in its way.
127
+
128
+ Baselines We consider both multi-robot (MR) and singlerobot (SR) baselines.
129
+
130
+ For MR training, we use MetaMorph (Gupta et al., 2022) as the baseline. However, we notice two issues in the MetaMorph code and thus implement a slightly modified version to eliminate these issues. We name the modified version as MetaMorph*, and build our modulation modules upon it. In general, MetaMorph* achieves similar or even better performance compared to MetaMorph in most environments, and we report the results of both for a fair comparison. See Appendix C for more details on the difference between MetaMorph and MetaMorph*.
131
+
132
+ For SR training, we train an MLP policy on each robot, and consider two different training budgets for different purposes. First, we do SR training with the same per-robot budget as in MR training, which is named as $SR$ -fair and used to compare the sample efficiency of MR and SR learning. Second, We do SR training for 10M steps on each robot till convergence, which is named as $SR - 10M$ and used as a performance upper bound. We choose to use an MLP of 3 hidden layers, each with 256 hidden units by performing a grid search over the layer number and hidden size.
133
+
134
+ Ablations As we propose two different approaches for contextual modulation, we test ablations by adding only HN or FA to the MetaMorph* baseline, and compare them with the full version of adding both to MetaMorph*.
135
+
136
+ Training Setup We train for 100M steps in FT, Incline, and Exploration, and 200M steps in VT and Obstacles, as they are more challenging to solve due to variable terrains. We run three random seeds for each method in each environment, and report the average performance and standard deviation. Following the same setup as in MetaMorph, we use PPO (Schulman et al., 2017) as the optimization algorithm. Similar to previous works (Dossa et al., 2021; Sun et al., 2022), we notice that the early stopping threshold has a significant influence on PPO performance (see Appendix B). We thus tune this hyperparameter over the candidate set of $\{0.03, 0.05\}$ for each method in each environment. All the remaining hyperparameters follow the same setup as in MetaMorph for a fair comparison.
137
+
138
+ ![](images/e610562d12335b59b514161e411596b433479e8da63675bb3c02a1ef1b23fc51.jpg)
139
+ Figure 4. The five environments used for experiments. From left to right: Flat terrain (FT), Incline, Exploration, Variable terrain (VT), Obstacles. Images credit to Gupta et al. (2021; 2022).
140
+
141
+ Evaluation Setup We evaluate zero-shot generalization to unseen robots under two settings with increasing difficulties. First, we test on new robots that have the same topology as the training ones but differ in kinematics or dynamics parameters. For each parameter to test, we create 4 variants of each training robot by randomly changing the value of the corresponding parameter on all the limbs. Second, we evaluate zero-shot generalization to new morphologies which have different topology graphs compared to those seen during training. The robots used for both settings are adopted from Gupta et al. (2022) for a fair comparison. For each robot, we collect 64 rollouts with randomly sampled initial states. We use the average episodic return over the test morphologies to measure the policy's transferability.
142
+
143
+ # 5. Results
144
+
145
+ # 5.1. Training Results
146
+
147
+ As shown in Figure 5, all MR methods significantly outperform SR-fair, illustrating the advantage of MTRL in sample efficiency. However, there is still a clear performance gap between the two MR baselines and SR-10M, due to the challenges of MTRL. Our method significantly reduces this gap (even outperforms SR-10M in Exploration), and consistently outperforms the two MR baselines in all the five environments w.r.t. both learning efficiency and final performance. Compared to MetaMorph*, which our method builds upon, contextual modulation improves the final performance by $19\%$ , $53\%$ , $48\%$ , $31\%$ and $29\%$ in each environment respectively. Although MetaMorph outperforms MetaMorph* in VT and Obstacles, our method still consistently outperforms MetaMorph in these two environments.
148
+
149
+ Ablation results show that both FA and HN contribute to the effectiveness of our method. FA consistently improves upon MetaMorph* in all the environments, and seems to be more effective in the three environments with unchanged terrain (VT, Incline and Exploration). On the other hand, HN helps in three of the five environments, and contributes more in the two environments with changing terrains (VT and Obstacles). Next we give some more detailed analysis on the two submodules of our method.
150
+
151
+ Fixed Attention FA introduces a strong inductive bias that how each node attends to the others should be solely determined by the morphology, and is proved to be effective in all the five environments. However, in environments with changing terrains, the robot may need to adopt different gaits in different terrains. While in principle this can be realized by taking terrain information as additional decoder input, an alternative idea is to further condition the attention weights on the terrain information, so that the nodes can attend to each other with dynamic terrain-conditioned weights to realize different gaits. We thus tried adding the height map as an additional input to compute attention weights, but got results even worse than the MetaMorph* baseline. The reason might be that the robot can already adapt to different terrains by taking the height map as decoder input, so the attention module only needs to model intra-morphology interactions, while using terrain info as attention inputs may introduce further optimization challenges. Nevertheless, it remains an interesting open question whether learning performance can be further improved by properly incorporating terrain information into attention computation.
152
+
153
+ Hypernetworks HN provides more significant improvement in the more challenging environments of VT and Obstacles with variable terrains. This may imply that behavior diversity across nodes is more important in environments that require complex locomotion skills, while in easier terrains, the benefits of HN may be outweighed by its optimization challenges. Moreover, adding HN harms learning performance in the Exploration environment. The training statistics show that the HN variant has a much higher error in value prediction compared to the other methods in Exploration, which may be the reason for its worse performance. Value prediction is particularly hard in Exploration, as the value depends on not only the robot's status, but also the robot's visitation history in the arena, which is not accessible to the robot. We hypothesize that this problem is more severe when using the more complex HN architecture.
154
+
155
+ # 5.2. Zero-Shot Generalization to Kinematics and Dynamics Variations
156
+
157
+ As shown in Figure 6, our method consistently outperforms the baselines, with an average improvement ratio of $26\%$ ,
158
+
159
+ ![](images/cd5e7826bacb5617b91fd0a106a68291b144e74fb7924328b76ab1d3dc7e1875.jpg)
160
+
161
+ ![](images/6070ae1d1d8d03e729329ae7b7e6e4ec928acaf5f26d8993c7104d4eb473a1ec.jpg)
162
+
163
+ ![](images/f8fe15c6e675632b8254156f73aa3ec5355d22caf862d9a568d36b31a02cf05f.jpg)
164
+
165
+ ![](images/23f41de682221c59e6aa5c506897de94bd40ef3466678af6f051b3003dc89534.jpg)
166
+ Figure 5. The training curves of different methods in each environment.
167
+
168
+ ![](images/0f08d62a20415d5f3641683fceaed29ac047e310082072a43ffecfd11a87c5df.jpg)
169
+
170
+ $50\%$ , $43\%$ , $28\%$ , $30\%$ in each environment compared to MetaMorph*, which validates that our method not only enables better multi-robot training, but also generalizes better to unseen robots with parametric variations. However, we also notice that zero-shot generalization to kinematics variation (especially joint angles) is much harder, as is also reported in Gupta et al. (2022). This is mainly because that changes in joint angles may significantly influence the feasible actions and the gait for locomotion, and how to tackle this challenge is an interesting direction for future work.
171
+
172
+ # 5.3. Zero-Shot Generalization to Unseen Morphologies
173
+
174
+ Table 1 shows the zero-shot generalization performance of different methods in each environment, which generally follows the same trend as during training, i.e., the model with higher training scores also performs better in zero-shot generalization. Specifically, our method outperforms MetaMorph* by $18\%$ , $29\%$ , $24\%$ , $27\%$ and $37\%$ in each environment respectively. This implies that our contextual modulation method can indeed better model the dependence of the control policy on the robot morphology, instead of simply overfitting to the training morphologies via its more complicated architecture designs. However, the large variance in the return across different seeds does imply that
175
+
176
+ improving zero-shot generalization on unseen morphologies is still an open problem for future work.
177
+
178
+ # 5.4. Qualitative Analysis
179
+
180
+ We conduct a qualitative analysis in the FT environment to illustrate the difference in the locomotion skills learned by different methods.
181
+
182
+ We experiment on an example morphology as shown in Figure 7, and compare the locomotion learned by MetaMorph* and our method in Figure 8. For MetaMorph*, the robot moves forward by kicking the ground with its front limb. However, the front limb does not fully stretch out, thus provides limited forward force and makes the body unstable. In 1000 timesteps, the robot falls twice and only achieves a return of 1375 in its best trial. By contrast, our method learns a policy that fully stretches out the front limb to provide stronger forward force, and better coordinates the movement of the front and back limbs. The robot runs more stably without any failure during evaluation, and achieves a much higher return of 4612.
183
+
184
+ In addition to behavior visualization, we further analyze the correlation between the action sequences taken by different limbs as an indicator of behavior synergies. Intuitively, if the
185
+
186
+ Table 1. Zero-shot generalization performance of different methods to test morphologies with unseen topology graphs. The best method in each environment is marked in Bold. The methods that are not statistically significantly different from the best method are marked by underline based on Welch's t-test with a significance level of 0.05 (Colas et al., 2019).
187
+
188
+ <table><tr><td>ENVIRONMENT</td><td>METAMORPH</td><td>METAMORPH*</td><td>FA</td><td>HN</td><td>FA+HN</td></tr><tr><td>FT</td><td>1384 ± 62</td><td>1266 ± 105</td><td>1439 ± 27</td><td>1259 ± 112</td><td>1490 ± 59</td></tr><tr><td>INCLINE</td><td>27 ± 32</td><td>312 ± 136</td><td>468 ± 58</td><td>312 ± 97</td><td>403 ± 66</td></tr><tr><td>EXPLORATION</td><td>19 ± 1</td><td>19 ± 1</td><td>22 ± 2</td><td>16 ± 3</td><td>23 ± 3</td></tr><tr><td>VT</td><td>752 ± 62</td><td>767 ± 23</td><td>860 ± 112</td><td>900 ± 24</td><td>971 ± 122</td></tr><tr><td>OBSTACLES</td><td>866 ± 30</td><td>829 ± 50</td><td>937 ± 46</td><td>969 ± 47</td><td>1133 ± 12</td></tr></table>
189
+
190
+ ![](images/5fdda1b2b2f256d30cc2903e7279088846d00495d6e7ad45854e4f5df5b506f7.jpg)
191
+ Figure 7. The example morphology and its morphology tree. Some limbs are connected to their parents via two joints, represented by the two edges between nodes. The sphere node is the torso of the robot and also the root of the morphology tree.
192
+
193
+ behavior of two limbs are better coordinated, then we may expect their action sequences to have a higher correlation coefficient. Figure 9 shows the correlation matrix between different action dimensions on the example morphology. For our method, joint 2 (which controls the front limb 2) is much better synchronized with joints 3 and 4 (which control limbs 3 and 4 in the back). This reflects how the periodic gait of our method in Figure 8 is generated.
194
+
195
+ In the VT environment, MetaMorph* has an average action correlation of 0.24 across all training morphologies, while our method has 0.29. This higher correlation indicates a better synergy between limbs, which may help explain why our method has more fluent and stable locomotion.
196
+
197
+ # 6. Related Work
198
+
199
+ Universal Morphology Control To learn a universal policy to control multiple robots, many previous works focus on the setting where the robots share the same morphology and only differ in kinematics or dynamics parameters
200
+
201
+ ![](images/e4bd9a1fba85e0d0eda820029341f56a44a049c309cda32d5be34aade79fcf24.jpg)
202
+
203
+ ![](images/fd2356cd56863d9ca85243702c906509b241b9e6cc1d5e8c3aadce076021a8ed.jpg)
204
+
205
+ ![](images/6f4ababbee70470e3904bcc740a4c9b26f38e0e469e958e5d615903927ad49f0.jpg)
206
+ Figure 6. Zero-shot generalization performance of different methods to kinematics and dynamics variations. The rows correspond to the 5 environments, and the columns correspond to parametric variations in 6 different morphology context parameters.
207
+
208
+ ![](images/cfcb8c154d137092c8b049e9e44bb4933357842d979a77a7090c67b7d7b3a276.jpg)
209
+ Figure 8. Visualization of the locomotion trajectories learned by MetaMorph* and our method on the example robot.
210
+
211
+ ![](images/03894ca5c70bf57181435c713fa5deab5a57a65c26f525d7da24f50660dfbdfc.jpg)
212
+ Figure 9. The correlation matrix of different action dimensions on the example morphology.
213
+
214
+ (Chen et al., 2018; Peng et al., 2018; Clavera et al., 2019; Ghadirzadeh et al., 2021; Feng et al., 2022). These works mainly build upon MLP architectures, thus cannot handle different morphologies with heterogeneous state and action spaces. Wang et al. (2018), Pathak et al. (2019) and Huang et al. (2020) use GNNs (Wu et al., 2020) to tackle this problem, as the robot morphology can be seen as a kinematic graph and GNNs can naturally generalize across graphs with different number of nodes. Kurin et al. (2021) show that it is hard to model the interactions between distant nodes in the morphology graph with GNNs, thus propose to use transformers as the controller to enable immediate interactions between any node pairs. While these works mainly focus on architecture design to better model limb interactions, more recent works show that incorporating morphology information into the controller via feature concatenation or positional encoding can further improve learning performance (Gupta et al., 2022; Hong et al., 2022; Trabucco et al., 2022). However, these approaches in effect just add a context-conditioned bias term to the node embedding, which may not be sufficient to model the complex dependency of a robot's control policy on its morphology. Moreover, instead of sharing all parameters across different morphologies, learning node-wise or morphology-wise parameters for some specific layers has also been shown to improve learning performance (D'Eramo et al., 2020; Yuan et al., 2022), but suffers from generalization and scalability issues as discussed in Section 3.1. Unlike existing works, the contextual modulation method in this paper enables both learning diverse morphology-conditioned policies, and generalization and scalability to new robots.
215
+
216
+ Contextual Modulation in RL The optimal policy for a task usually critically depends on the task context that defines the task's characteristics. Consequently, conditioning the policy on the task context may significantly improve its training performance and generalization ability over a distribution of tasks compared to context-agnostic learning (Benjamins et al., 2022). To learn a context-conditioned policy, an importance design choice is the architecture used to incorporate the task context into the policy, which reflects our inductive bias on the task structure. Instead of simply concatenating the context features to the state features, which is limited in model capacity (Galanti & Wolf, 2020), different architectures have been proposed to modulate the policy via task context, such as feature-wise multiplication (Ben-Iwhiwhu et al., 2022; Benjamins et al., 2022), a routing network that determines how to combine different skill modules for a specific task (Yang et al., 2020; Sodhani et al., 2021; Ponti et al., 2022), and hypernetworks (Yu et al., 2019; Peng et al., 2021; Sarafian et al., 2021; Beck et al., 2022; Rezaei-Shoshtari et al., 2022). Our work shares a similar motivation as these methods, but focuses on a more challenging domain of universal morphology control where
217
+
218
+ different tasks do not share the same state and action space.
219
+
220
+ # 7. Conclusion
221
+
222
+ In this paper, we investigated how to learn a universal control policy for different robot morphologies. To better model the dependency of the control policy on the robot morphology, we proposed a hierarchical architecture to modulate the base controller with morphology context, which includes a hypernetwork module that generates morphology-dependent controller parameters, and a morphology-dependent attention module to modulate the transformer layers in the base controller. Experimental results validated the effectiveness of our method on both multiple training robots and unseen test morphologies.
223
+
224
+ For future work, an interesting direction is how to learn better context representation for modulation. In this paper, we directly used the original node context features provided in the benchmark as the modulator input, and a simple MLP as the context encoder. How to design better context features, such as utilizing node connectivity information, and how to design better context encoding architectures are both interesting topics to investigate. Another potential direction is how to improve zero-shot generalization performance on unseen robots, as there is still a large gap between the current generalization results and the optimal performance we can achieve by directly training on the test robots. Thirdly, our method builds upon a modular design space assumption which may not hold on some real-world robots, thus how to relax this assumption to enable more general knowledge transfer across different morphologies is an interesting direction for future work. Finally, while we focus on the problem setting of learning a universal controller over a set of pre-given robot morphologies, an interesting direction for future work is to apply our method to a closely related problem setting of jointly optimizing the morphology design and its corresponding control policy (Schaff et al., 2019; Wang et al., 2019; Yuan et al., 2022; Schaff & Walter, 2022).
225
+
226
+ # Acknowledgements
227
+
228
+ We would like to thank Zhengdao Chen, Agrim Gupta, Matthew Jackson, Vitaly Kurin and Risto Vuorio for their helpful discussion on the work. We would also like to thank the conference reviewers for their constructive feedback on the paper. Zheng Xiong is supported by UK EPSRC CDT in Autonomous Intelligent Machines and Systems (grant number EP/S024050/1) and AWS. Jacob Beck is supported by the Oxford-Google DeepMind Doctoral Scholarship. The experiments were made possible by a generous equipment grant from NVIDIA.
229
+
230
+ # References
231
+
232
+ Andrychowicz, O. M., Baker, B., Chogiej, M., Jozefowicz, R., McGrew, B., Pachocki, J., Petron, A., Plappert, M., Powell, G., Ray, A., et al. Learning dexterous in-hand manipulation. The International Journal of Robotics Research, 39(1):3-20, 2020.
233
+ Beck, J., Jackson, M. T., Vuorio, R., and Whiteson, S. Hypernetworks in meta-reinforcement learning. In 6th Annual Conference on Robot Learning, 2022.
234
+ Ben-Iwhiwhu, E., Dick, J., Ketz, N. A., Pilly, P. K., and Soltoggio, A. Context meta-reinforcement learning via neuromodulation. Neural Networks, 152:70-79, 2022.
235
+ Benjamins, C., Eimer, T., Schubert, F., Mohan, A., Biedenkapp, A., Rosenhahn, B., Hutter, F., and Lindauer, M. Contextualize me-the case for context in reinforcement learning. arXiv preprint arXiv:2202.04500, 2022.
236
+ Brohan, A., Brown, N., Carbajal, J., Chebotar, Y., Dabis, J., Finn, C., Gopalakrishnan, K., Hausman, K., Herzog, A., Hsu, J., et al. Rt-1: Robotics transformer for real-world control at scale. arXiv preprint arXiv:2212.06817, 2022.
237
+ Chang, O., Flokas, L., and Lipson, H. Principled weight initialization for hypernetworks. In International Conference on Learning Representations, 2019.
238
+ Chen, T., Murali, A., and Gupta, A. Hardware conditioned policies for multi-robot transfer learning. Advances in Neural Information Processing Systems, 31, 2018.
239
+ Clavera, I., Nagabandi, A., Liu, S., Fearing, R. S., Abbeel, P., Levine, S., and Finn, C. Learning to adapt in dynamic, real-world environments through meta-reinforcement learning. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id=HyztsoC5Y7.
240
+ Colas, C., Sigaud, O., and Oudeyer, P.-Y. A hitchhiker's guide to statistical comparisons of reinforcement learning algorithms. In *ICLR Worskhop on Reproducibility*, 2019.
241
+ D'Eramo, C., Tateo, D., Bonarini, A., Restelli, M., Peters, J., et al. Sharing knowledge in multi-task deep reinforcement learning. In 8th International Conference on Learning Representations, {ICLR} 2020, Addis Ababa, Ethiopia, April 26-30, 2020, pp. 1-11. OpenReview.net, 2020.
242
+ Dossa, R. F. J., Huang, S., Ontañón, S., and Matsubara, T. An empirical investigation of early stopping optimizations in proximal policy optimization. IEEE Access, 9: 117981-117992, 2021.
243
+ Dufter, P., Schmitt, M., and Schütze, H. Position information in transformers: An overview. Computational Linguistics, 48(3):733-763, 2022.
244
+
245
+ Feng, G., Zhang, H., Li, Z., Peng, X. B., Basireddy, B., Yue, L., SONG, Z., Yang, L., Liu, Y., Sreenath, K., et al. Genloco: Generalized locomotion controllers for quadrupedal robots. In 6th Annual Conference on Robot Learning, 2022.
246
+ Galanti, T. and Wolf, L. On the modularity of hypernetworks. Advances in Neural Information Processing Systems, 33:10409-10419, 2020.
247
+ Ghadirzadeh, A., Chen, X., Poklukar, P., Finn, C., Björkman, M., and Kragic, D. Bayesian meta-learning for few-shot policy adaptation across robotic platforms. In 2021 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pp. 1274-1280. IEEE, 2021.
248
+ Gupta, A., Savarese, S., Ganguli, S., and Fei-Fei, L. Embodied intelligence via learning and evolution. Nature communications, 12(1):1-12, 2021.
249
+ Gupta, A., Fan, L., Ganguli, S., and Fei-Fei, L. Metamorph: Learning universal controllers with transformers. In International Conference on Learning Representations, 2022.
250
+ Ha, D., Dai, A., and Le, Q. V. Hypernetworks. arXiv preprint arXiv:1609.09106, 2016.
251
+ Hallak, A., Di Castro, D., and Mannor, S. Contextual markov decision processes. arXiv preprint arXiv:1502.02259, 2015.
252
+ Hong, S., Yoon, D., and Kim, K.-E. Structure-aware transformer policy for inhomogeneous multi-task reinforcement learning. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id=fy_XRVHqly.
253
+ Huang, W., Mordatch, I., and Pathak, D. One policy to control them all: Shared modular policies for agent-agnostic control. In International Conference on Machine Learning, pp. 4455-4464. PMLR, 2020.
254
+ Jagnandan, K. and Higham, T. E. Lateral movements of a massive tail influence gecko locomotion: an integrative study comparing tail restriction and autotomy. Scientific Reports, 7(1):1-8, 2017.
255
+ Kalashnikov, D., Irpan, A., Pastor, P., Ibarz, J., Herzog, A., Jang, E., Quillen, D., Holly, E., Kalakrishnan, M., Vanhoucke, V., et al. Scalable deep reinforcement learning for vision-based robotic manipulation. In Conference on Robot Learning, pp. 651-673. PMLR, 2018.
256
+ Kurin, V., Igl, M., Roktaschel, T., Boehmer, W., and Whiteson, S. My body is a cage: the role of morphology in graph-based incompatible control. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=N3zUDGN510.
257
+
258
+ Levine, S., Finn, C., Darrell, T., and Abbeel, P. End-to-end training of deep visuomotor policies. The Journal of Machine Learning Research, 17(1):1334-1373, 2016.
259
+ Liu, Z., Li, X., Kang, B., and Darrell, T. Regularization matters in policy optimization - an empirical study on continuous control. In International Conference on Learning Representations, 2021. URL https://openreview.net/forum?id=yr1mrH3IC.
260
+ Pathak, D., Lu, C., Darrell, T., Isola, P., and Efros, A. A. Learning to control self-assembling morphologies: a study of generalization via modularity. Advances in Neural Information Processing Systems, 32, 2019.
261
+ Peng, M., Zhu, B., and Jiao, J. Linear representation meta-reinforcement learning for instant adaptation. arXiv preprint arXiv:2101.04750, 2021.
262
+ Peng, X. B., Andrychowicz, M., Zaremba, W., and Abbeel, P. Sim-to-real transfer of robotic control with dynamics randomization. In 2018 IEEE international conference on robotics and automation (ICRA), pp. 3803-3810. IEEE, 2018.
263
+ Ponti, E. M., Sordoni, A., and Reddy, S. Combining modular skills in multitask learning. arXiv preprint arXiv:2202.13914, 2022.
264
+ Rezaei-Shoshtari, S., Morissette, C., Hogan, F. R., Dudek, G., and Meger, D. Hypernetworks for zero-shot transfer in reinforcement learning. arXiv preprint arXiv:2211.15457, 2022.
265
+ Ruder, S. An overview of multi-task learning in deep neural networks. arXiv preprint arXiv:1706.05098, 2017.
266
+ Sarafian, E., Keynan, S., and Kraus, S. Recomposing the reinforcement learning building blocks with hypernetworks. In International Conference on Machine Learning, pp. 9301-9312. PMLR, 2021.
267
+ Schaff, C. and Walter, M. R. N-limb: Neural limb optimization for efficient morphological design. arXiv preprint arXiv:2207.11773, 2022.
268
+ Schaff, C., Yunis, D., Chakrabarti, A., and Walter, M. R. Jointly learning to construct and control agents using deep reinforcement learning. In 2019 International Conference on Robotics and Automation (ICRA), pp. 9798-9805. IEEE, 2019.
269
+ Schulman, J., Wolski, F., Dhariwal, P., Radford, A., and Klimov, O. Proximal policy optimization algorithms. arXiv preprint arXiv:1707.06347, 2017.
270
+ Sodhani, S., Zhang, A., and Pineau, J. Multi-task reinforcement learning with context-based representations.
271
+
272
+ In International Conference on Machine Learning, pp. 9767-9779. PMLR, 2021.
273
+ Stifani, N. Motor neurons and the generation of spinal motor neuron diversity. Frontiers in cellular neuroscience, 8: 293, 2014.
274
+ Sun, M., Kurin, V., Liu, G., Devlin, S., Qin, T., Hofmann, K., and Whiteson, S. You may not need ratio clipping in ppo. arXiv preprint arXiv:2202.00079, 2022.
275
+ Trabucco, B., Phielipp, M., and Berseth, G. Anymorph: Learning transferable polices by inferring agent morphology. In International Conference on Machine Learning, pp. 21677-21691. PMLR, 2022.
276
+ Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L., and Polosukhin, I. Attention is all you need. Advances in neural information processing systems, 30, 2017.
277
+ Vithayathil Varghese, N. and Mahmoud, Q. H. A survey of multi-task deep reinforcement learning. *Electronics*, 9(9): 1363, 2020.
278
+ Wang, T., Liao, R., Ba, J., and Fidler, S. Nervenet: Learning structured policy with graph neural networks. In International conference on learning representations, 2018.
279
+ Wang, T., Zhou, Y., Fidler, S., and Ba, J. Neural graph evolution: Automatic robot design. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id=BkgWHnR5tm.
280
+ Wu, Z., Pan, S., Chen, F., Long, G., Zhang, C., and Philip, S. Y. A comprehensive survey on graph neural networks. IEEE transactions on neural networks and learning systems, 32(1):4-24, 2020.
281
+ Yang, R., Xu, H., Wu, Y., and Wang, X. Multi-task reinforcement learning with soft modularization. Advances in Neural Information Processing Systems, 33:4767-4777, 2020.
282
+ Yu, T., Kumar, S., Gupta, A., Levine, S., Hausman, K., and Finn, C. Multi-task reinforcement learning without interference. In Proc. Optim. Found. Reinforcement Learn. Workshop NeurIPS, 2019.
283
+ Yuan, Y., Song, Y., Luo, Z., Sun, W., and Kitani, K. M. Transform2act: Learning a transform-and-control policy for efficient agent design. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id=UcDUxjPYWSr.
284
+
285
+ # A. Implementation Details
286
+
287
+ # A.1. Architecture Details of Contextual Modulation
288
+
289
+ Intuitively, using GNNs or transformers as the context encoder to model node interactions may learn better context representations. However, in practice we find that using simple MLPs as the context encoder achieves similar or even better performance. The reason might be that we have many fewer training samples for the context encoder, which equals the number of robots we have for training, as the morphology context does not change on a robot. So using models with high capacity may not be helpful here and even lead to overfitting. Moreover, HNs are known to be hard to optimize (Chang et al., 2019), and we find that using transformers as the context encoder makes HN training unstable. Consequently, we just use MLPs as the context encoder shared over different nodes. Specifically, we train two separate context encoders for HN and FA respectively. The context encoder is a 2-layer MLP for HN, and a 3-layer MLP for FA, both with 128 units in each hidden layer.
290
+
291
+ The HN output layer is implemented as a linear mapping from context encoding to the parameters in the base network, with one independent output head for each modulated layer in the base controller. We initialize it with the Bias-HyperInit method proposed by Beck et al. (2022), i.e., the weights are set to 0, and the biases are sampled from the same distribution that is used to initialize the modulated layer in the base network. In this way, all the nodes share the same control parameters just like MetaMorph at the beginning, and gradually develop node-wise diversity while the HN weights are updated.
292
+
293
+ # A.2. Proprioceptive and Context Features
294
+
295
+ We use the same proprioceptive and context features as in MetaMorph for a fair comparison, which can be found in Appendix A.1 of Gupta et al. (2022).
296
+
297
+ # B. PPO and Early Stopping
298
+
299
+ PPO (Schulman et al., 2017) is an on-policy RL algorithm that takes multiple steps of update on the current data we have, while also trying not to exceed some trust region boundary to avoid performance collapse. For a state-action pair $s$ , $a$ , the clipping objective function of PPO is defined as
300
+
301
+ $$
302
+ L (s, a, \theta_ {k}, \theta) = \min \left(\frac {\pi_ {\theta} (a | s)}{\pi_ {\theta_ {k}} (a | s)} A ^ {\pi_ {\theta_ {k}}} (s, a), \operatorname {c l i p} \left(\frac {\pi_ {\theta} (a | s)}{\pi_ {\theta_ {k}} (a | s)}, 1 - \epsilon , 1 + \epsilon\right) A ^ {\pi_ {\theta_ {k}}} (s, a)\right),
303
+ $$
304
+
305
+ where $\pi_{\theta_k}$ is the behavior policy used to collect on-policy data for policy update in iteration $k$ , $\pi_{\theta}$ is the target policy we want to learn, $A^{\pi_{\theta_k}}(s,a)$ is the advantage function of $\pi_{\theta_k}$ , and $\epsilon$ is a hyperparameter that constrains the updated policy to not be too far away from the behavior policy.
306
+
307
+ In many RL libraries, one PPO iteration is implemented by first collecting $N$ steps of rollout data on $M$ workers in parallel with $\pi_{\theta_k}$ , then dividing the collected data into $B$ batches and repeating minibatch update for $T$ epochs. Consequently, for one PPO iteration, we'll do $T \cdot B$ times of minibatch update.
308
+
309
+ However, the clipping objective function alone can not guarantee policy update within the trust region. Early stopping is a solution to this problem by first checking the approximate KL divergence between $\pi_{\theta}$ and $\pi_{\theta_k}$ before each minibatch update, and terminating the current update iteration if the divergence exceeds a threshold value $\delta$ . The policies' KL divergence is approximated as $D_{\mathrm{KL}}(\pi_{\theta_k}||\pi_\theta)\approx \sum_{(s,a)\in \mathcal{B}}\log \left(\frac{\pi_{\theta_k}(a|s)}{\pi_\theta(a|s)}\right)$ , where $\mathcal{B}$ is the current data minibatch used for policy update.
310
+
311
+ The early stopping threshold $\delta$ is a critical hyperparameter in PPO, as it gives a measurement of the range of the trust region we allow for policy update. We tune it over the candidate set of $\{0.03, 0.05\}$ , and report the optimal value of $\delta$ for each method in each environment in Table 2. We do not tune over a wider range, as empirically we found that a even smaller value of $\delta$ usually causes early stopping to happen too early, while a larger value allows for a too large trust region, both harming the learning performance.
312
+
313
+ # C. Analysis on MetaMorph
314
+
315
+ In this section, we introduce the issues found when reproducing MetaMorph results with its source code, which motivates us to propose the MetaMorph* variant as an alternative baseline.
316
+
317
+ Table 2. Optimal value of the early stopping threshold for each method in each environment.
318
+
319
+ <table><tr><td>ENVIRONMENT</td><td>METAMORPH*</td><td>FA</td><td>HN</td><td>FA+HN</td></tr><tr><td>FT</td><td>0.05</td><td>0.05</td><td>0.05</td><td>0.05</td></tr><tr><td>INCLINE</td><td>0.03</td><td>0.05</td><td>0.05</td><td>0.05</td></tr><tr><td>EXPLORATION</td><td>0.03</td><td>0.03</td><td>0.03</td><td>0.03</td></tr><tr><td>VT</td><td>0.03</td><td>0.03</td><td>0.03</td><td>0.03</td></tr><tr><td>OBSTACLES</td><td>0.03</td><td>0.03</td><td>0.03</td><td>0.03</td></tr></table>
320
+
321
+ ![](images/49296b5a9098a5b68afefab3eabee8c5f1e3cc5c2156abbf5903e134b2d7da4e.jpg)
322
+ Figure 10. The effect of PE and dropout on the performance of MetaMorph in the FT environment.
323
+
324
+ The MetaMorph paper reports significant improvement in learning performance by adding positional encoding (PE) to the node embedding. PE is a common practice in transformers to incorporate positional information into the embedding of each element (Vaswani et al., 2017). Specifically, MetaMorph adopts learned PE, i.e., the PE for each position is a vector that is learned during training instead of hard-coded in advance. However, a robot morphology is structured as a tree, which does not hold sequential information about each node by nature. So MetaMorph first traverses each morphology tree via depth-first search to turn it into a 1D sequence, then index each node by its position in the sequence. One PE vector is learned for each position in the sequence, and the nodes with the same index across different robots will share the same PE vector.
325
+
326
+ However, we found that in the source code of MetaMorph, PE is implemented as $e_i' = \text{dropout}(e_i + \text{PE}_i)$ , where $e_i$ is the embedding of node $i$ . To investigate which operation actually contributes to the performance improvement, we experiment with $e_i' = \text{dropout}(e_i)$ and $e_i' = e_i + \text{PE}_i$ respectively, and surprisingly find that the dropout operation is the main contributor here, while PE alone makes little difference in training performance (Figure 10).
327
+
328
+ ![](images/e729a4d570af91174a50c26cc97715c771f37ad2d37e5a7c02c7adabaa644550.jpg)
329
+ Figure 11. Sources of inconsistency in PE across morphologies. (1) The nodes that play different roles in different morphologies may share the same PE, such as the two nodes indexed by 2 in the left and middle robot. (2) There is no intrinsic order between the children of a parent node in the robot morphology, so PE is sensitive to how we choose which child node to expand first, such as the middle and right robot which have the same morphology but totally different PE for each non-root node.
330
+
331
+ ![](images/0f9015b7225a9558894e00823934b390a079ee2c0a8eaf95c5f25816787530a6.jpg)
332
+
333
+ ![](images/898c6ffac5dce5d6ec5c1706c926091babd02d22628bf821460792ea956586a1.jpg)
334
+
335
+ # C.1. Why PE Does Not Help?
336
+
337
+ Our hypothesis here is that PE has the benefit of enabling more diverse behaviors across different nodes, but also has the drawback of adding the same PE vector to nodes with different physical meanings across robots, i.e., PE is not consistent across morphologies (Figure 11 shows two sources of inconsistency in PE). And when training on multiple robots, the drawback outweighs the benefit, so PE provides no performance gain overall.
338
+
339
+ To validate this hypothesis, we investigate the effect of PE in single-task (ST) training. If our hypothesis holds, we should observe better performance by using PE compared to not, as there is no inconsistency issue on a single robot, while the benefits of PE maintain. We experiment on 30 morphologies and show their average learning curve in Figure 12. As expected, PE indeed improves training performance in ST training, which proves that using PE to distinguish between different nodes in a single morphology is helpful. However, the inconsistency issue breaks its effectiveness in the multi-morphology training setting.
340
+
341
+ Based on the above analysis, we conclude that the PE implementation in MetaMorph is not essential for good performance, thus decide to not include it in MetaMorph*.
342
+
343
+ # C.2. Why Dropout Helps?
344
+
345
+ It's quite surprising that removing the dropout operation causes such a significant performance drop in MetaMorph, as dropout is not believed to be a very useful regularizer for on-policy RL algorithms (Liu et al., 2021). Furthermore, the dropout operation is implemented in an inconsistent way in MetaMorph, which introduces significant noise to the action probability ratio $r = \frac{\pi_{\theta}(a|s)}{\pi_{\theta_k}(a|s)}$ . Specifically, if a dropout mask $m$ is applied to a state $s$ during data collection, then the same mask should be used when $s$ is used during policy update, i.e., $r = \frac{\pi_{\theta}(a|s;m)}{\pi_{\theta_k}(a|s;m)}$ , to maintain a consistent ratio computation. However, in the MetaMorph code, a different dropout mask $m'$ is randomly sampled whenever $s$ is used for policy update, i.e., $r' = \frac{\pi_{\theta}(a|s;m')}{\pi_{\theta_k}(a|s;m)}$ , which introduces significant noise. For example, before the first minibatch update in a PPO iteration, we expect $r$ to be 1 for each state-action pair in the minibatch, as $\pi_{\theta} = \pi_{\theta_k}$ before policy update. However, using inconsistent dropout masks will make $r$ unequal to 1 even before any policy update, which does not make sense intuitively.
346
+
347
+ We thus look deeper into the training statistics of PPO to better understand why this inconsistent dropout operation works, and notice that using dropout or not causes a significant difference in the distribution shift of $r$ during the learning process. Figure 13 shows how the distribution of $r$ changes on each epoch during one PPO update iteration. We can see that the inconsistent dropout operation somehow maintains the distribution stable across epochs, while the distribution significantly changes if learning without dropout. This implies that when learning without dropout, the policy has very likely exceeded the trust region and thus performs worse.
348
+
349
+ A natural solution to restricting the distribution shift is the early stopping method proposed in Appendix B. MetaMorph actually already uses ES in its code, but the threshold is set to 0.2, which is too large and in practice seldomly triggers early stopping. We set it to a smaller value of 0.03 or 0.05, so that we can achieve similar performance as MetaMorph without using the inconsistent dropout operation, which is the second modification we make in MetaMorph*.
350
+
351
+ ![](images/6ca20e3b0b45da22710d48c87546c41a90dc221341dd263d5520793e25d850d5.jpg)
352
+ Figure 12. The effect of PE on single-task MetaMorph in the FT environiment.
353
+
354
+ ![](images/f8de3ca0065f3dbca78e415a6f14035eb4810ea7ddc50734cd26fda1ae2315d4.jpg)
355
+ Figure 13. Ratio distribution of each epoch during one PPO update iteration. Left: MetaMorph; Right: MetaMorph without dropout. Lighter color represents earlier epoch during one update iteration. There is a spike in the right of each subplot because we clip the ratios to be within [0, 2].
356
+
357
+ ![](images/03b6a18b508faec0869206694aa214fe9c811537c9d305482be4a811a3a6f1e8.jpg)
universalmorphologycontrolviacontextualmodulation/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:958a6f71fd0570d0b7763e5c6ccebc833731c345705e94f99432a9f8730107dc
3
+ size 484043
universalmorphologycontrolviacontextualmodulation/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3414a8f74425ee23bed1a1c70a956d57dd295185e415aad7bb5746e854398f7d
3
+ size 470141
universalphysicsinformedneuralnetworkssymbolicdifferentialoperatordiscoverywithsparsedata/f03c5cf1-ca24-426c-a4cf-41fc69f509fd_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4b673ec60cb57207a439e48a3b559700f5baee68071085040a57f61d0c24e6a4
3
+ size 64212
universalphysicsinformedneuralnetworkssymbolicdifferentialoperatordiscoverywithsparsedata/f03c5cf1-ca24-426c-a4cf-41fc69f509fd_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:46c50444dab8b2f53380421600f939f3878f0696bad8ba3b04c2848084048bf7
3
+ size 77338
universalphysicsinformedneuralnetworkssymbolicdifferentialoperatordiscoverywithsparsedata/f03c5cf1-ca24-426c-a4cf-41fc69f509fd_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a403202bab2304c966a0723c0641187ad5da7a79616addbbf5880ed30506c323
3
+ size 1743446
universalphysicsinformedneuralnetworkssymbolicdifferentialoperatordiscoverywithsparsedata/full.md ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Universal Physics-Informed Neural Networks: Symbolic Differential Operator Discovery with Sparse Data
2
+
3
+ Lena Podina $^{*1}$ Brydon Eastman $^{*2}$ Mohammad Kohandel $^{3}$
4
+
5
+ # Abstract
6
+
7
+ In this work we perform symbolic discovery of differential operators in a situation where there is sparse experimental data. This small data regime in machine learning can be made tractable by providing our algorithms with prior information about the underlying dynamics. Physics Informed Neural Networks (PINNs) have been very successful in this regime (reconstructing entire ODE solutions using only a single point or entire PDE solutions with very few measurements of the initial condition). The Universal PINN approach (UPINN) adds a neural network that learns a representation of unknown hidden terms in the differential equation. The algorithm yields both a surrogate solution to the differential equation and a black-box representation of the hidden terms. These hidden term neural networks can then be converted into symbolic equations using symbolic regression techniques like AI Feynman. In order to achieve convergence of the neural networks, we provide our algorithms with (noisy) measurements of both the initial condition as well as (synthetic) experimental data obtained at later times. We demonstrate strong performance of UPINNs even when provided with very few measurements of noisy data in both the ODE and PDE regime.
8
+
9
+ # 1. Introduction
10
+
11
+ Machine learning algorithms, for instance neural networks (NN), are particularly helpful in representing unknown quantities in a data-driven way (Belohlav et al., 1997). NNs with a wide enough hidden layer can be used to approximate any
12
+
13
+ *Equal contribution 1Cheriton School of Computer Science, University of Waterloo, Waterloo, Canada 2OpenAI, San Francisco, USA 3Department of Applied Mathematics, University of Waterloo, Waterloo, Canada. Correspondence to: Lena Podina <lpodina@uwaterloo.ca>, Mohammad Kohandel <kohandel@uwaterloo.ca>.
14
+
15
+ Proceedings of the $40^{th}$ International Conference on Machine Learning, Honolulu, Hawaii, USA. PMLR 202, 2023. Copyright 2023 by the author(s).
16
+
17
+ function (Pinkus, 1999) by tuning its parameters (henceforth 'NN parameters'). Hence, NNs have been used to infer DE parameters or even entire DE models, due to their ability to approximate functions. Many recent applications use NNs augmented with prior knowledge in order to learn underlying DE models from data (Chakraborty, 2020; Raissi et al., 2019; Lu et al., 2021b; Rackauckas et al., 2020; Meng & Karniadakis, 2020; Lu et al., 2021a). However, acquiring sufficient data to fit these values accurately using NNs is difficult. A method that can function in low-data regimes by leveraging the known structure of the model is needed.
18
+
19
+ Two prominent NN-based methods that learn DE models from data are physics-informed neural networks (PINN) (Raissi et al., 2019) and universal differential equations (UDE) (Rackauckas et al., 2020). In UDEs, each unknown component of the DE model is approximated by a NN and a hard DE constraint is employed. That is, the best-fit DE is satisfied at all times during training. However, UDEs are not robust to noise, require a lot of data, and SINDy, as employed in (Rackauckas et al., 2020), does not succeed in finding the true mechanistic model reliably. PINNs assume the form of the true DE and fits its parameters via a soft constraint (relaxing the requirement that the NN should satisfy the best-fit DE exactly), which is added to the NN loss function as an additional loss term referred to as the 'PINN loss'. A drawback of PINNs is that the structure of the DE model must be determined in advance, and there is no way to learn its unknown components using the method as originally proposed. Additionally, as iterative optimization is computationally expensive, PINN loss can fail on stiff DEs (Wang et al., 2021).
20
+
21
+ Our approach, Universal PINNs (UPINNs), bridges the limitations of both PINNs (cannot be used when the structure of the DE is not fully known) (Raissi et al., 2019) and UDEs (not robust to noise and requires lots of data) (Rackauckas et al., 2020). To address this, we replace the hard constraint of the UDE with that of PINN loss, which allows the approach to learn unknown components of the DE model from data. This approach is robust to noise and performs well in low-data regimes. Additionally, using the AI Feynman
22
+
23
+ algorithm (Udrescu & Tegmark, 2020) yields good results in identifying the underlying hidden terms of the DE model.
24
+
25
+ In this paper, we claim the following contributions:
26
+
27
+ 1. We propose a novel training methodology, Universal PINN, which combines PINN loss with the UDE framework to allow a PINN-based approach to learn unknown parts of the DE model from data
28
+ 2. Our method is robust to noise and learns the unknown DE model components to significantly higher accuracy in the Lotka-Volterra model compared to the state of the art (UDE approach)
29
+ 3. UPINNs perform very well in systems biology ODEs, and the Viscous Burgers' equation partial differential equation
30
+ 4. Using a symbolic regression algorithm, we reached better identification of the tested systems than in the original UDE paper
31
+
32
+ # 2. Background
33
+
34
+ As per (Raissi et al., 2019), suppose that the following DE governs a physical process. $u(t,x)$ is an unknown real-valued function of time $(t)$ and position $(x)$ . Its time derivative is related to its value for each tuple $(t,x)$ with a known function $\mathcal{N}$ , and unknown vector of parameters $\theta$ . Furthermore, there are $N$ potentially noisy DE measurements $\{t_i,x_i,u_i\}$ .
35
+
36
+ $$
37
+ \frac {\partial u (t , x)}{\partial t} = \mathcal {N} [ u; \theta ], x \in \Omega , \Omega \in R ^ {D}, t \in [ 0, T ] \quad (1)
38
+ $$
39
+
40
+ Although $\theta$ is required in order to find a numerical or analytical function $u$ that satisfies 1, $\theta$ is unknown in this setup. Using the given data, the PINN method from (Raissi et al., 2019) can estimate $\theta$ and $u$ simultaneously. Its key component is a neural network $U$ , which predicts $u$ given any tuple $(t,x)$ . The following loss function is used to train $U$ :
41
+
42
+ $$
43
+ \mathcal {L} = \frac {1}{N} \sum_ {i = 1} ^ {N} | U (t ^ {i}, x ^ {i}) - u ^ {i} | + \frac {1}{M} \sum_ {j = 1} ^ {M} \left| \frac {d U}{d t _ {j}} - \mathcal {N} [ u; \theta ] \right| \tag {2}
44
+ $$
45
+
46
+ where $\frac{dU}{dt_j}$ is auto-differentiated through the neural network and evaluated at time $t_j$ and position $x_j$ . The first term penalizes $U$ for making predictions that do not match the DE at a predefined set of $M$ collocation points $\{t_j, x_j\}$ . The second term penalizes $U$ for making predictions that do
47
+
48
+ not match the data. Note that the second term contains $\theta$ , which allows parameter estimate $\hat{\theta}$ to be updated using its gradient with respect to $\mathcal{L}$ . At every optimization iteration, the parameters of $U$ are updated along with $\hat{\theta}$ .
49
+
50
+ A UDE (Rackauckas et al., 2020) is a DE which is defined in part using universal approximators, e.g. a neural network. These NNs can be used to approximate unknown components of $\mathcal{N}$ . We will assume that possibly noisy data $\{t_i, x_i, u_i\}$ is available from Eq. 1. Suppose that $\mathcal{N}$ is a function $g$ composed of $k$ unknown functions $h_i$ and known parameters $\theta$ :
51
+
52
+ $$
53
+ \mathcal {N} [ u; \theta ] = g (u, h _ {1} (u; \theta), \dots , h _ {k} (u; \theta); \theta) \tag {3}
54
+ $$
55
+
56
+ In (Rackauckas et al., 2020), the $h_i$ terms are approximated by a single neural network $H$ with $k$ outputs and fit using iterative optimization such as Adam (Kingma & Ba, 2014) or gradient descent (Bishop & Nasrabadi, 2006). Since Eq. (1) always holds, the loss function only consists mean squared error between the DE solution and the data. Note that with any particular approximation $H$ , the DE (1) is defined fully and $u$ can be solved for numerically. Hence, the training loop for UDEs involves numerically solving Eq. (1), computing the error between the solution and the data, and updating $H$ to better approximate the unknown components of $\mathcal{N}$ . At the end of training, $H$ will represent the unknown component of $\mathcal{N}$ and the numerical solution of Eq. (1) will yield $u$ that matches the solution of the true DE.
57
+
58
+ Symbolic regression is a general technique of finding a model that fits data while balancing the simplicity of the model with its accuracy. This problem has been solved with various genetic algorithms (see, among others, (McKay et al., 1995; Schmidt & Lipson, 2009)) but since this method is computationally expensive, newer techniques are becoming more popular. For example, AI Feynman (Udrescu & Tegmark, 2020) leverages NNs and symmetry, units, compositionality, etc. and finally returns a list of potential models ranked by error and complexity. Some work (Valipour et al., 2021; Kamienny et al., 2022) makes use of transformers to find the correct functional form. In our work, we only use them at the final stage after our method has learned an approximate representation of the missing components.
59
+
60
+ # 3. Methods
61
+
62
+ Our proposed method, Universal PINNs, is a modification of the PINNs to discover the functional form of an unknown term within a differential equation. Suppose $\vec{u} (\vec{x},t)\in \mathbb{R}^m$ for $\vec{x}\in \mathbb{R}^d$ . Let $\mathcal{N}$ be a (potentially non
63
+
64
+ linear) differential operator, then consider time $t$ in the domain $[0,T]\subset \mathbb{R}$ along with a $d$ dimensional, bounded spatial domain $\Omega \subset \mathbb{R}^d$ where $\partial \Omega$ denotes the boundary of $\Omega$ . Notably, if $\mathcal{N}$ contains any derivatives, we assume that those derivatives are with respect to the spatial variables only. We then consider problems of the form
65
+
66
+ $$
67
+ \frac {d}{d t} \vec {u} (\vec {x}, t) = \mathcal {N} [ \vec {u} ] (\vec {x}, t), \quad t \in [ 0, T ], \quad \vec {x} \in \Omega
68
+ $$
69
+
70
+ subject to initial condition
71
+
72
+ $$
73
+ \vec {u} (\vec {x}, 0) = \vec {u} _ {0} (\vec {x}), \quad \vec {x} \in \Omega
74
+ $$
75
+
76
+ and boundary conditions
77
+
78
+ $$
79
+ \beta [ \vec {u} ] (\vec {x}, t) = 0, \quad \vec {x} \in \partial \Omega , \quad t \in [ 0, T ]
80
+ $$
81
+
82
+ where $\beta$ is a (potentially non-linear) differential operator whose derivatives are only with respect to the spatial variables.
83
+
84
+ Further, suppose
85
+
86
+ $$
87
+ \mathcal {N} [ \vec {u} ] (\vec {x}, t) = \mathcal {N} _ {K} [ \vec {u} ] (\vec {x}, t) + \mathcal {F} [ \vec {u} ] (\vec {x}, t)
88
+ $$
89
+
90
+ where $\mathcal{N}_K$ is some differential operator with known functional form and $\mathcal{F}$ represents some unknown, target differential operator. Similarly, suppose $\beta = \beta_K + \mathcal{B}$ for some known $\beta_K$ and some unknown $\mathcal{B}$ .
91
+
92
+ Finally, one can consider $\Omega = \varnothing$ , in which case the underlying differential law is governed by an ordinary differential equation (ODE). In this situation, there is no boundary condition and so no need for $\beta$ (or, equivalently, $\beta$ is the empty function).
93
+
94
+ Suppose we have $n$ data points $D = \{(t_k, \vec{x}_k, \vec{u}_k)\}_{k=0}^{n-1}$ where $\vec{u}_k = \vec{u}(t_k, \vec{x}_k) + \epsilon_k$ where $\epsilon_k$ is some noise term (potentially $\epsilon_k = 0$ ). We will use this measured data to fit the parameters of (up to) three neural networks. The first network, $F(\vec{u}; \theta_F)$ , will approximate the target differential operator $\mathcal{F}[\vec{u}]$ by using a neural network with parameters $\theta_F$ . The second network, $U(\vec{x}, t; \theta_U)$ , will approximate the value of $\vec{u}(x, t)$ by a neural network with parameters $\theta_U$ . The third network, $B(\vec{u}; \theta_B)$ , will approximate the value of $\mathcal{B}[\vec{u}]$ , the unknown target for the boundary condition, with a neural network parameterized by $\theta_B$ . To fit these networks, we consider another two sets of collocation points: these sets are $X_P = \{(\vec{x}_k, t_k)\}_{k=0}^{n_P-1} \subset (\Omega \setminus \partial \Omega) \times (0, T]$ and $X_B = \{(\vec{x}_k, t_k)\}_{k=0}^{n_B-1} \subset (\partial \Omega) \times (0, T]$ . These sets correspond to locations in the space-time domain where we enforce that our network $U$ satisfies the underlying differential equation (in the case of $X_P$ ) and the boundary conditions (in the case of $X_B$ ).
95
+
96
+ To calculate the gradients for fitting these networks, we consider the loss function
97
+
98
+ $$
99
+ L \left(\theta_ {U}, \theta_ {B}, \theta_ {F}\right) = L _ {M} \left(\theta_ {U}\right) + L _ {B} \left(\theta_ {U}, \theta_ {B}\right) + L _ {P} \left(\theta_ {U}, \theta_ {F}\right).
100
+ $$
101
+
102
+ The first component of the loss is the MSE loss. This loss is the difference in MSE between the measurement value of $\vec{u} \approx \vec{u}_k$ from the input data with the neural network approximation of $\vec{u} \approx U(\vec{x}_k, t_k)$ , evaluated at the same space-time location and is given by
103
+
104
+ $$
105
+ L _ {M} \left(\theta_ {U}\right) = \frac {1}{n} \sum_ {\left(\vec {x} _ {k}, t _ {k}, \vec {u} _ {k}\right) \in D} \left(U \left(\vec {x} _ {k}, t _ {k}; \theta_ {U}\right) - \vec {u} _ {k}\right) ^ {2}.
106
+ $$
107
+
108
+ The second component of the loss is the boundary loss. This loss is the mean squared value of the approximated value of the boundary condition and is given by
109
+
110
+ $$
111
+ L _ {B} \left(\theta_ {U}, \theta_ {B}\right) =
112
+ $$
113
+
114
+ $$
115
+ \frac {1}{n _ {B}} \sum_ {(\vec {x} _ {k}, t _ {k}) \in X _ {B}} \left(\beta_ {K} [ U ] (\vec {x} _ {k}, t _ {k}; \theta_ {U}) + B (U (\vec {x} _ {k}, t _ {k}; \theta_ {U}); \theta_ {B})\right) ^ {2}
116
+ $$
117
+
118
+ The final component of the loss is the PINN loss. This loss is the mean squared error between the value $U_{t}$ , the time derivative of the neural network approximation of $U$ , and the value $\mathcal{N}_K[U] + F(U)$ .
119
+
120
+ $$
121
+ L _ {P} (\theta_ {U}, \theta_ {F}) =
122
+ $$
123
+
124
+ $$
125
+ \begin{array}{l} \frac {1}{n _ {P}} \sum_ {(\vec {x} _ {k}, t _ {k}) \in X _ {P}} \left(\mathcal {N} _ {\mathcal {K}} [ U ] (\vec {x} _ {k}, t _ {k}; \theta_ {U}) + F (U (\vec {x} _ {k}, t _ {k}; \theta_ {U}); \theta_ {F}) \right. \\ - U _ {t} \left(\vec {x} _ {k}, t _ {k}; \theta_ {U}\right)) ^ {2}. \\ \end{array}
126
+ $$
127
+
128
+ This loss function is quite similar to the loss function for PINNs given in (Raissi et al., 2019), however here we insert two additional neural networks into the loss function corresponding to the unknown parts of the underlying dynamics in the boundary conditions and the differential equation. To compensate for these additional parameters, we extend the first component of the loss to include more than just initial data (but solution data as well). In this way, $D$ could contain data from the initial condition, data from the boundary, or data from the interior of the domain.
129
+
130
+ Practically, one way to select $X_P$ is to simply choose $n_P$ and use Latin hypercube sampling to select $n_P$ points in $(\Omega \setminus \partial \Omega) \times (0, T]$ . A similar construction works for selecting $X_B$ . In this way, we are sampling the domain in a space-filling manner.
131
+
132
+ The architecture of the fully-connected neural networks is as follows, for each of our models examined in Results:
133
+
134
+ 1. Burgers: two inputs for $t$ and $x$ followed by scaling layer; 8 hidden layers of 20 units for the surrogate network and the hidden component network; sigmoid activation
135
+ 2. Lotka-Volterra and Apoptosis model: one input for $t$ followed by a scaling layer; 2 hidden layers of 64 units for the surrogate solution; 2 hidden layers of 16 units for the hidden component approximation; sigmoid activation
136
+
137
+ # 4. Results
138
+
139
+ To demonstrate our approach, we show high accuracy in identifying the hidden terms in three test-cases: the Lotka-Volterra equations (an ODE model), and the viscous Burgers' equation (a parabolic PDE model), and a model for cell apoptosis (an ODE model). Additionally, we show that AI Feynman is able to correctly identify the functional form of hidden terms within the Lotka-Volterra model from the output of our model.
140
+
141
+ # 4.1. Lotka-Volterra System
142
+
143
+ We begin our analysis by testing our method on the Lotka-Volterra (LV) model (Berryman, 1992) of predator-prey interactions. The DE is formulated as follows:
144
+
145
+ $$
146
+ \frac {d x}{d t} = \alpha x - \beta x y
147
+ $$
148
+
149
+ $$
150
+ \frac {d y}{d t} = - \delta y + \gamma x y.
151
+ $$
152
+
153
+ We take the known portion of the differential equation as $\mathcal{N}_{\mathcal{K}}[U] = [\alpha x, -\delta y]$ for known parameters $\alpha$ and $\delta$ , and seek to learn $F = [F_{1}, F_{2}] \approx [-\beta x y, \gamma x y]$ from data only, without knowing the target form and without knowing $\beta$ and $\gamma$ .
154
+
155
+ To generate the synthetic data, $\alpha, \beta, \gamma, \delta$ were fixed at (1.3, 0.9, 0.8, 1.8) respectively, with initial conditions at $(x_0, y_0) = (0.44249296, 4.6280594)$ just as in (Rackauckas et al., 2020). The time interval was chosen as [0, 3] and stayed the same throughout every LV experiment.
156
+
157
+ An ODE solver was used to generate data satisfying the LV equations. This yields a set of points $\{t_i, x_i, y_i\}$ . Then, Gaussian noise is added to each $x_i$ and $y_i$ . Given a particular noise level $\epsilon$ , Gaussian noise was added to the data as follows:
158
+
159
+ $$
160
+ \left(x _ {i}\right) _ {\text {n o i s e}} = x _ {i} + \epsilon \cdot \bar {x} \cdot N (0, 1)
161
+ $$
162
+
163
+ $$
164
+ \left(y _ {i}\right) _ {\text {n o i s e}} = y _ {i} + \epsilon \cdot \bar {y} \cdot N (0, 1)
165
+ $$
166
+
167
+ where $\bar{x}$ denotes the element-wise mean of $x_{i}$ over all $i$ (similarly for $y$ ).
168
+
169
+ First, we demonstrate our approach on noise-free data (Table 1) and data with $\epsilon = 5\times 10^{-3}$ noise (Table 2) for various values of $n$ (number of data points) and $n_P$ (number of collocation points). We want to show how the hard-to-acquire data can be augmented by taking more collocation points which require no experiments/measurements and come at only the cost of increased computing power. We see that, in contrast to a standard PINN approach, we need to provide more data than just the initial condition. However, even with very sparse measurement data, we can acquire a good discovery by only increasing the number of collocation points.
170
+
171
+ The additional benefit gained from increasing the collocation points is only realized when there is already ample enough experimental data for the algorithm to leverage.
172
+
173
+ Table 1. MSE between $F$ and the true hidden target after training for various values of $n$ and ${n}_{P} -$ noiseless data
174
+
175
+ <table><tr><td>nPn</td><td>102</td><td>103</td><td>104</td></tr><tr><td>1</td><td>2 × 101</td><td>2 × 101</td><td>2 × 101</td></tr><tr><td>5</td><td>9 × 10-4</td><td>1 × 10-3</td><td>9 × 10-4</td></tr><tr><td>10</td><td>2 × 10-4</td><td>4 × 10-5</td><td>5 × 10-6</td></tr></table>
176
+
177
+ Table 2. MSE between $F$ and the true hidden target after training for various values of $n$ and ${n}_{P} -$ noisy $\left( {\epsilon = 5 \times {10}^{-3}}\right)$ data
178
+
179
+ <table><tr><td>nPn</td><td>102</td><td>103</td><td>104</td></tr><tr><td>1</td><td>2 × 101</td><td>2 × 101</td><td>2 × 101</td></tr><tr><td>5</td><td>6 × 10-2</td><td>4 × 10-3</td><td>5 × 10-3</td></tr><tr><td>10</td><td>1 × 10-3</td><td>6 × 10-4</td><td>8 × 10-4</td></tr></table>
180
+
181
+ Next, we compare UPINN performance to the UDE method. We test the two methods on noiseless sparse data (1) and on noisy data (Fig 2). The error is computed as a mean squared error (MSE) taken with respect to the true interaction. At minimal noise level, the UDE approach and UPINN approach perform similarly and for the densest data UDEs slightly outperform UPINNs. Although increasing either noise or sparsity degrades the performance of both methods, the UPINN method consistently attains a lower MSE compared to the UDE method as noise or sparsity increases.
182
+
183
+ Figures 6 and 9 show the surrogate solution and hidden terms as recovered by the UDE and UPINN methods. The noise level of the noisy data was set at 0.1 and, for the noiseless sparse data, there were 5 points each 0.6 units apart. It is clear that UPINNs are quite robust to noise and perform well in low-data regimes. The UDE approach performs reasonably on sparse data, but is not robust to noise.
184
+
185
+ Finally, AI Feynman symbolic regression is run on the neural network output from both our approach and the UDE approach, in order to find the best functional form. These results are presented in Table 4. A dash indicates AI Feynman did not recover the functional form $Cxy$ . The best performance between the two methods is bolded. In cases of both sparse and noisy data, AI Feynman correctly recovers the hidden interaction terms more often for our method than it does for the UDE method. If a formula is recovered for both methods, the one recovered for the PINN method is often more accurate.
186
+
187
+ The terms $\gamma xy$ and $-\beta xy$ in the LV equations correspond to the predator's uptake function in the ecological model.
188
+
189
+ ![](images/ee4f4cbaba71b7a68106f600e1f63fcdab85a87075fc8c5d6ff5899565692fb2.jpg)
190
+ Figure 1. Sparse data regime
191
+
192
+ ![](images/79a1c28d6a15c398a862ca9f529754761b285d1d4270b37fb2d95725323df4a1.jpg)
193
+ Figure 2. Noisy data regime
194
+
195
+ This represents the predators' feeding habits as a function of prey population and its resulting effect on both the prey population and the predator's population. The actual form of these functions can take various forms in predator-prey models (see, for instance, (Harrison, 1979; Bolger et al., 2020)). While we initially modelled this as two unknown, decoupled functions $F_{1}$ and $F_{2}$ and learned them independently, we could also have modeled them by a single function with
196
+
197
+ ![](images/04b7f38d399e0a055649f27ccabee19d9ebefaed34fefa2a4260cb2fdc151fe1.jpg)
198
+
199
+ ![](images/ec3e6f843a3ba572a6b03908626245e8762c632b07d2abcb623e28c6f06b600c.jpg)
200
+ Figure 4. Noisy data regime. Reconstructed trajectory (top) and learned hidden interaction (bottom).
201
+
202
+ ![](images/17b7fb7556d43587fbd4057dc9a3e950a9708f25502ffc726a1a63b9988c5759.jpg)
203
+
204
+ ![](images/406e1f32d8dcfe504f7d545cfc330f24842c3d3dfd235062d601daad58e85b2d.jpg)
205
+ Figure 3. Mean squared error (MSE) of the recovery of the true interaction, comparing between the UPINN and UDE method. The spacing parameter determines how much time passes between datapoints, but the overall time interval [0, 3] remains the same.
206
+ Figure 5. Sparse data regime. Reconstructed trajectory (top) and learned hidden interaction (bottom).
207
+ Figure 6. UDE method performance on the Lotka-Volterra model
208
+
209
+ an additional learned parameter as a scaling factor. That is, we could take $F_{1} = -\phi F_{2}$ and then only explicitly learn $F_{2}$ and a single parameter $\phi$ . This results in regressions that are near identical to the ones presented above, but showcases an important modelling methodology that our method is amenable to and, for more complicated models than LV, may be necessary in order to achieve a high-quality
210
+
211
+ ![](images/2f157c8fa20da004bcd830518abc0a18c60750cc9328d5706d1964950a5ae4c1.jpg)
212
+
213
+ ![](images/d612d5f920e7bedad0bbfb6f38738ea218a0e45795c497bb340bf413d5e2fe1a.jpg)
214
+ Figure 7. Noisy data regime. Reconstructed trajectory (top) and learned hidden interaction (bottom).
215
+
216
+ ![](images/50797eec77a2804f45acd16823871f8f2532b89776e0f3390cbc1c792ff3acda.jpg)
217
+
218
+ ![](images/1684701a38f5df6e24e01edd10d575f925c24b4df7167a73475717657dfa200c.jpg)
219
+ Figure 8. Sparse data regime. Reconstructed trajectory (top) and learned hidden interaction (bottom).
220
+ Figure 9. UPINN performance on the Lotka-Volterra model
221
+
222
+ regression.
223
+
224
+ # 4.2. Viscous Burger's Equation
225
+
226
+ Finally, our method is easily applied to PDEs (as in the original PINN implementation). Here we present the discovery
227
+
228
+ Table 3. Coefficients (with MSE) recovered by AI Feynman from the approximations of $F_{1}$ , comparing over datasets (rows) and method of finding $F_{1}$ (columns). The true coefficient is -0.9.
229
+
230
+ <table><tr><td>spacing</td><td>noise level</td><td>F1(ude)</td><td>F1(UPINN)</td></tr><tr><td>0.1</td><td>0</td><td>-0.901 (2.8e-7)</td><td>-</td></tr><tr><td>0.2</td><td>0</td><td>-</td><td>-</td></tr><tr><td>0.3</td><td>0</td><td>-</td><td>-0.897 (4e-6)</td></tr><tr><td>0.4</td><td>0</td><td>-</td><td>-0.888 (8.2e-5)</td></tr><tr><td>0.5</td><td>0</td><td>-</td><td>-0.889 (8.9e-5)</td></tr><tr><td>0.6</td><td>0</td><td>-0.892 (4e-3)</td><td>-0.890 (1e-5)</td></tr><tr><td>0.1</td><td>8e-3</td><td>-9.25 (1.8e-3)</td><td>-0.906 (1e-5)</td></tr><tr><td>0.1</td><td>1e-2</td><td>-</td><td>-0.911 (3.45e-5)</td></tr><tr><td>0.1</td><td>3e-2</td><td>-</td><td>-0.960 (1e-3)</td></tr><tr><td>0.1</td><td>5e-2</td><td>-</td><td>-</td></tr><tr><td>0.1</td><td>8e-2</td><td>-</td><td>-</td></tr><tr><td>0.1</td><td>1e-1</td><td>-</td><td>-</td></tr></table>
231
+
232
+ Table 4. Coefficients (with MSE) recovered by AI Feynman from the approximations $F_{2}$ , comparing over datasets (rows) and method of finding $F_{2}$ (columns). The true coefficient is 0.8 for $F_{2}$ .
233
+
234
+ <table><tr><td>spacing</td><td>noise level</td><td>F2 (UDE)</td><td>F2 (UPINN)</td></tr><tr><td>0.1</td><td>0</td><td>0.802 (1.1e-6)</td><td>0.797 (2.5e-6)</td></tr><tr><td>0.2</td><td>0</td><td>0.797 (3.4e-6)</td><td>0.799 (3.8e-7)</td></tr><tr><td>0.3</td><td>0</td><td>-</td><td>0.798 (1.9e-6)</td></tr><tr><td>0.4</td><td>0</td><td>-</td><td>0.797 (5.2e-6)</td></tr><tr><td>0.5</td><td>0</td><td>0.760 (1e-3)</td><td>-</td></tr><tr><td>0.6</td><td>0</td><td>-</td><td>0.800 (1e-32)</td></tr><tr><td>0.1</td><td>8e-3</td><td>-</td><td>0.798 (3e-5)</td></tr><tr><td>0.1</td><td>1e-2</td><td>0.791 (2.3e-5)</td><td>0.777 (1.5e-4)</td></tr><tr><td>0.1</td><td>3e-2</td><td>-</td><td>0.777 (1.5e-4)</td></tr><tr><td>0.1</td><td>5e-2</td><td>-</td><td>0.740 (1.1e-3)</td></tr><tr><td>0.1</td><td>8e-2</td><td>-</td><td>-</td></tr><tr><td>0.1</td><td>1e-1</td><td>0.887 (2e-3)</td><td>-</td></tr></table>
235
+
236
+ of both the solution to the PDE where the underlying hidden dynamics of the operator were partially hidden. This reconstruction used only noisy $(\epsilon = 5\times 10^{-3})$ data obtained from two time points (the initial condition, $t = 0$ , and a later time at $t = 0.5$ ). While this method can be used to discover the form of the boundary condition as well, here we assume that the homogeneous Dirichlet boundary conditions are known. The PDE in question is
237
+
238
+ $$
239
+ \frac {\partial u}{\partial t} = - u \frac {\partial u}{\partial x} + \nu \frac {\partial^ {2} u}{\partial x ^ {2}}, \nu = \frac {1}{1 0 0 0 \pi}, u (x, 0) = - \sin (\pi x)
240
+ $$
241
+
242
+ Here we took $\mathcal{N}_{\mathcal{K}} = \nu u_{xx}$ and let the algorithm learn the hidden term $-u u_x$ . To do this, we gave the $F$ network $u$ , $u_x$ , and $u_t$ as inputs. This represents an inductive prior where we are assuming that the hidden term depends on first order and lower derivatives of the solution. In our approach, such a prior is necessary (that is, the algorithm cannot learn what order of derivatives to include or not include, it can merely choose which inputs presented to it
243
+
244
+ to utilize). For collocation data we used $n_P = 10^4$ and $n_B = 10^2$ points sampled from the appropriate parts of the domain $[-1,1] \times [0,1]$ via Latin hypercube sampling. The PDE solution was reconstructed with MSE of $3 \times 10^{-4}$ and the hidden term was discovered with MSE of $2 \times 10^{-2}$ . The resulting solution is visualized in Figure 10.
245
+
246
+ ![](images/5412e42d676d5af7c0a282fad639e79c67fa072f82870597376563af24f82fec.jpg)
247
+ Figure 10. The reconstructed solution of Burgers' equation. The two vertical dashed white lines indicate the noisy experimental data that were sampled for the algorithm.
248
+
249
+ # 4.3. Cell Apoptosis Model
250
+
251
+ We also test the method on a biological application, which is the Q1 cell apoptosis model from (Wee & Aguda, 2006). This is an ODE with three variables, serine-threonine kinase $Akt_{s}$ (active Akt), $Akt$ (inactive Akt) and tumour suppressor protein $p53$ . $p53$ promotes cell apoptosis, or programmed cell death, and Akt inhibits it. Here, we only focus on the system of ODEs and learning its nonlinear terms. We refer readers to the paper for the biological motivation and discussion. We denote the concentrations of $p53$ , active Akt and inactive Akt as $x$ , $y$ , $z$ respectively.
252
+
253
+ $$
254
+ v _ {0} = k _ {0}
255
+ $$
256
+
257
+ $$
258
+ v _ {1} = k _ {1} \cdot z \cdot (j _ {1} + y)
259
+ $$
260
+
261
+ $$
262
+ v _ {m 1} = \frac {k _ {m 1} \cdot y}{j _ {m 1} + y}
263
+ $$
264
+
265
+ $$
266
+ v _ {2} = \frac {k _ {2} \cdot y \cdot x}{j _ {2} + x}
267
+ $$
268
+
269
+ $$
270
+ v _ {m 3} = \frac {k _ {m 3} \cdot x \cdot y}{j _ {m 3} + y}
271
+ $$
272
+
273
+ $$
274
+ \frac {d x}{d t} = v _ {0} - v _ {2} - k _ {d} \cdot x
275
+ $$
276
+
277
+ $$
278
+ \frac {d y}{d t} = v _ {1} - v _ {m 1} - v _ {m 3}
279
+ $$
280
+
281
+ $$
282
+ \frac {d z}{d t} = \frac {- d y}{d t}
283
+ $$
284
+
285
+ All parameter values were taken from the paper. With the initial condition $(x,y,z) = (0.248,0.0973,0.0027)$ and 30 noiseless datapoints, both the $v_{1}$ and $v_{2}$ interactions (including the parameters) were learned to a high degree of accuracy. In Figures 11 and 12 it can be seen that although the general shape does not match the true interaction $100\%$ , the mean squared error between the true interaction and the learned function is in fact very small (on the order of $10^{-4}$ ) and the surrogate solution fits the data very well. This case study reveals a key trait of the method – in some DE's, the hidden interaction is not unique given a particular trajectory and data. Furthermore, when the derivatives of the trajectory are very small (as can be seen by the saturation past $t = 100$ ) the method can have difficulty learning the hidden term. As is done in (Yazdani et al., 2020), if this method were augmented to handle very small and very large values through scaling, more accurate learning of the interaction would be possible.
286
+
287
+ # 5. Conclusion
288
+
289
+ In conclusion, the Universal PINN approach is able to recover, with a great degree of accuracy, the symbolic functional form of hidden terms within a differential operator using very sparse measurements of noisy data. This approach is robust to both noise and sparsity of the data by increasing the number of collocation points (an operation that doesn't require any additional experimentation, just stronger compute capacities). This approach can be applied to discovering the functional form of an unknown ordinary differential equation (ODE) as well as both the functional form of a partial differential operator in a partial differential equation (PDE) and unknown terms in the boundary condition of a PDE. Although PINNs have been noted to perform sub-optimally on stiff equations without modification (Ji
290
+
291
+ ![](images/0b527775cc6f7d20f542582a4c2fca81abf3534dbd15409961ae8e38ed0689b3.jpg)
292
+
293
+ ![](images/c4a65b029cc016276ca2b66b8c9c29c4b669e23b52f314cf512c1c5b44e4f318.jpg)
294
+ Figure 11. Learning the $v_{1}$ term using UPINNs. Reconstructed trajectory (top) and learned hidden interaction (bottom).
295
+
296
+ ![](images/f5b31025daa4baabd5c83934431004c58627f9d4b0945136581a8bf4bc1ef827.jpg)
297
+
298
+ ![](images/d01c47cdc78d2e4f8dc5ef097a75dd699eae3cdb06fcd6d7782ba4be561b39a8.jpg)
299
+ Figure 12. Learning the $v_{2}$ term using UPINNs. Reconstructed trajectory (top) and learned hidden interaction (bottom).
300
+
301
+ et al., 2021; Moya & Lin, 2021), we have noted promising results in this direction. However, more investigation is needed.
302
+
303
+ # Software and Data
304
+
305
+ A GitHub link will be included with the "camera-ready" version of the manuscript.
306
+
307
+ # References
308
+
309
+ Belohlav, Z., Zamostny, P., Kluson, P., and Volf, J. Application of random-search algorithm for regression analysis of catalytic hydrogenations. The Canadian Journal of Chemical Engineering, 75(4):735-742, 1997.
310
+ Berryman, A. A. The orgins and evolution of predator-prey theory. Ecology, 73(5):1530-1535, 1992.
311
+ Bishop, C. M. and Nasrabadi, N. M. Pattern recognition and machine learning, volume 4. Springer, 2006.
312
+ Bolger, T., Eastman, B., Hill, M., and Wolkowicz, G. A predator-prey model in the chemostat with holling type ii response function. Mathematics in Applied Sciences and Engineering, 1(4):333-354, 2020.
313
+ Chakraborty, S. Transfer learning based multi-fidelity physics informed deep neural network. CoRR, abs/2005.10614, 2020. URL https://arxiv.org/abs/2005.10614.
314
+ Harrison, G. W. Global stability of predator-prey interactions. Journal of Mathematical Biology, 8(2):159-171, 1979.
315
+ Ji, W., Qiu, W., Shi, Z., Pan, S., and Deng, S. Stiff-pinn: Physics-informed neural network for stiff chemical kinetics. The Journal of Physical Chemistry A, 125(36): 8098-8106, 2021.
316
+ Kamienny, P.-A., d'Ascoli, S., Lample, G., and Charton, F. End-to-end symbolic regression with transformers. arXiv preprint arXiv:2204.10532, 2022.
317
+ Kingma, D. P. and Ba, J. Adam: A method for stochastic optimization. arXiv preprint arXiv:1412.6980, 2014.
318
+ Lu, J., Bender, B., Jin, J. Y., and Guan, Y. Deep learning prediction of patient response time course from early data via neural-pharmacokinetic/pharmacodynamic modelling. Nature machine intelligence, 3(8):696-704, 2021a.
319
+ Lu, J., Deng, K., Zhang, X., Liu, G., and Guan, Y. Neural-ode for pharmacokinetics modeling and its advantage to alternative machine learning models in predicting new dosing regimens. Iscience, 24(7):102804, 2021b.
320
+
321
+ McKay, B., Willis, M. J., and Barton, G. W. Using a tree structured genetic algorithm to perform symbolic regression. In First international conference on genetic algorithms in engineering systems: innovations and applications, pp. 487-492. IET, 1995.
322
+ Meng, X. and Karniadakis, G. E. A composite neural network that learns from multi-fidelity data: Application to function approximation and inverse pde problems. Journal of Computational Physics, 401:109020, 2020.
323
+ Moya, C. and Lin, G. Dae-pinn: A physics-informed neural network model for simulating differential-algebraic equations with application to power networks. arXiv preprint arXiv:2109.04304, 2021.
324
+ Pinkus, A. Approximation theory of the mlp model in neural networks. Acta Numerica, 8:143-195, 1999. doi: 10.1017/S0962492900002919.
325
+ Rackauckas, C., Ma, Y., Martensen, J., Warner, C., Zubov, K., Supekar, R., Skinner, D., Ramadhan, A., and Edelman, A. Universal differential equations for scientific machine learning. arXiv preprint arXiv:2001.04385, 2020.
326
+ Raissi, M., Perdikaris, P., and Karniadakis, G. Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations. Journal of Computational Physics, 378:686-707, 2019. ISSN 0021-9991. doi: https://doi.org/10.1016/j.jcp.2018.10.045. URL https://www.sciencedirect.com/science/article/pii/S0021999118307125.
327
+ Schmidt, M. and Lipson, H. Distilling free-form natural laws from experimental data. Science, 324(5923):81-85, 2009. doi: 10.1126/science.1165893. URL https://www.science.org/doi/abs/10.1126/science.1165893.
328
+ Udrescu, S.-M. and Tegmark, M. Ai feynman: A physics-inspired method for symbolic regression. Science Advances, 6(16):eaay2631, 2020.
329
+ Valipour, M., Panju, M., You, B., and Ghodsi, A. Symbolicgpt: A generative transformer model for symbolic regression. In Preprint Arxiv, 2021. URL https://arxiv.org/abs/2106.14131. Under Review.
330
+ Wang, S., Teng, Y., and Perdikaris, P. Understanding and mitigating gradient flow pathologies in physics-informed neural networks. SIAM Journal on Scientific Computing, 43(5):A3055-A3081, 2021.
331
+ Wee, K. B. and Aguda, B. D. Akt versus p53 in a network of oncogenes and tumor suppressor genes regulating cell survival and death. *Biophysical journal*, 91(3):857-865, 2006.
332
+
333
+ Yazdani, A., Lu, L., Raissi, M., and Karniadakis, G. E. Systems biology informed deep learning for inferring parameters and hidden dynamics. PLoS computational biology, 16(11):e1007575, 2020.
universalphysicsinformedneuralnetworkssymbolicdifferentialoperatordiscoverywithsparsedata/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de0506fbac46fab28e32079065503deb0bd1a647cc79549b8a0ef9c1254d9107
3
+ size 476689
universalphysicsinformedneuralnetworkssymbolicdifferentialoperatordiscoverywithsparsedata/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4fefc70c9d09bdc3e041d276a6cb30c3c16787296aeafaa07a8a572956ed0e57
3
+ size 418978
unleashingmaskexploretheintrinsicoutofdistributiondetectioncapability/08cb0f55-471d-41a0-89ff-3fe0bf0a00cb_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ee4e5bc22d83837754decf9104a54dfeba507c7801e6e630d8ebfecd9dc2a23
3
+ size 252222
unleashingmaskexploretheintrinsicoutofdistributiondetectioncapability/08cb0f55-471d-41a0-89ff-3fe0bf0a00cb_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2e18050eec0ca23d49ac4598bc331f0c80cf2f950b1bf42d332c53a9f6ed96a
3
+ size 303237
unleashingmaskexploretheintrinsicoutofdistributiondetectioncapability/08cb0f55-471d-41a0-89ff-3fe0bf0a00cb_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2dbe39e9909d63f9b5abb9b581b2b1ebba8afe8dc210dd998de75fd5ced07834
3
+ size 9758487
unleashingmaskexploretheintrinsicoutofdistributiondetectioncapability/full.md ADDED
The diff for this file is too large to render. See raw diff
 
unleashingmaskexploretheintrinsicoutofdistributiondetectioncapability/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb347ea3785e1b986af59d80cdf223d0e9dec4798e6fd43c4c46135ab4e6c446
3
+ size 4475744
unleashingmaskexploretheintrinsicoutofdistributiondetectioncapability/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:839027d61013b1f021f2e2d011b6ef5067cf365e55cbdd8c90cc33fa54e1064d
3
+ size 1205241
unlockingslotattentionbychangingoptimaltransportcosts/eb0bd92d-7406-4b0e-941b-c21a4d92e3ae_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aa0b6f2dc5a8c1c800b390d64a2e0a82d29fe9777a8ddb4803cf0f4ec60c81ce
3
+ size 136083
unlockingslotattentionbychangingoptimaltransportcosts/eb0bd92d-7406-4b0e-941b-c21a4d92e3ae_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:74193e446c276c94bba0d441e3cab2e130f6891a64fb7c2d85084e6b61bcded2
3
+ size 161512
unlockingslotattentionbychangingoptimaltransportcosts/eb0bd92d-7406-4b0e-941b-c21a4d92e3ae_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9833bd8a4fb4ac4fd3ffa93f52a0c3ab4701d978707f161198aa875f005e7133
3
+ size 4908130
unlockingslotattentionbychangingoptimaltransportcosts/full.md ADDED
@@ -0,0 +1,548 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Unlocking Slot Attention by Changing Optimal Transport Costs
2
+
3
+ Yan Zhang $^{*1}$ David W. Zhang $^{*2}$ Simon Lacoste-Julien $^{134}$ Gertjan J. Burghouts $^{5}$ Cees G. M. Snoek $^{2}$
4
+
5
+ # Abstract
6
+
7
+ Slot attention is a powerful method for object-centric modeling in images and videos. However, its set-equivalence limits its ability to handle videos with a dynamic number of objects because it cannot break ties. To overcome this limitation, we first establish a connection between slot attention and optimal transport. Based on this new perspective we propose MESH (Minimize Entropy of Sinkhorn): a cross-attention module that combines the tiebreaking properties of unregularized optimal transport with the speed of regularized optimal transport. We evaluate slot attention using MESH on multiple object-centric learning benchmarks and find significant improvements over slot attention in every setting.
8
+
9
+ # 1. Introduction
10
+
11
+ Suppose we have an image containing two cats and one dog. Given a query like [cat, cat, dog], our task is to provide instance-specific information for each query element, such as their positions in the image. When constructing a neural network to solve this problem, cross-attention is a natural choice to relate the queries to our image (Vaswani et al., 2017; Wei et al., 2020). With such a model, the dog can be located perfectly, but our two queries for the cats inevitably end up with an undesirable result: the average of the two cats' positions. The problem is that with our model, multiple copies of the same query element must have the same result (Zhang et al., 2022); it is impossible to receive different answers for the same query, even if the context makes it obvious what is desired.
12
+
13
+ Models that rely on cross-attention, such as slot attention (Locatello et al., 2020), can run into this issue when trying to extract objects from images and other data modalities. This
14
+
15
+ $^{*}$ Equal contribution $^{1}$ Samsung - SAIT AI Lab, Montreal $^{2}$ University of Amsterdam $^{3}$ Mila, Université de Montreal $^{4}$ Canada CIFAR AI Chair $^{5}$ TNO. Correspondence to: Yan Zhang <yan@cyanzone>, David W. Zhang <w.d.zhang@uva.nl>.
16
+
17
+ Proceedings of the $40^{th}$ International Conference on Machine Learning, Honolulu, Hawaii, USA. PMLR 202, 2023. Copyright 2023 by the author(s).
18
+
19
+ has especially been a problem in the video domain due to occlusions and new objects appearing (Kipf et al., 2022). For example, Wu et al. (2022) observe in experiments that when there are two objects but five "slots" (equivalent to queries in the previous example), the three slots that do not have a specific object to model become nearly identical. Once that has happened, the "cat problem" from before applies: these very similar slots (queries) must receive essentially the same information. Consequently, if multiple new objects appear in the video, these three slots can—at best—all bind to only a single object, which is clearly undesirable.
20
+
21
+ This issue is present because cross-attention is set-equivariant, a property traditionally considered desirable. However, Zhang et al. (2022) show that set-equivariance is too restrictive when applied to multisets: sets with repeated elements allowed, which are prevalent in deep learning (background in Section 2). This manifests itself in two related problems:
22
+
23
+ 1. Soft assignments. The model tends to mix several inputs into each slot (query) rather than making a hard decision of one slot corresponding to exactly one input. This leads to difficulties when the information from each input must be kept distinct.
24
+
25
+ 2. Lack of tiebreaking. Similar slots are processed similarly, so they will likely contain similar information. Multiple similar slots prefer to capture an average of the relevant inputs rather than each slot capturing a different input, which leads to the problem described earlier where two cats cannot be localized individually.
26
+
27
+ To avoid these issues, a property called exclusive multiset-equivalence is necessary (Zhang et al., 2022). So far, only models from the Deep Set Prediction Networks family (Zhang et al., 2019; 2022) are known to have this property. However, they lack the object-centric inductive bias useful for object-centric learning tasks where the set-equivariant slot attention (Locatello et al., 2020) shines. Fortunately, introducing even a single exclusively multiset-equivariant module in a model is enough to give the entire model this property. In this paper, we develop a module that enhances cross-attention in order to make the object-centric slot attention exclusively multiset-equivariant, thereby addressing the problems of soft assignments and tiebreaking.
28
+
29
+ In particular, we will look towards the field of optimal transport for inspiration, which is a natural fit for attention models (Sander et al., 2022). This is because optimal transport concerns itself with computing the "best" assignment from one set to another given some pairwise costs (Villani, 2009), while cross-attention learns exactly such costs. This optimal transport perspective is especially useful because some optimal transport algorithms are able to break ties, which makes them relevant for multiset-equivariance. Unfortunately, these algorithms tend to be slow and difficult to parallelize. On the other hand, solutions to the entropy-regularized optimal transport problem (Cuturi, 2013) are fast but are unable to break ties. We aim to combine the best of both worlds.
30
+
31
+ # Contributions.
32
+
33
+ 1. We establish that slot attention already uses an approximation of regularized optimal transport (Section 3). We use this to motivate variants of slot attention where either the approximation, or both the approximation and regularization are removed—with the latter being exclusively multiset-equivariant. However, this comes with a significant speed penalty and a lack of gradients, which can hinder learning.
34
+ 2. To avoid these issues, we introduce the MESH idea: minimize the entropy of Sinkhorn (Section 4). It combines the benefits of our two proposed slot attention variants: speed, gradients, and exclusive multiset-equivalence. We also show why this is more effective for reducing entropy and maintaining useful gradients than Sinkhorn alone.
35
+ 3. We evaluate our method in slot attention (SA-MESH<sup>1</sup>) on two object detection and two unsupervised object discovery tasks (Section 5). We find that our optimal transport-based variants generally outperform slot attention. Crucially, SA-MESH almost always has the best results—often by a significant margin.
36
+
37
+ # 2. Background
38
+
39
+ Multisets are generalizations of sets by allowing repetitions of elements. In deep learning, sets and multisets are represented as $\mathbb{R}^{n\times c}$ matrices with $n$ being the number of elements and $c$ the feature dimension per element. The uniqueness property of sets is rarely enforced in deep learning, so most models should be thought of as operating on multisets rather than sets (Zhang et al., 2022). These models must then be careful to not rely on the arbitrary order of the $n$ elements. To guarantee this, they should satisfy certain equivariances.
40
+
41
+ # 2.1. Permutation equivariances
42
+
43
+ The standard definition of permutation-equivariant (set-equivariant) functions $f$ states that a permutation of the input $X$ should result in the same permutation of the output (Zaheer et al., 2017). With $\Pi$ as the space of $n \times n$ permutation matrices:
44
+
45
+ $$
46
+ \begin{array}{l} \forall \boldsymbol {X} \in \mathbb {R} ^ {n \times c}, \forall \boldsymbol {P} \in \Pi : \tag {1} \\ f (\boldsymbol {P X}) = \boldsymbol {P} f (\boldsymbol {X}). \\ \end{array}
47
+ $$
48
+
49
+ However, this means that a set-equivariant function must always produce the same result when there are equal inputs (Zhang et al., 2022): $f([a, a]) = [c, d]$ is not possible for $c \neq d$ . Zhang et al. (2022) therefore introduce a more appropriate equivariance for multisets, multiset-equivariance:
50
+
51
+ $$
52
+ \begin{array}{l} \forall \boldsymbol {X} \in \mathbb {R} ^ {n \times c}, \forall \boldsymbol {P} _ {1} \in \Pi , \exists \boldsymbol {P} _ {2} \in \Pi : \\ f \left(\boldsymbol {P} _ {1} \boldsymbol {X}\right) = \boldsymbol {P} _ {2} f (\boldsymbol {X}) \wedge \boldsymbol {P} _ {1} \boldsymbol {X} = \boldsymbol {P} _ {2} \boldsymbol {X}. \tag {2} \\ \end{array}
53
+ $$
54
+
55
+ It states that when there are interchangeable elements in $\mathbf{X}$ (so $P_{1}\mathbf{X} = P_{2}\mathbf{X}$ for $P_{1} \neq P_{2}$ ), then there are multiple permutations of the output that are valid for achieving equivariance. This relaxation of set-equivariance makes the tiebreaking in $f([a, a]) = [c, d]$ possible.
56
+
57
+ While this property specifies what happens with equal elements, the continuity of most machine learning models suggests that the primary benefit in practice is with similar elements (Zhang et al., 2022): similar elements no longer have to result in similar outputs. All set-equivariant models are also multiset-equivariant, which means that only models that are exclusively multiset-equivariant (multiset-equivariant, but not set-equivariant) are capable of tiebreaking. Unfortunately, most operations in the multiset learning literature are set-equivariant and thus unable to break ties.
58
+
59
+ # 2.2. Slot attention
60
+
61
+ Slot attention (SA) (Locatello et al., 2020) can be used to abstract the contents of an image into a multiset of "slots". Each slot can be thought of as a "container" that combines related information from the input into a vector. The model learns how to route information from the input into these slots—in object-centric learning, these slots often learn to represent individual objects. It does this by alternating two steps: 1. cross-attention between the multisets of input features and slot features to compute updates for each slot, and 2. utilizing a GRU (Cho et al., 2014) to apply the computed updates to the corresponding slots.
62
+
63
+ The input features are represented by a matrix $\mathbf{X} \in \mathbb{R}^{n \times c}$ , and the slots are randomly initialized as a matrix $Z^{(0)} \in \mathbb{R}^{m \times d}$ , with $m$ being the number of slots and $d$ the number of dimensions per slot. Cross-attention in slot attention utilizes the standard key-query-value mechanism to compute
64
+
65
+ updates for each slot. The computed updates are then applied to the corresponding slots using a GRU update. The whole procedure is repeated for a fixed number of times, which is referred to as the number of slot attention iterations.
66
+
67
+ $$
68
+ \boldsymbol {Q} ^ {(l)} = \boldsymbol {Z} ^ {(l)} \boldsymbol {W} _ {Q}, \quad \boldsymbol {K} = \boldsymbol {X} \boldsymbol {W} _ {K}, \quad \boldsymbol {V} = \boldsymbol {X} \boldsymbol {W} _ {V} \tag {3}
69
+ $$
70
+
71
+ $$
72
+ \boldsymbol {A} ^ {(l)} = \text {n o r m a l i z e} \left(\operatorname {s o f t m a x} \left(\boldsymbol {Q} ^ {(l)} \boldsymbol {K} ^ {\top}\right)\right) \tag {4}
73
+ $$
74
+
75
+ $$
76
+ \boldsymbol {Z} ^ {(l + 1)} = \operatorname {G R U} \left(\boldsymbol {Z} ^ {(l)}, \boldsymbol {A} ^ {(l)} \boldsymbol {V}\right). \tag {5}
77
+ $$
78
+
79
+ In Locatello et al. (2020), softmax forces each sum over the $m$ slots to be 1 while normalize forces each sum over the $n$ input elements to be 1. All operations used in slot attention are set-equivariant with respect to the slots, which makes the model set-equivariant (Locatello et al., 2020). In this paper, we introduce a module to make slot attention exclusively multiset-equivariant, which allows it to break ties between similar slots.
80
+
81
+ Note that similar slots can arise due to a multitude of reasons, such as the ones we pointed out in the introduction; it is not necessary for the objects in the input to be similar. This is also why the random initialization of slots in slot attention is not sufficient for tiebreaking, because the slots can become similar after the slot updates, after which they can no longer be separated easily.
82
+
83
+ # 3. Connecting slot attention to optimal transport
84
+
85
+ Optimal transport (Villani, 2009) identifies the most cost-effective method for redistributing mass between two distributions. This process typically involves sampling from both distributions, calculating the pairwise distances between the samples, and applying an optimal transport algorithm to determine the transport map that minimizes the total cost. In the context of cross-attention, we are comparing two multisets containing the input and slot features rather than two distributions, but the same principles of computing pairwise distances and finding an optimal transport map still apply. By making this connection between slot attention and optimal transport more explicit, we can leverage the powerful algorithms of optimal transport to enhance the performance of slot attention.
86
+
87
+ Entropy-regularized optimal transport. A critical component when applying cross-attention in slot attention is the normalization of the attention matrix. Equation 4 first exponentiates all the entries, then normalizes one dimension of the attention matrix to sum to 1, then the other dimension to sum to 1. This sequence of operations is also known as applying the Sinkhorn algorithm for a single step. The Sinkhorn algorithm solves the entropy-regularized optimal transport problem (Cuturi, 2013) by repeatedly alternating these two normalizations, which results in a doubly stochas-
88
+
89
+ tic matrix at convergence. We can therefore think of Equation 4 as approximating this entropy-regularized optimal transport (by using only one Sinkhorn iteration) to determine how the information from the input should be associated with the slots. This connection between transformers (which use a slightly different normalization) and optimal transport has also been made by Sander et al. (2022).
90
+
91
+ A simple extension is thus to consider slot attention using more than one Sinkhorn iteration, which we will refer to as SA-SH. In this variant, instead of using a similarity score, a distance function $d$ (e.g. $\mathrm{L2norm}^2$ ) is used to compute the attention matrix as follows:
92
+
93
+ $$
94
+ C _ {i j} = d \left(\boldsymbol {Q} _ {i}, \boldsymbol {K} _ {j}\right) \tag {6}
95
+ $$
96
+
97
+ $$
98
+ \boldsymbol {A} = \operatorname {s i n k h o r n} (\boldsymbol {C}). \tag {7}
99
+ $$
100
+
101
+ Although the proposed extension properly computes the optimal transport map, it remains limited by its set-equivalence and is unable to perform tiebreaking. One additional detail is that the Sinkhorn algorithm must handle non-square matrices since the number of slots is usually much smaller than the number of inputs; naively applying the algorithm on such matrices does not converge. We describe the details of how to handle this in Appendix A as they are not important to the following discussion.
102
+
103
+ Unregularized optimal transport. By using the full Sinkhorn algorithm, SA-SH replaces the usual attention matrix with the transport map of the regularized optimal transport problem. This raises the question whether other optimal transport algorithms can be used in the context of slot attention too. A benefit of optimal transport without regularization is that it can be exclusively multiset-equivariant: many algorithms naturally include tiebreaking, which leads to low entropy solutions. By replacing entropy-regularized optimal transport with unregularized optimal transport, we can make slot attention exclusively multiset-equivariant to avoid the issues we pointed out in Section 1.
104
+
105
+ We thus propose the SA-EMD (Earth Mover's Distance) variant, wherein we use the EMD algorithm (Bonneel et al., 2011) that is part of the POT package (Flamary et al., 2021). The EMD algorithm provides a sparse solution to the unregularized optimal transport problem and has the ability to break ties. However, using the EMD algorithm also presents some challenges. The gradients of unregularized optimal transport problems are piecewise constant, which prevents learning of the cost matrix $C$ . Thus, we need to estimate gradients, for which many different techniques exist (Gould et al., 2016; Fung et al., 2022; Bai et al., 2019; Pogancić et al., 2020). In practice, we observe that the gradient of the Sinkhorn operator is also a good descent direction for EMD.
106
+
107
+ We find that we obtain the best empirical results through:
108
+
109
+ $$
110
+ \boldsymbol {A} = \operatorname {e m d} (\boldsymbol {C}) + \operatorname {s i n k h o r n} (\boldsymbol {C}). \tag {8}
111
+ $$
112
+
113
+ Another issue is that the EMD algorithm is relatively slow. The standard solvers use a network simplex algorithm (a variant of the simplex algorithm for graphs), which is difficult to parallelize efficiently on GPUs. Can we get the benefits of unregularized optimal transport with its exclusive multiset-equivariance, while still being fast and differentiable like entropy-regularized optimal transport?
114
+
115
+ # 4. MESH: minimizing the entropy of Sinkhorn
116
+
117
+ Previously, we focused on different ways of turning costs $C$ into a transport map $A$ . Now, we turn our attention to changing the costs themselves, followed by using the computational efficiency of the Sinkhorn algorithm to compute the transport map for these modified costs. A key difference between unregularized optimal transport and entropy-regularized optimal transport is the entropy in the resulting transport map. The idea is to change the costs in such a way that even after entropy-regularized optimal transport, the entropy remains low. This objective allows the tiebreaking necessary for exclusive multiset-equivariance. To implement this idea, we aim to find a new cost $C'$ that minimizes the entropy $H(P) = -\sum_{i,j} P_{ij} \log P_{ij}$ .
118
+
119
+ $$
120
+ \operatorname {M E S H} \left(\boldsymbol {C}\right) = \underset {\boldsymbol {C} ^ {\prime} \in \mathcal {V} (\boldsymbol {C})} {\arg \min } H \left(\operatorname {s i n k h o r n} \left(\boldsymbol {C} ^ {\prime}\right)\right) \tag {9}
121
+ $$
122
+
123
+ $$
124
+ \boldsymbol {A} = \operatorname {s i n k h o r n} (\operatorname {M E S H} (\boldsymbol {C})). \tag {10}
125
+ $$
126
+
127
+ $\mathcal{V}(C)$ denotes a neighborhood around $C$ , which is implicitly defined by how we implement the arg min. We refer to this variant of slot attention as SA-MESH (Minimize Entropy of Sinkhorn). Equation 9 changes the cost so that the resulting transport map has low entropy (preferring 0s and 1s) despite the entropy regularization. The final transport map is calculated from this new cost matrix efficiently using the Sinkhorn algorithm. In summary, the costs are changed to make the transport map look more like the output of unregularized optimal transport.
128
+
129
+ To solve this optimization problem, we propose to use gradient descent for a small, fixed number of steps starting from the original cost matrix $C$ . The last point ensures that the new cost matrix remains close to $C$ so that the new optimal transport problem will be similar to the original one. Differentiating through this can be done with standard automatic differentiation. While the process described so far does not feature any tiebreaking explicitly (and would in fact struggle to minimize entropy successfully when exactly equal rows or columns are present in $C$ ), we can simply
130
+
131
+ add a small amount of noise at the start of the optimization: $C'(0) = C + \epsilon, \epsilon_{ij} \sim \mathcal{N}(0, 10^{-6})$ . Another important detail is to normalize the gradient to have a fixed norm: the small amount of noise is amplified (to break ties) only when slots are similar. This is done without having to resort to large learning rates, which would impact the stability of optimization. We thus propose to repeat the following for $T$ steps with a learning rate $\lambda$ :
132
+
133
+ $$
134
+ \boldsymbol {C} ^ {\prime (t + 1)} = \boldsymbol {C} ^ {\prime (t)} - \lambda \frac {\nabla_ {\boldsymbol {C} ^ {\prime (t)}} \boldsymbol {A} ^ {\prime (t)}}{\left\| \nabla_ {\boldsymbol {C} ^ {\prime (t)}} \boldsymbol {A} ^ {\prime (t)} \right\|} \tag {11}
135
+ $$
136
+
137
+ $$
138
+ \text {w i t h} \boldsymbol {A} ^ {\prime (t)} = H (\operatorname {s i n k h o r n} \left(\boldsymbol {C} ^ {\prime (t)}\right)). \tag {12}
139
+ $$
140
+
141
+ Note that exact minimization is not needed, nor necessarily desirable. A critical aspect is that $C'(T)$ is still related to the initial $C$ . For example, if $C$ is square, then $C' = 10^{23}I$ would always "successfully" minimize Equation 9, but also solve a problem unrelated to $C$ and provide no signal to learn from. This is why we initialize $C'^{(0)}$ as $C$ with a small amount of noise. Note that if this noise is too high (e.g. $\epsilon_{ij} \sim \mathcal{N}(0,1)$ ), the solution can again lose correspondence with the actual cost matrix $C$ that we are trying to compute the transport map for. We develop a more complicated version that explicitly enforces $C$ and $C'$ to be similar (Appendix B) but find that it is not necessary in practice as long as the noise in the initialization is reasonably low.
142
+
143
+ # 4.1. Properties
144
+
145
+ Equivariance. SA-MESH is now exclusively multiset-equivariant: it is multiset-equivariant because all the individual operations are multiset-equivariant, but it is not set-equivariant because equal slots will no longer receive the same transport plans due to the tiebreaking from the noise and subsequent optimization (see proof in Appendix C). This gives our method more representational power than standard SA and SA-SH because it is no longer restricted by set-equivariance.
146
+
147
+ A useful side-effect is that random initialization of slots is no longer necessary. Since ties can be broken by this entropy minimization, it is no problem to initialize all slots to be the same vector. In standard slot attention, the amount of noise in $Z^{(0)}$ needs to be just right: too low, and the set-equivariant model has difficulties breaking ties between these similar slots (Wu et al., 2022); too high, and the model can become unreliable from the noisiness (Kipf et al., 2022). Furthermore, randomly initializing the slots does not prevent them from collapsing to the same values in a later iteration—such as when there are fewer objects to model than slots. In contrast, a tiny amount of noise in $C'$ (as long as it is above machine precision after sinkhorn) is sufficient for tiebreaking and avoiding collapse, and any other effect of the noise can be optimized away through the gradient descent.
148
+
149
+ ![](images/fb6468c62063129e9cf90c1144c2c20abde5faf33bb68f26c5ac08ebfcd28791.jpg)
150
+ Figure 1. MESH reduces entropy while maintaining reasonable gradients across a large range of attention values, in particular when attention is uncertain (low scaling factors). Meanwhile, Sinkhorn (SH) provides nontrivial gradients in a much smaller range with entropy reduction being ineffective when the scaling is too low. Entropy of transport map (left) and corresponding gradient norm (right) when varying the scaling factor on the input. The entropy is normalized to have 1 as maximum entropy. The gradient norm of each method is normalized to have a maximum of 1, we show the unnormalized gradient norms in Appendix E.
151
+
152
+ ![](images/0b186fdbaf616bd7adc2780673388a1cd356d0b97bc4621363539f0a8faba47f.jpg)
153
+
154
+ Speed. SA-MESH offers a significant improvement in computation time when compared to SA-EMD. This is because it only requires the evaluation of the Sinkhorn algorithm for a small number of optimization steps (in our experiments, we found little improvement above four steps). While it may not be as fast as SA-SH, its exclusive multiset-equivalence can speed up learning by making the model more powerful. In many cases, the computation required for SA-MESH is outweighed by other components of the model such as the image processing part that creates the input multiset for SA. Since each optimization step in MESH needs to solve a similar optimal transport problem, we can reuse the result from the previous iterations to improve the efficiency, as we describe in Appendix D.
155
+
156
+ Gradients. Another benefit over SA-EMD is that gradient computation is simple since we can fully rely on automatic differentiation instead of having to manually estimate gradients for the black-box EMD solver in SA-EMD. We find experimentally that we do not even need to differentiate the gradient updates in Equation 11 themselves; the gradients of $C^{(T)}$ can simply be passed along to $C$ in a straight-through manner (Bengio et al., 2013) without reduction in performance. SA-MESH also has benefits in terms of the "quality" of gradients over SA-SH, which we explain in the following.
157
+
158
+ # 4.2. Comparison to changing temperature
159
+
160
+ An alternative for breaking ties is to add noise to the cost matrix (like SA-MESH), but then simply reduce the temperature of the Sinkhorn algorithm, which corresponds to reducing the amount of entropy regularization (Cuturi, 2013). For sufficiently low temperatures, this should also be able to map equal inputs to different slots. How does this much sim
161
+
162
+ pler approach compare to MESH, which minimizes entropy by gradient descent?
163
+
164
+ Sinkhorn with low temperatures can be thought of as analogous to softmax with low temperatures. As the temperature decreases, the behavior of softmax becomes more similar to an argmax, but the gradients become ill-behaved as a result. Similarly, with Sinkhorn, low temperatures may result in gradients that make it difficult or impossible to learn a good cost matrix. We now make this notion more concrete and show that MESH can reduce entropy while maintaining "good" gradients for a much larger range of inputs.
165
+
166
+ In Figure 1, we have the following set-up. Starting from a $10 \times 10$ identity matrix, we scale it by a varying factor to obtain the cost matrix, then apply either Sinkhorn (for different temperatures $\tau$ ) or MESH (for different learning rates $\lambda$ ). We then measure the entropy of the resulting transport map (left), as well as the norm of the gradient of this entropy with respect to the cost matrix (right). Gradient norms close to zero slow down learning because the gradients provide little to no information on how to learn the cost matrix.
167
+
168
+ When the scaling factor is large (e.g. $>10$ , attention is confident), the behaviors are similar (low entropy and small gradients). When the scaling factor is small (e.g. $< 0.1$ , attention is not confident), MESH is still always able to reduce entropy while maintaining reasonable gradients. In contrast, Sinkhorn only has nontrivial gradients in a relatively small range; outside of this range, learning is difficult because the gradient norms become close to 0. Thus, a trade-off has to be made for Sinkhorn, which is not necessary for MESH: either $\tau$ is high and low scaling factors result in virtually zero gradients (with no reduction to the entropy), or $\tau$ is low and higher scaling factors result in virtually zero gradients
169
+
170
+ Table 1. Random objects detection, measured in RMSE divided by standard deviation $\sigma$ of random objects (lower is better). An always-predict-zeros baseline has a normalized RMSE of 1. Median over 5 random seeds.
171
+
172
+ <table><tr><td>Model</td><td>σ = 1.0</td><td>σ = 0.1</td><td>σ = 0.01</td></tr><tr><td>SA</td><td>0.44</td><td>0.53</td><td>0.65</td></tr><tr><td>SA-SH</td><td>0.27</td><td>0.32</td><td>0.41</td></tr><tr><td>SA-EMD</td><td>0.23</td><td>0.52</td><td>1.04</td></tr><tr><td>SA-MESH</td><td>0.24</td><td>0.27</td><td>0.31</td></tr></table>
173
+
174
+ instead. The MESH learning rate $\lambda$ can be used to control the shape of how entropy is reduced, while the Sinkhorn temperature $\tau$ only changes the location and does not increase the range of nontrivial gradients. In summary, MESH effectively reduces entropy while maintaining well-behaved gradients for a large range of inputs.
175
+
176
+ # 5. Experiments
177
+
178
+ We now experimentally evaluate SA with our optimal transport variants, with a particular focus on comparing SA to SA-MESH. We open-source all of our code https://github.com/davzha/MESH and provide extra experimental details in Appendix F.
179
+
180
+ # 5.1. Random objects detection
181
+
182
+ First, we evaluate the effect of the different SA variants in a simplified object detection setting. The aim is to assess a model's ability to detect and distinguish similar objects in a controlled setting. Given a multiset containing $k$ random 32d vectors sampled from $\mathcal{N}(0,\sigma^2\mathbf{I})$ and $h$ zero vectors, the goal is to copy only the $k$ random vectors into the $k$ slots. In the context of object detection on images, this can be thought of as detecting $k$ different objects, each of which occupies exactly one position in a feature map.
183
+
184
+ In this setting, we want the object information to be preserved as accurately as possible. To vary the difficulty of this task, we change the standard deviation $\sigma$ of the random
185
+
186
+ vectors to be copied and measure the error relative to this $\sigma$ . A lower standard deviation corresponds to a harder task because the elements become more similar to each other and to the background zero vectors.
187
+
188
+ Results. Table 1 shows our results for $k = 5$ objects and $h = 100$ background elements for varying difficulties $\sigma$ . First, we see that SA-SH and SA-MESH can detect the objects on the hardest setting of $\sigma = 0.01$ more accurately than SA on $\sigma = 1$ . This demonstrates the general value of our proposed optimal transport perspective in the context of attention. SA-MESH with its lower entropy outperforms SA-SH: the SA-MESH performance for a specific $\sigma$ is roughly equivalent to SA-SH at a $\sigma$ ten times higher. This shows the benefits of reducing entropies in the transport map through MESH, which helps objects stay distinct from each other. Meanwhile, SA-EMD (also with low entropy transport maps) performs similarly to SA-MESH on $\sigma = 1$ , but degenerates to the always-predict-zeros baseline on $\sigma = 0.01$ . We attribute this to the inherently imprecise gradient estimation leading to learning problems.
189
+
190
+ # 5.2. CLEVR property prediction
191
+
192
+ Next, we test SA and our proposed variants on a more realistic object detection task. CLEVR (Johnson et al., 2017) is a synthetic dataset containing images with up to ten objects in a 3d scene. Each object is sampled with varying sizes, materials, shapes, and colors. The task is to predict the multiset of objects with their properties and 3d position. Following Zhang et al. (2019), we evaluate using average precision (AP) at different distance thresholds for the 3d coordinates of the predicted objects.
193
+
194
+ Results. Table 2 shows that SA-MESH achieves the best SA results (and state-of-the-art results on some metrics) while only increasing run time by a small amount. These results are followed by SA-EMD, which has slightly worse results (likely due to the inherently imprecise gradient estimation) but takes over three times longer to train. Again, we see that all three optimal transport-based methods greatly
195
+
196
+ Table 2. CLEVR property prediction, average precision (AP) in % (mean ± standard deviation) over 5 random seeds, higher is better. SA-MESH improves over all other SA variants at only a small computational cost. Note that the exclusively multiset-equivariant iDSPN is not object-centric, so it is not fully comparable. SA (original) results are copied from Locatello et al. (2020), iDSPN results from Zhang et al. (2022). Models with $\dagger$ use the improvement by Chang et al. (2022), see Appendix G for our results without $\dagger$ .
197
+
198
+ <table><tr><td>Model</td><td>AP∞</td><td>AP1</td><td>AP0.5</td><td>AP0.25</td><td>AP0.125</td><td>AP0.0625</td><td>Train time</td></tr><tr><td>iDSPN (Zhang et al., 2022)</td><td>98.8±0.5</td><td>98.5±0.6</td><td>98.2±0.6</td><td>95.8±0.7</td><td>76.9±2.5</td><td>32.3±3.9</td><td>—</td></tr><tr><td>SA (original) (Locatello et al., 2020)</td><td>94.3±1.1</td><td>86.7±1.4</td><td>56.0±3.6</td><td>10.8±1.7</td><td>0.9±0.2</td><td>—</td><td>—</td></tr><tr><td>SA†</td><td>94.3±0.4</td><td>85.7±1.6</td><td>77.2±1.5</td><td>53.1±2.7</td><td>16.7±1.8</td><td>4.0±0.7</td><td>2.2 h</td></tr><tr><td>SA-SH†</td><td>98.9±0.2</td><td>97.7±0.5</td><td>95.2±0.9</td><td>83.3±0.8</td><td>38.5±2.0</td><td>10.0±1.4</td><td>2.3 h</td></tr><tr><td>SA-EMD†</td><td>99.3±0.3</td><td>98.1±0.4</td><td>95.9±0.8</td><td>85.8±1.1</td><td>42.0±2.0</td><td>11.4±1.3</td><td>9.3 h</td></tr><tr><td>SA-MESH†</td><td>99.4±0.1</td><td>99.2±0.2</td><td>98.9±0.2</td><td>91.1±1.1</td><td>47.6±0.8</td><td>12.5±0.4</td><td>2.4 h</td></tr></table>
199
+
200
+ outperform the baseline SA, which validates the benefits of the optimal transport perspective in attention.
201
+
202
+ We believe that there are two reasons why SA-SH performs much better than SA, even though both are set-equivariant. Keep in mind that SA is equivalent to SA-SH with a single Sinkhorn iteration. Performing more Sinkhorn iterations gives a more accurate transport map, which can be interpreted as fully resolving the "competition" between slots for inputs. This competition interpretation is what motivated the normalizations (1-step Sinkhorn) in (Locatello et al., 2020). The other factor is that SA-SH, in order to converge for rectangular cost matrices, requires the use of learned margins (see Appendix A). These can assist with weighting down the importance of background pixels or unused slots, which makes it easier for the model to learn the $W_{K}$ and $W_{V}$ matrices of slot attention.
203
+
204
+ Note that we only provide the results for iDSPN (which is also exclusively multiset-equivariant) for context; this is not supposed to be a direct comparison due to the significant difference in approach. In general, slot attention through the use of attention has the benefit of not needing to compress the input into a single vector (global scene representation) like iDSPN. The resulting object-centric inductive bias and the relative simplicity have allowed for wider adoption and success of SA over iDSPN (Kipf et al., 2022; Hu et al., 2020; Li et al., 2021; Sajjadi et al., 2022), which makes our improvements to SA meaningful, even if in this case some metrics are worse than iDSPN.
205
+
206
+ # 5.3. Unsupervised object discovery on images
207
+
208
+ In this task, the objective is to discover objects without the supervision of what the objects are. We follow Locatello et al. (2020) and set up an image reconstruction task with slots as the latent bottleneck using SA. These slots are individually decoded into object-specific images, each comprising the RGB color channels and an alpha mask. These object-specific images are then combined to form the final reconstructed image. To evaluate the performance, we compare the per-slot alpha masks to the actual object segmentation masks. The goal is thus for image reconstruction with a multiset bottleneck to lead to a decomposition of the scene into individual objects, with each object being modeled by a distinct slot.
209
+
210
+ We evaluate on the Multi-dSprites dataset, which is the only benchmark presented by Locatello et al. (2020) that still presented a challenge (possibly due to the presence of highly overlapping objects). Additionally, we test on ClevrTex (Karazija et al., 2021), a synthetic dataset similar to CLEVR that introduces the added challenge of different textures. In line with prior work (Kipf et al., 2022), we evaluate the Foreground Adjusted Rand Index (FG-ARI) and Foreground mean Intersection over Union (FG-mIoU).
211
+
212
+ Table 3. Object discovery on images results in Multi-dSprites in % (mean ± standard deviation) over 5 random seeds, higher is better. SA-MESH outperforms the other models and has lower variance.
213
+
214
+ <table><tr><td>Model</td><td>FG-ARI</td><td>FG-mIoU</td></tr><tr><td>SA (Locatello et al., 2020)</td><td>91.3±0.3</td><td>—</td></tr><tr><td>SA</td><td>92.2±0.5</td><td>24.3±5.4</td></tr><tr><td>SA-SH</td><td>87.2±1.8</td><td>84.0±3.1</td></tr><tr><td>SA-MESH</td><td>95.6±0.2</td><td>86.2±2.2</td></tr></table>
215
+
216
+ Table 4. Object discovery on images results in ClevrTex in % (mean ± standard deviation) over 5 random seeds, higher is better. SA-MESH outperforms the other models and has lower variance.
217
+
218
+ <table><tr><td>Model</td><td>FG-ARI</td><td>FG-mIoU</td></tr><tr><td>SA</td><td>52.8±14.9</td><td>26.3±14.9</td></tr><tr><td>SA-SH</td><td>70.8±5.8</td><td>35.3±4.4</td></tr><tr><td>SA-MESH</td><td>79.0±2.6</td><td>43.2±4.0</td></tr></table>
219
+
220
+ To ensure FG-mIoU is permutation-insensitive, we use the Hungarian algorithm to find the best matching between the masks. See Section F.3 for more details. Note that we no longer test SA-EMD because the larger input size compared to Section 5.2 makes its training time infeasible.
221
+
222
+ Results. Table 3 and Table 4 show that on both Multi-dSprites and ClevrTex, SA-MESH achieves significantly higher FG-ARI and FG-mIoU compared to all baselines. SA-SH and SA-MESH improve especially in mIoU, which Karazija et al. (2021) argue is a better metric than ARI to evaluate the accuracy of object masks. Appendix H shows two extra ablations on the training setup.
223
+
224
+ Analysis. In Figure 2, we observe that minimizing the entropy leads to much sparser attention maps for SA-MESH in comparison to SA: SA-MESH only attends to a small part within each object, rather than the whole object as is usually the case for SA. Keep in mind that attention maps are only used to route the required information to each slot, and it is the slots themselves that represent the individual
225
+
226
+ ![](images/dda08f66d28b423f9fca7afaea6e5702dc6e1f72eb111bfa468a1c231900bc4b.jpg)
227
+ Figure 2. Attention maps (first row) and alpha masks (second row) for each of the six slots in SA-MESH on Multi-dSprites. The attention focuses on only a small region inside each object, but the model still reconstructs the full objects. See Appendix J for more examples.
228
+
229
+ Table 5. Video object discovery results on CLEVRR-S and CLEVRR-L in % (mean ± standard deviation) over 5 random seeds. SA-MESH outperforms all other models in terms of quality of predicted masks (ARI, mIoU) and achieves high temporal consistency (TC). See Appendix J for example masks.
230
+
231
+ <table><tr><td rowspan="2">Model</td><td colspan="3">CLEVRER-S</td><td colspan="3">CLEVRER-L</td></tr><tr><td>FG-ARI</td><td>FG-mIoU</td><td>TC</td><td>FG-ARI</td><td>FG-mIoU</td><td>TC</td></tr><tr><td>SA</td><td>78.1±14.0</td><td>16.8±9.8</td><td>26.3±22.5</td><td>69.6±14.9</td><td>12.2±6.6</td><td>12.8±8.7</td></tr><tr><td>SA fixed noise</td><td>71.0±34.0</td><td>17.1±11.4</td><td>42.8±19.3</td><td>79.4±5.9</td><td>11.9±6.2</td><td>18.5±13.0</td></tr><tr><td>SA learned noise</td><td>80.2±14.1</td><td>13.2±4.9</td><td>21.3±13.5</td><td>84.7±5.7</td><td>10.2±1.2</td><td>19.4±7.7</td></tr><tr><td>SA-SH</td><td>89.3±2.3</td><td>10.0±2.8</td><td>89.7±2.4</td><td>82.9±1.5</td><td>7.0±0.2</td><td>26.8±0.5</td></tr><tr><td>SA-MESH</td><td>93.8±1.0</td><td>44.1±7.1</td><td>80.2±10.1</td><td>92.9±2.2</td><td>54.4±8.9</td><td>55.4±5.7</td></tr></table>
232
+
233
+ objects. Attending to a small part of each object is sufficient because the receptive field of the CNN image encoder lets it move information from the edge of an object into the center. The accuracy of the final alpha masks of SA-MESH shows that this happens successfully. In Appendix J, we see that SA-MESH attends less to the background than SA on Multi-dSprites.
234
+
235
+ Similar to Locatello et al. (2020), we observe that some SA runs fail to separate the individual objects into different slots despite having a low reconstruction error. In those cases, the attention maps divide the image into separate regions, independent of the image content. SA-MESH ensures that the attention maps are sparse, which helps to avoid these kinds of failure modes. Appendix J shows this difference between SA-MESH and SA on ClevrTex: SA-MESH discovers objects successfully in most cases, and usually, only the background is split into spatial regions.
236
+
237
+ # 5.4. Unsupervised object discovery on video
238
+
239
+ As we mentioned in Section 1, Wu et al. (2022) observed issues with SA when applied to videos where multiple objects can enter the scene. To evaluate our method in this scenario, we build two variants of the CLEVRER video dataset (Yi et al., 2019) where the number of visible objects varies over time. We only use two frames from each video: the first frame, and either the 16th frame (short time difference, CLEVRER-S) or the 128th frame (long time difference, CLEVRER-L). We do this to evaluate SA without the dynamics prediction component that Wu et al. (2022) are concerned with. In CLEVRER-S, the total number of objects increases by two or more in $9.5\%$ of the videos, while in CLEVRER-L, this occurs for $68.8\%$ of the videos.
240
+
241
+ We evaluate FG-ARI and FG-mIoU on the two frames individually, which is then averaged. We also compute a temporal consistency (TC) metric as the fraction of objects that are correctly captured by the same slot (details in Section F.4).
242
+
243
+ Results. Table 5 shows that SA-MESH outperforms the other models by a significant margin. The only exception is
244
+
245
+ on CLEVRER-S for temporal consistency—we can close this gap simply by reducing the MESH learning rate $\lambda$ (five run average: $90.0\%$ FG-ARI, $22.7\%$ FG-mIoU, $95.1\%$ TC). The proposal by Wu et al. (2022) of adding noise to slots to prevent them from collapsing helps SA on CLEVRER-L, but to a lesser extent than SA-MESH, which uses exclusive multiset-equivariance to prevent collapse. This is evidenced by the much better FG-mIoU of SA-MESH.
246
+
247
+ # 6. Related work
248
+
249
+ Object-centric learning. Object-centric learning aims to model visual input data in terms of multiple "objects" rather than a global representation or grid of feature vectors. This decomposition can be considered an abstraction of the input; reasoning over a small number of objects is intuitively more efficient than over a feature map (Ke et al., 2022; Huang et al., 2020). Scenarios with multiple independent objects are ubiquitous in natural data, so it is desirable to model them well. Karazija et al. (2021) classify object-centric learning methods into three categories: pixel-space approaches which group related pixels together (Greff et al., 2019; Pervez et al., 2022), glimpse approaches which sequentially extract patches from the input (Crawford & Pineau, 2019; Lin et al., 2020; Jiang & Ahn, 2020), and sprite approaches which learn a dictionary of object appearances (Monnier et al., 2021; Smirnov et al., 2021). These are part of the wider research area of factorizing knowledge into smaller, independent parts which can be modeled more easily (Goyal et al., 2019; 2021; Didolkar et al., 2021).
250
+
251
+ We choose to apply MESH on specifically the pixel-space based slot attention (Locatello et al., 2020) because of its simplicity in approach (cross-attention with GRU updates), the lack of assumptions on what an object is (which makes it a general technique), and its set-equivariance. Since Zhang et al. (2022) show a specific limitation with set-equivariance, there is a clear path towards improvement, namely making it exclusively multiset-equivariant. We accomplish this in this paper, with strong results backing up the benefits of our approach.
252
+
253
+ Optimal transport. Another approximation of optimal transport can be obtained through the Sliced Wasserstein Distance (Bonneel et al., 2015). It performs tiebreaking through the use of numerical sorting and is thus exclusively multiset-equivariant, but it lacks precise 1-to-1 associations between inputs and slots. This can especially be a problem with varying input sizes. We tried approaches based on this method as a replacement for standard cross-attention but did not obtain any competitive results.
254
+
255
+ In a similar direction to Sinkhorn, which performs entropy-regularized optimal transport, Blondel et al. (2018) study L2-regularized optimal transport problems. While their solver is faster than unregularized optimal transport and obtains lower entropy solutions than Sinkhorn, similarly to Sinkhorn the convexity of the problem means that it cannot break ties effectively on its own, even with noise. In SA-MESH, we can replace Sinkhorn with this method, but we found that it was too slow comparatively.
256
+
257
+ # 7. Discussion
258
+
259
+ We introduced several variants of slot attention that can break ties between slots which enables better modeling of objects. In particular, MESH is a promising method that enhances cross-attention. As a result, it grants slot attention the property of exclusive multiset-equivariance while maintaining learnability and efficiency.
260
+
261
+ While minimizing entropy in MESH has a nice symmetry with entropy-regularized optimal transport, it is not clear whether a sparse attention map is always desirable. We try to learn a neural network on the transport map in Appendix I, but find no improvements over simply using the entropy; the derivative of the learned objective ends up with a similar shape to that of the entropy, which suggests that entropy is indeed a reasonable choice to minimize for now. While the experiments on ClevrTex are a small step towards more complicated image data, we do not have any evaluation on real world data, so it is not certain what new problems will present themselves. Recent object-centric learning techniques that are able to scale to real-world scenarios often use more powerful image encoders and decoder architectures with the vanilla slot attention, so it is possible in principle to simply replace SA with SA-MESH in these models. In practice, it is so far uncertain whether any inductive biases introduced by SA-MESH only apply well on simpler synthetic data.
262
+
263
+ Our experiments show that in certain cases, SA-SH can already provide most of the benefits without the additional complexity of the bi-level optimization in SA-MESH. For example, most of the benefit over SA in Section 5.1 is already obtained with SA-SH, while SA-MESH only provides a small benefit over SA-SH. On the other hand, there are
264
+
265
+ cases like Section 5.4 where SA-MESH greatly outperforms SA-SH. We believe that it is important to gain a better understanding of what situations make one preferable over the other.
266
+
267
+ A limitation of our experiments is that we only evaluate the MESH idea in the context of slot attention, when in reality it is a more general method. For example, it could be used to enhance self-attention in Transformers. Another example is that Sinkhorn is used by Peña et al. (2022) for merging the weights of two neural networks together. MESH could be used as an alternative in this context to replace the Sinkhorn algorithm. In general, we believe that optimal transport will continue to play an important role in deep learning, with MESH being a way of bringing tiebreaking into the picture without paying the usual speed penalty associated with optimal transport.
268
+
269
+ # Acknowledgements
270
+
271
+ The work of DWZ is part of the research programme Perspectief EDL with project number P16-25 project 3, which is financed by the Dutch Research Council (NWO) domain Applied and Engineering Sciences (TTW). This research was enabled in part by compute resources provided by Mila (mila.quebec), Calcul Quebec (calculquebec.ca), the Digital Research Alliance of Canada (alliancecan.ca), and by support from the Canada CIFAR AI Chair Program. Simon Lacoste-Julien is a CIFAR Associate Fellow in the Learning Machines & Brains program.
272
+
273
+ # References
274
+
275
+ Bai, S., Kolter, J. Z., and Koltun, V. Deep equilibrium models. In Advances in Neural Information Processing Systems (NeurIPS), 2019.
276
+ Bengio, Y., Léonard, N., and Courville, A. C. Estimating or propagating gradients through stochastic neurons for conditional computation. arXiv preprint arXiv:1308.3432, 2013.
277
+ Blondel, M., Seguy, V., and Rolet, A. Smooth and sparse optimal transport. In International Conference on Artificial Intelligence and Statistic (AISTATS), 2018.
278
+ Bonneel, N., Van De Panne, M., Paris, S., and Heidrich, W. Displacement interpolation using lagrangian mass transport. In SIGGRAPH Asia, 2011.
279
+ Bonneel, N., Rabin, J., Peyre, G., and Pfister, H. Sliced and radon wasserstein barycenters of measures. Journal of Mathematical Imaging and Vision, 51(1):22-45, 2015.
280
+ Chang, M., Griffiths, T. L., and Levine, S. Object representations as fixed points: Training iterative refinement
281
+
282
+ algorithms with implicit differentiation. arXiv preprint arXiv:2207.00787, 2022.
283
+ Cho, K., Van Merrienboer, B., Bahdanau, D., and Bengio, Y. On the properties of neural machine translation: Encoder-decoder approaches. arXiv preprint arXiv:1409.1259, 2014.
284
+ Crawford, E. and Pineau, J. Spatially invariant unsupervised object detection with convolutional neural networks. In AAAI Conference on Artificial Intelligence, 2019.
285
+ Cuturi, M. Sinkhorn distances: Lightspeed computation of optimal transport. In Advances in Neural Information Processing Systems (NeurIPS), 2013.
286
+ Didolkar, A., Goyal, A., Ke, N. R., Blundell, C., Beaudoin, P., Heess, N., Mozer, M., and Bengio, Y. Neural production systems: Learning rule-governed visual dynamics. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
287
+ Flamary, R., Courty, N., Gramfort, A., Alaya, M. Z., Bois-bunon, A., Chambon, S., Chapel, L., Corenflos, A., Fatras, K., Fournier, N., Gautheron, L., Gayraud, N. T., Janati, H., Rakotomamonjy, A., Redko, I., Rolet, A., Schutz, A., Seguy, V., Sutherland, D. J., Tavenard, R., Tong, A., and Vayer, T. Pot: Python optimal transport. Journal of Machine Learning Research, 22(78), 2021.
288
+ Fung, S. W., Heaton, H., Li, Q., McKenzie, D., Osher, S., and Yin, W. JFB: Jacobian-free backpropagation for implicit networks. In AAAI Conference on Artificial Intelligence, 2022.
289
+ Gould, S., Fernando, B., Cherian, A., Anderson, P., Cruz, R. S., and Guo, E. On differentiating parameterized argmin and argmax problems with application to bi-level optimization. arXiv preprint arXiv:1607.05447, 2016.
290
+ Goyal, A., Lamb, A., Hoffmann, J., Sodhani, S., Levine, S., Bengio, Y., and Scholkopf, B. Recurrent independent mechanisms. In International Conference on Learning Representations (ICLR), 2019.
291
+ Goyal, A., Lamb, A., Gampa, P., Beaudoin, P., Levine, S., Blundell, C., Bengio, Y., and Mozer, M. Object files and schemata: Factorizing declarative and procedural knowledge in dynamical systems. In International Conference on Learning Representations (ICLR), 2021.
292
+ Greff, K., Kaufmann, R. L., Kabra, R., Watters, N., Burgess, C., Zoran, D., Matthew, L., Botvinick, M., and Lerchner, A. Multi-object representation learning with iterative variational inference. In International Conference on Machine Learning (ICML), 2019.
293
+
294
+ Hu, J., Yang, Y., Chen, C., He, L., and Yu, Z. SAS: Dialogue state tracking via slot attention and slot information sharing. In Annual Meeting of the Association for Computational Linguistics (ACL), 2020.
295
+ Huang, Q., He, H., Singh, A., Zhang, Y., Lim, S.-N., and Benson, A. Better set representations for relational reasoning. In Advances in Neural Information Processing Systems (NeurIPS), 2020.
296
+ Jiang, J. and Ahn, S. Generative neurosymbolic machines. In Advances in Neural Information Processing Systems (NeurIPS), 2020.
297
+ Johnson, J., Hariharan, B., van der Maaten, L., Fei-Fei, L., Zitnick, C. L., and Girshick, R. Clevr: A diagnostic dataset for compositional language and elementary visual reasoning. In Computer Vision and Pattern Recognition (CVPR), 2017.
298
+ Karazija, L., Laina, I., and Rupprecht, C. Clevrtex: A texture-rich benchmark for unsupervised multi-object segmentation. arXiv preprint arXiv:2111.10265, 2021.
299
+ Ke, N. R., Didolkar, A., Mittal, S., Goyal, A., Lajoie, G., Bauer, S., Rezende, D., Bengio, Y., Mozer, M., and Pal, C. Systematic evaluation of causal discovery in visual model based reinforcement learning. Advances in Neural Information Processing Systems (NeurIPS), 2022.
300
+ Kipf, T., Elsayed, G. F., Mahendran, A., Stone, A., Sabour, S., Heigold, G., Jonschkowski, R., Dosovitskiy, A., and Greff, K. Conditional object-centric learning from video. In International Conference on Learning Representations (ICLR), 2022.
301
+ Li, L., Wang, B., Verma, M., Nakashima, Y., Kawasaki, R., and Nagahara, H. Scouter: Slot attention-based classifier for explainable image recognition. In International Conference on Computer Vision (ICCV), 2021.
302
+ Lin, Z., Wu, Y.-F., Peri, S. V., Sun, W., Singh, G., Deng, F., Jiang, J., and Ahn, S. Space: Unsupervised object-oriented scene representation via spatial attention and decomposition. In International Conference on Learning Representations (ICLR), 2020.
303
+ Locatello, F., Weissenborn, D., Unterthiner, T., Mahendran, A., Heigold, G., Uszkoreit, J., Dosovitskiy, A., and Kipf, T. Object-centric learning with slot attention. In Advances in Neural Information Processing Systems (NeurIPS), 2020.
304
+ Monnier, T., Vincent, E., Ponce, J., and Aubry, M. Unsupervised layered image decomposition into object prototypes. In International Conference on Computer Vision (ICCV), 2021.
305
+
306
+ Pervez, A., Lippe, P., and Gavves, E. Differentiable mathematical programming for object-centric representation learning. arXiv preprint arXiv:2210.02159, 2022.
307
+ Peyre, G. and Cuturi, M. Computational optimal transport. Foundations and Trends in Machine Learning, 11(5-6): 355-607, 2019.
308
+ Pena, F. A. G., Medeiros, H. R., Dubail, T., Aminbeidokhti, M., Granger, E., and Pedersoli, M. Re-basin via implicit sinkhorn differentiation. arXiv preprint arXiv:2212.12042, 2022.
309
+ Pogancic, M. V., Paulus, A., Musil, V., Martius, G., and Rolinek, M. Differentiation of blackbox combinatorial solvers. In International Conference on Learning Representations (ICLR), 2020.
310
+ Sajjadi, M. S. M., Duckworth, D., Mahendran, A., van Steenkiste, S., Pavetic, F., Lučić, M., Guibas, L. J., Greff, K., and Kipf, T. Object scene representation transformer. In Advances in Neural Information Processing Systems (NeurIPS), 2022.
311
+ Sander, M. E., Ablin, P., Blondel, M., and Peyre, G. Sinkformers: Transformers with doubly stochastic attention. In International Conference on Artificial Intelligence and Statistics (AISTATS), 2022.
312
+ Smirnov, D., Gharbi, M., Fisher, M., Guizilini, V., Efros, A., and Solomon, J. M. Marionette: Self-supervised sprite learning. Advances in Neural Information Processing Systems (NeurIPS), 2021.
313
+ Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L., and Polosukhin, I. Attention is all you need. In Advances in Neural Information Processing Systems (NeurIPS), 2017.
314
+ Villani, C. Optimal transport: old and new, volume 338. Springer, 2009.
315
+ Wei, X., Zhang, T., Li, Y., Zhang, Y., and Wu, F. Multimodality cross attention network for image and sentence matching. In Conference on Computer Vision and Pattern Recognition (CVPR), 2020.
316
+ Wu, Z., Dvornik, N., Greff, K., Kipf, T., and Garg, A. Slotformer: Unsupervised visual dynamics simulation with object-centric models. arXiv preprint arXiv:2210.05861, 2022.
317
+ Yi, K., Gan, C., Li, Y., Kohli, P., Wu, J., Torralba, A., and Tenenbaum, J. B. Clevrer: Collision events for video representation and reasoning. In International Conference on Learning Representations (ICLR), 2019.
318
+
319
+ Zaheer, M., Kottur, S., Ravanbakhsh, S., Poczos, B., Salakhutdinov, R. R., and Smola, A. J. Deep sets. In Advances in Neural Information Processing Systems (NeurIPS), 2017.
320
+ Zhang, Y., Hare, J., and Prügel-Bennett, A. Deep set prediction networks. In Advances in Neural Information Processing Systems (NeurIPS), 2019.
321
+ Zhang, Y., Zhang, D. W., Lacoste-Julien, S., Burghouts, G. J., and Snoek, C. G. M. Multiset-equivariant set prediction with approximate implicit differentiation. In International Conference on Learning Representations (ICLR), 2022.
322
+
323
+ # A. Marginals in Sinkhorn and EMD
324
+
325
+ As we mention in the main text, we need to account for the (typical) case of the number of inputs $n$ and the number of slots $m$ differing, i.e. with a cost matrix $C \in \mathbb{R}^{m \times n}$ . The problem is that it is impossible to make every row and every column of the transport map sum to 1 when the number of rows and columns is different. Fortunately, there is standard practice for how to deal with this case in optimal transport (Peyre & Cuturi, 2019; Cuturi, 2013; Bonneel et al., 2011). We can define non-negative marginals $\pmb{a} \in \mathbb{R}^m$ and $\pmb{b} \in \mathbb{R}^n$ that specify the row and column sums of the transport map respectively. If $\sum_{i} \pmb{a}_{i} = \sum_{j} \pmb{b}_{j}$ , then convergence is as normal.
326
+
327
+ In our case, we learn both $\mathbf{a} = m \cdot \mathrm{softmax}(h_{\mathbf{a}}(\mathbf{Z}))$ and $\mathbf{b} = m \cdot \mathrm{softmax}(h_{\mathbf{b}}(\mathbf{X}))$ with neural networks $h_{\mathbf{a}}: \mathbb{R}^d \to \mathbb{R}$ and $h_{\mathbf{b}}: \mathbb{R}^c \to \mathbb{R}$ that are shared across the $m$ slots or $n$ input elements respectively. These allow the model to put focus on important input elements (e.g. the inputs corresponding to objects) and ignore unimportant input elements (e.g. the inputs corresponding to the background), as well as put focus on the relevant number of slots. Since both softmaxes sum to one, we have $\sum_{i} \mathbf{a}_{i} = \sum_{j} \mathbf{b}_{j} = m$ so there is no problem with convergence.
328
+
329
+ For the Sinkhorn algorithm, it now repeatedly alternates normalizing all the rows to sum to $\pmb{a}$ , then all the columns to sum to $\pmb{b}$ . For the EMD solver that we use (Bonneel et al., 2011), these marginals are standard parameters in the algorithm. In the main text, we omit these marginals whenever we refer to sinkhorn or emd for simplicity of notation.
330
+
331
+ # B. Enforcing $C'$ to be similar to $C$
332
+
333
+ The following discussion is not critical to understanding the main text, since we find empirically that with the right initialization (e.g. $C' = C + \epsilon$ with $\epsilon_{ij} \sim \mathcal{N}(0, 10^{-6})$ ), learning is not a problem. We only find that this variant is
334
+
335
+ necessary with an initialization such as $\epsilon \sim \mathcal{N}(0, I)$ . As we mention in the main text, the amount of noise is not important as long as it remains above machine precision after applying sinkhorn, which can be easily checked a-priori.
336
+
337
+ In order to enforce $C'$ to be related to $C$ more explicitly, we define the following objective instead:
338
+
339
+ $$
340
+ \begin{array}{l} \operatorname {M E S H} (C) = \underset {C ^ {\prime}} {\arg \min } [ H (\operatorname {s i n k h o r n} (C ^ {\prime})) \\ \left. + \alpha | | \operatorname {s i n k h o r n} \left(\boldsymbol {C} ^ {\prime}\right) \boldsymbol {S} - \operatorname {s i n k h o r n} (\boldsymbol {C}) | | ^ {2} \right] \tag {13} \\ \end{array}
341
+ $$
342
+
343
+ The second term relates $C'$ to $C$ directly with a regularization factor $\alpha$ . $S$ is a similarity matrix, which we will define shortly. The idea behind it is to allow costs to be freely changed among similar slots, but disallow this for dissimilar slots. The aim of $||\mathrm{sinkhorn}(C')S - \mathrm{sinkhorn}(C)||^2$ is thus to make sure that $\mathrm{sinkhorn}(C')$ looks the same as $\mathrm{sinkhorn}(C)$ after allowing weight in the transport map to be moved around among similar slots.
344
+
345
+ Example Consider the case where we have three slots: $Z = [x, x, y]$ and three inputs $X = [\alpha, \beta, \gamma]$ . Let us assume for this example that the cost matrix prefers associating $\gamma$ with $y$ and both $\alpha$ and $\beta$ with $x$ . Computing unregularized optimal transport solutions would therefore give us either of two solutions:
346
+
347
+ $$
348
+ \boldsymbol {T} _ {1} = \left[ \begin{array}{l l l} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{array} \right] \quad \text {o r} \quad \boldsymbol {T} _ {2} = \left[ \begin{array}{l l l} 0 & 1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 1 \end{array} \right] \tag {14}
349
+ $$
350
+
351
+ However, the Sinkhorn algorithm is unable to break the tie between the two $x$ slots, so even with a temperature approaching 0, we obtain the following result:
352
+
353
+ $$
354
+ \operatorname {s i n k h o r n} (C) = \left[ \begin{array}{l l l} 0. 5 & 0. 5 & 0 \\ 0. 5 & 0. 5 & 0 \\ 0 & 0 & 1 \end{array} \right] \tag {15}
355
+ $$
356
+
357
+ Suppose we have a similarity matrix $\tilde{\pmb{S}}\in \mathbb{R}^{m\times m}$ ( $m$ is the number of slots) that measures pairwise similarities ranging from 0 to 1:
358
+
359
+ $$
360
+ \tilde {\boldsymbol {S}} = \left[ \begin{array}{l l l} 1 & 1 & 0 \\ 1 & 1 & 0 \\ 0 & 0 & 1 \end{array} \right] \tag {16}
361
+ $$
362
+
363
+ The first two slots are similar amongst themselves but dissimilar to the $y$ slot. If we normalize each column of $\tilde{S}$ to
364
+
365
+ sum to 1 to obtain $S$ , then we see the following:
366
+
367
+ $$
368
+ \begin{array}{l} \underbrace {\left[ \begin{array}{l l l} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{array} \right]} _ {T _ {1}} \underbrace {\left[ \begin{array}{l l l} 0 . 5 & 0 . 5 & 0 \\ 0 . 5 & 0 . 5 & 0 \\ 0 & 0 & 1 \end{array} \right]} _ {S} = \underbrace {\left[ \begin{array}{l l l} 0 . 5 & 0 . 5 & 0 \\ 0 . 5 & 0 . 5 & 0 \\ 0 & 0 & 1 \end{array} \right]} _ {\text {s i n k h o r n} (C)} (17) \\ \underbrace {\left[ \begin{array}{l l l} 0 & 1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 1 \end{array} \right]} _ {T _ {2}} \underbrace {\left[ \begin{array}{l l l} 0 . 5 & 0 . 5 & 0 \\ 0 . 5 & 0 . 5 & 0 \\ 0 & 0 & 1 \end{array} \right]} _ {S} = \underbrace {\left[ \begin{array}{l l l} 0 . 5 & 0 . 5 & 0 \\ 0 . 5 & 0 . 5 & 0 \\ 0 & 0 & 1 \end{array} \right]} _ {\operatorname {s i n k h o r n} (C)} (18) \\ \end{array}
369
+ $$
370
+
371
+ This means that $\operatorname{sinkhorn}(C') = T_1$ and $\operatorname{sinkhorn}(C') = T_2$ are both valid solutions for the minimization of $||\operatorname{sinkhorn}(C')S - \operatorname{sinkhorn}(C)||^2$ . Note that any other permutation matrix for $T$ (i.e. one where there is not a 1 in the bottom right corner) would not be a valid solution. This restricts Equation 9 to only consider transport maps that are convex combinations of $T_1$ and $T_2$ for this example, with the entropy minimization preferring $T_1$ and $T_2$ specifically. The small amount of noise in the $C'$ initialization arbitrarily makes it prefer one of the two.
372
+
373
+ Definition We define the similarity matrix $\tilde{S}_{ij} = g(Z_i, Z_j)$ , where $g: \mathbb{R}^c \times \mathbb{R}^c \to \mathbb{R}$ is a small neural network that takes pairs of slots as input and produces a similarity score as output. We then normalize each column of $\tilde{S}$ to sum to 1 by applying softmax on each column.
374
+
375
+ $$
376
+ \boldsymbol {S} = \operatorname {s o f t m a x} (\tilde {\boldsymbol {S}}) \tag {19}
377
+ $$
378
+
379
+ If we set up a training task for the example described above, we observe that $S$ is learned to be virtually the same as the $S$ we use in the example.
380
+
381
+ # C. Multiset-equivariance of SA-SH, SA-EMD, and SA-MESH
382
+
383
+ First, we show that SA-SH is set-equivariant, and therefore not exclusively multiset-equivariant.
384
+
385
+ Proposition C.1. SA-SH is set-equivariant.
386
+
387
+ Proof. Slot attention is set-equivariant (Locatello et al., 2020). All the additional operations in SA-SH are set-equivariant for a similar reason to Deep Sets (Zaheer et al., 2017): only sum, broadcast, and elementwise operations are used in Sinkhorn. Since composition of set-equivariant operations maintains set-equivariance, SA-SH is set-equivariant. $\square$
388
+
389
+ Proposition C.2. SA-EMD and SA-MESH are exclusively multiset-equivariant.
390
+
391
+ Proof. To show exclusive multiset-equivariance, we need to show that they are not set-equivariant, but still multiset-equivariant. We begin with the former.
392
+
393
+ To show that SA-EMD and SA-MESH are not set-equivariant, it is enough to give a counter-example. Suppose we have the following cost matrix:
394
+
395
+ $$
396
+ \left[ \begin{array}{l l} 1 & 1 \\ 1 & 1 \end{array} \right] \tag {20}
397
+ $$
398
+
399
+ Running EMD gives us one of the following transport maps as the solution, depending on the arbitrary tiebreaking in the EMD implementation.
400
+
401
+ $$
402
+ \left[ \begin{array}{l l} 1 & 0 \\ 0 & 1 \end{array} \right] \quad \text {o r} \quad \left[ \begin{array}{l l} 0 & 1 \\ 1 & 0 \end{array} \right] \tag {21}
403
+ $$
404
+
405
+ Both have zero entropy, hence they are also possible solutions when the MESH objective is perfectly optimized. Set-equivariance requires that a permutation applied to the input in Equation 20 changes the output by the same permutation. As pointed out by Zhang et al. (2022), this does not happen because the arbitrary tiebreaking remains the same. Therefore, both SA-EMD and SA-MESH are not set-equivariant.
406
+
407
+ To show that they are multiset-equivariant, first recall the definition of multiset-equivariance.
408
+
409
+ $$
410
+ \begin{array}{l} \forall \boldsymbol {X} \in \mathbb {R} ^ {n \times c}, \forall \boldsymbol {P} _ {1} \in \Pi , \exists \boldsymbol {P} _ {2} \in \Pi : \\ f \left(\boldsymbol {P} _ {1} \boldsymbol {X}\right) = \boldsymbol {P} _ {2} f (\boldsymbol {X}) \wedge \boldsymbol {P} _ {1} \boldsymbol {X} = \boldsymbol {P} _ {2} \boldsymbol {X}. \\ \end{array}
411
+ $$
412
+
413
+ EMD produces a solution with the minimum total cost by definition. This means that the transport map must remain the same, up to permutation. This is because if any of the values in the transport map were to change (aside from being permuted), then the original solution was not a minimum, which is a contradiction. Therefore, we know that a $P_{2}$ must exist for any $P_{1}$ .
414
+
415
+ In the same way with MESH, with infinitesimally small noise, the only thing that can change is the permutation of the solution: if no ties are broken the noise has virtually no effect because the subsequent operations in MESH are continuous, if a tie is broken then the ordering of the tie is random. In either case, we can again always find a $P_{2}$ for every $P_{1}$ on the inputs, since the values in the solution remain the same up to permutation.
416
+
417
+ We have thus shown that SA-EMD and SA-MESH are not set-equivariant, but are multiset-equivariant (i.e. exclusively multiset-equivariant).
418
+
419
+ # D. Sinkhorn algorithm implementation
420
+
421
+ Ideally, we want to compute the Sinkhorn algorithm for as few steps as possible since it is used in every MESH step, which means that we also have to differentiate through the
422
+
423
+ Sinkhorn algorithm in every MESH step. However, we also need to run it for a sufficient number of steps for (good enough) convergence. Fortunately, because we repeatedly run the Sinkhorn algorithm on similar inputs over different MESH steps, we can optimize its implementation. The idea is that the gradient descent for minimizing the entropy makes small changes (especially near MESH convergence), which allows us to reuse computation between different MESH steps.
424
+
425
+ ![](images/ecf95097fb35fdb2906eb0d6036ddccc6fea63b0fafb9ad9347cba41cf242de4.jpg)
426
+ Figure 3. Mean absolute error gap to the fully converged Sinkhorn for the two different Sinkhorn implementations for varying numbers of MESH iterations. Both implementations always use 5 Sinkhorn iterations and thus have comparable computational costs. Reusing $\mathbf{u}$ and $\mathbf{b}$ is clearly more effective.
427
+
428
+ If the entropy minimization has converged, then the Sinkhorn output does not change. This means that if we keep track of the operations we performed in the previous SA-MESH iteration, we can simply reapply them. Let us take a look at these operations: the Sinkhorn algorithm (multiplicatively) rescales rows and columns repeatedly. Multiplication is commutative, so we can collect all the row normalizations together into a single row normalizer $\pmb{u}$ and all the column normalizations into a single column normalizer $\pmb{v}$ . Applying these two normalizers on the (exponentiated) cost matrix gives us exactly the same result as if we had manipulated the matrix with the normalizations directly. The next time we run the Sinkhorn algorithm with a slightly changed cost matrix, we can bootstrap the algorithm with the previously found $\pmb{u}$ and $\pmb{v}$ . We can then run a few more iterations to account for the changes in the cost matrix, giving us a new $\pmb{u}$ and $\pmb{v}$ .
429
+
430
+ In Figure 3, we ablate whether there are benefits to reusing $\mathbf{u}$ and $\mathbf{v}$ in SA-MESH. In particular, we compute the ideal solution by running the Sinkhorn algorithm until convergence at every ME iteration. Then we examine whether reusing $\mathbf{u}$ and $\mathbf{v}$ helps close the gap to the ideal solution
431
+
432
+ ![](images/efdc30d755f6c3c92cace180612a5ecbaea9a1f25a2dda62b72823d25ca145e2.jpg)
433
+ Figure 4. Same gradient norm plot as Figure 1 but without normalizing each model to have a maximum of 1. The only difference between left and right is the scale of the y-axis. This shows that the gradient norm for tempered SH varies drastically with temperature, while the gradient norm of MESH remains more similar across learning rates. This makes tuning the learning rate hyperparameter easier as it can be considered more independently from other hyperparameters of the model.
434
+
435
+ ![](images/36f06737a35f3093c88ffc84d8df3ce3f1af9eacbe8d02cb6a70002ae92bde36.jpg)
436
+
437
+ when we limit the number of SH iterations. At 1 ME iteration there are no $\pmb{u}$ and $\pmb{v}$ for bootstrapping available, so both exhibit the same gap. At more than 1 ME iteration we observe that reusing $\pmb{u}$ and $\pmb{v}$ helps in narrowing the gap to the ideal solution, or equivalently, can achieve the same approximation with fewer iterations.
438
+
439
+ We do not claim that this technique of collecting Sinkhorn operations into $\mathbf{u}$ and $\mathbf{v}$ is novel, as there are several implementations that use this trick for performing the Sinkhorn algorithm. Usually, it is a minor implementation detail since the approaches of manipulating the matrix directly and collecting normalizations into $\mathbf{u}$ and $\mathbf{v}$ are mathematically equivalent. In our case however, this formulation leads to a concrete benefit due to our setup where we run the Sinkhorn algorithm on similar inputs, which allows us to reuse $\mathbf{u}$ and $\mathbf{v}$ in a beneficial way.
440
+
441
+ # E. Gradients of tempered SH and MESH, without normalizing their scale
442
+
443
+ In Figure 4, we show the same gradient norms as in Figure 1. However, rather than normalizing each model to have a maximum of 1 (which is more useful for visualizing them all at once), we maintain their native scaling. This shows that changing the SH temperature has a major effect on the scale of the gradients while changing the MESH learning rate only has minor effects on the gradients (but still significant effects on entropy reduction). In other words, the amount of entropy minimization can be changed without major impacts on the hyperparameters of other parts of the network.
444
+
445
+ # F. Experimental details
446
+
447
+ # F.1. Random object detection
448
+
449
+ We generate a dataset of 64,000 data points to train on, each being a multiset with five 32-dimensional objects sampled from $\mathcal{N}(0,\sigma^2\pmb{I})$ and 100 zero vectors. We directly apply slot attention on this: the dimensionality of the slot attention weights are all 32. Since we know that there are always five objects, we set the number of slots to five. The loss is computed by computing a mean squared error between all pairs of predicted and ground-truth objects, then using the Hungarian algorithm find the matching with the lowest loss. We find that using implicit differentiation of slots (Chang et al., 2022) is significantly more stable on this dataset, so we use it for all models. We train all models for 20 epochs with a batch size of 64 (1,000 steps each epoch).
450
+
451
+ # F.2. Object detection on CLEVR
452
+
453
+ We largely follow same training setup as DSPN and iDSPN (Zhang et al., 2019; 2022) and adapt the slot attention implementation to it. Matching Zhang et al. (2022) and Locatello et al. (2020), we resize the input images to $128 \times 128$ . To compute the loss, we use the Hungarian algorithm to compute the least-cost matching between predicted objects and ground-truth objects.
454
+
455
+ # F.3. Object discovery
456
+
457
+ We compute the temporal consistency (TC) by first matching the predicted objects in each frame to their corresponding ground-truth objects. Then, we calculate the proportion of objects that have the same slot in both frames out of those that appear in both frames. To find the optimal assign
458
+
459
+ ment between the predicted and ground-truth objects, we first compute all pairwise IoUs between the predicted and ground-truth masks. We then invert these IoUs by applying $1 - \mathrm{IoU}$ and use the Hungarian matching algorithm to find the best match—the one with the highest mIoU.
460
+
461
+ We compute the mIoU in a similar manner as the TC metric, by finding the matching between the ground-truth objects and the predicted objects that results in the highest mIoU.
462
+
463
+ Multi-dSprites. We closely follow the experimental setup described by Locatello et al. (2020). Specifically, we use the same image encoder, decoder, and hyperparameters where applicable. Locatello et al. (2020) used 500k training steps, while all of our runs were trained for 530 epochs, which results in slightly fewer than 500k training steps.
464
+
465
+ ClevrTex. We pre-process the images by applying the same center crop as suggested by Karazija et al. (2021) and resize the images to $64 \times 64$ resolution instead of $128 \times 128$ resolution. This allows us to use the same neural network architecture as we did for the Multi-dSprites dataset.
466
+
467
+ Since the dataset has more complicated visuals we increase the model size by increasing the channel sizes. In particular, we double the number of channels in the image encoder and decoder to 64, and we double the dimensions of the slots to 128 (with the MLP in slot attention having an intermediate dimension of 256). We again train all models for 530 epochs which correspond to around $330\mathrm{k}$ gradient update steps in this case. The maximum number of objects in an image is 10, so we set the number of slots to 11.
468
+
469
+ # F.4. CLEVRR
470
+
471
+ We construct the datasets from the 20k videos in the CLEVRER dataset, by picking two frames at specific timesteps from each video. In the CLEVRER-S dataset, we use the first and 16th video frames. In the second dataset, we use the first and 128th (last) frames. The proportion of examples where new objects appear increases with the time gap between the two frames, and similarly the amount of displacement for objects that are in both frames increases too. We show examples from the two dataset variants in Figure 6.
472
+
473
+ For the distance function $d$ that computes the cost matrix of the optimal transport problem in SA-MESH, we empirically find that the cosine distance works better in this case than the $l2$ distance. We suspect that since the $l2$ distance allows the slots to be pushed arbitrarily far apart that learning might slow down in the later stages of training.
474
+
475
+ We extend the model which we used in the Multi-dSprites experiment to video data. Our setup is similar to Kipf et al (2022), but we do not use a predictor model (except for
476
+
477
+ the SA learned noise baseline) to update the slots when transitioning from one video frame to the next. In particular, the model first applies the image encoder to all video frames independently to compute the input feature maps. Next, the SA (or our proposed variants) is applied to the features of one video frame at a time, and every time the slots are initialized from the slots of the previous frame. Finally, each image is decoded independently. The learned noise baseline uses a 2-layer MLP with LayerNorm to predict the mean and variance of a Gaussian, from which the initial slots are sampled for the next frame, following the stochastic SAVi setup by Wu et al. (2022). We use 8 slots.
478
+
479
+ # G. CLEVR object prediction results
480
+
481
+ In Table 6 we show our results for CLEVR object prediction without implicit differentiation of slots (Chang et al., 2022). All results are slightly lower than the results reported in Table 2, but the overall message remains exactly the same. The only major difference is that SA-SH performs much worse compared to SA-SH†.
482
+
483
+ # H. Extra ablations
484
+
485
+ Additional slot attention iterations In general the benefit of more iterations is minor (see ablations in Locatello et al. (2020), Appendix C) and using too many can hurt in some cases, which is why many recent works (Wu et al., 2022; Kipf et al., 2022) set the number of iterations to 3 or even fewer. We ran an additional experiment where we trained the plain slot attention baseline on Multi-dSprites with 5 iterations resulting in $81.9 \pm 6.1$ FG-ARI, which is worse than the $92.2 \pm 0.5$ achieved with 3 iterations reported in our main results. Also note that the slot attention module is only a part of the full neural network and is not the bottleneck when using larger encoders.
486
+
487
+ Learned slot initializations In our perspective, the initialization should be thought of as separate to the slot attention method itself. A different initialization does not change the fact that the slots can collapse, especially in cases like the video datasets where the initialization is not a free parameter but dependent on the previous timestep. Thus, having control over the initialization should not be relied upon.
488
+
489
+ Locatello et al. (2020) report in their Appendix B that learning the initial slots decreases the performance in unsupervised learning. We ran experiments with SA using a learned initialization on Multi-dSprites to evaluate this as well. On the Multi-dSprites dataset, SA with a learned initialization achieves $93.0 \pm 1.0$ FG-ARI, which is comparable to the standard SA at $92.2 \pm 0.5$ and remains lower than the $95.6 \pm 0.2$ of SA-MESH.
490
+
491
+ Table 6. Results on CLEVR object property multiset prediction, average precision (AP) in % (mean ± standard deviation) over 5 random seeds, higher is better. All SA results are based on our re-implementation. SA (original) results copied from Locatello et al. (2020), iDSPN results from Zhang et al. (2022).
492
+
493
+ <table><tr><td>Model</td><td>AP∞</td><td>AP1</td><td>AP0.5</td><td>AP0.25</td><td>AP0.125</td><td>AP0.0625</td><td>Time</td></tr><tr><td>iDSPN (Zhang et al., 2022)</td><td>98.8±0.5</td><td>98.5±0.6</td><td>98.2±0.6</td><td>95.8±0.7</td><td>76.9±2.5</td><td>32.3±3.9</td><td>—</td></tr><tr><td>SA (original) (Locatello et al., 2020)</td><td>94.3±1.1</td><td>86.7±1.4</td><td>56.0±3.6</td><td>10.8±1.7</td><td>0.9±0.2</td><td>—</td><td>—</td></tr><tr><td>SA</td><td>89.1±1.2</td><td>85.7±1.0</td><td>73.3±1.2</td><td>35.4±1.5</td><td>9.0±0.8</td><td>2.0±0.3</td><td>2.4 h</td></tr><tr><td>SA-SH</td><td>95.6±1.0</td><td>94.0±1.1</td><td>84.5±1.7</td><td>41.3±3.0</td><td>10.4±0.7</td><td>2.5±0.4</td><td>2.5 h</td></tr><tr><td>SA-EMD</td><td>99.2±0.2</td><td>98.7±0.4</td><td>97.0±0.8</td><td>82.4±1.2</td><td>34.0±2.2</td><td>8.3±0.9</td><td>9.7 h</td></tr><tr><td>SA-MESH</td><td>99.2±0.3</td><td>99.1±0.3</td><td>98.8±0.5</td><td>88.3±0.8</td><td>40.8±1.0</td><td>10.6±0.3</td><td>2.5 h</td></tr></table>
494
+
495
+ # I. Alternative MESH objective
496
+
497
+ In Section 4 we choose the entropy as the inner objective function because the goal was to reverse the effect of the entropy-regularized optimal transport version. Alternatively, it is possible to learn a neural network with scalar inputs and outputs in place of the entropy function. For the neural network, we choose a simple 2-layer MLP with ReLU activations and 32 hidden dimensions. We plot the derivative of a learned objective function in Figure 5b. Its shape is similar to the derivative of the entropy Figure 5a, but learning it incurs additional compute compared to simply using the entropy function $H$ .
498
+
499
+ Justified by this analysis we can directly use the entropy function as the MESH objective for improved efficiency. Empirically we observe that we do not even need to backpropagate through the gradient descent optimization procedure of MESH and it suffices to treat MESH as the identity function during backprop. One perspective that might explain this: since the negative derivative of $H$ is a monotonic increasing function, changes to the input will also affect the output in the same direction.
500
+
501
+ ![](images/9b28aecab9c821ba31a2f68122177466cf045ff923fcf1d718fbc53fcb3e6361.jpg)
502
+ (a) $H$
503
+
504
+ ![](images/5ea7176d2373a6634b57d234d538229e18abc886b058a6755e407a12d57b9a71.jpg)
505
+ (b) MLP
506
+ Figure 5. Derivative of the objective function in MESH
507
+
508
+ # J. Object discovery example results
509
+
510
+ In the following, we show examples of SA and SA-MESH performing object discovery on the various datasets that we use. We always show the original image on the left, followed by either the attention maps for each slot or the final alpha masks for each slot. The attention map or the alpha masks are multiplied with the original image to make it easier to tell how precise their locations are.
511
+
512
+ - Figure 7 shows the intermediate attention maps over the three slot attention iterations on the Multi-dSprites dataset.
513
+ - Figure 8 shows the final per-slot alpha masks on the Multi-dSprites dataset.
514
+ - Figure 9 shows the intermediate attention map of the last slot attention iteration, as well as the final per-slot alpha masks on the ClevrTex dataset.
515
+ Figure 10 shows the final per-slot alpha masks on the CLEVRER-S and CLEVRER-L datasets.
516
+
517
+ Please refer to the individual figure captions for a more detailed description of observations on these results.
518
+
519
+ ![](images/8bdbc94f00b91655d4202e48e4069f09ae3de43aeb00aabb96ad54b484afaf11.jpg)
520
+ Frame 1 Frame 16
521
+ Figure 6. Examples from the two datasets derived from CLEVRR. Significant changes like multiple new objects appearing occur less frequently in CLEVRR-S. Objects can be significantly displaced from one frame to the other in CLEVRR-L.
522
+
523
+ ![](images/52c63ac68a24fddd49e42a17e06a464ac347d251f033194d59fbb149a71e3170.jpg)
524
+ Frame 1 Frame 128
525
+
526
+ ![](images/554c2333cac06533e2b74651f1c4104bbc090e51f603dc3484dc0e44bdc69e51.jpg)
527
+ (a) SA
528
+ Figure 7. Attention maps for all three slot attention iterations for five different examples from the validation split of Multi-dSprites. Note how the shade of SA is generally darker indicating higher attention values even in background areas. In the third example, we can see how SA models the pink and blue ellipses using one slot while splitting the purple heart over two slots. In contrast, SA-MESH is able to route the three objects into three different slots in the second slot attention iteration.
529
+
530
+ ![](images/0aab2d70b06a29864f3f057f39a0923f6a9cc59bf1d6579734787c1f487d18f6.jpg)
531
+ (b) SA-MESH
532
+
533
+ ![](images/29d286bf304add52d2db6ab89114871875b02586e1de2a2fbd5ff19e4d2c7175.jpg)
534
+ (a) SA
535
+ Figure 8. Predicted alpha masks from the validation split of Multi-dSprites. In general, the masks for SA-MESH are sharper than for SA. For example, in the last row, the brown heart is only recognizable as a blown blob for SA, but is a distinct heart shape for SA-MESH. In the third example, SA splits the purple heart into two slots, while SA-MESH models it with one as desired.
536
+
537
+ ![](images/ae4af2f7238d4809843cefe869b19b84741e466f1e18e48b70f7002518427d8d.jpg)
538
+ (b) SA-MESH
539
+
540
+ ![](images/ac441f16606ddabb8bd684b27deb34abd6457b527022fa8ca6a4ff428cb309fd.jpg)
541
+ (a) SA
542
+
543
+ ![](images/bf694dd92858629e469d15d9c0ae3d88842b4b7c240da758f84eee2a10744a88.jpg)
544
+ (b) SA-MESH
545
+ Figure 9. Attention maps (top) and masks (bottom) for four different examples from the validation split of ClevrTex. SA commonly learns that each slot should attend to a spatial region as opposed to a specific object. SA-MESH on the other hand is better able to localize individual objects, though the background is often still handled with a region-specific approach.
546
+
547
+ ![](images/de3c2ae2415f1b5bfb870593837117945d79957636a959b3dbbf544267f3b7bc.jpg)
548
+ Figure 10. Example alpha masks for CLEVRER-S and CLEVRER-L. Possibly due to the difficulty of handling multiple new objects, SA and its noise variants choose a region-based decomposition on CLEVRER-L instead of an object-based decomposition like on CLEVRER-S. SA-SH and SA-MESH learn an object-based decomposition for both datasets.
unlockingslotattentionbychangingoptimaltransportcosts/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:44c882d098f6092d03cbb4bf208007d19b472cc8c6d93ee6d65f55b37c6cab86
3
+ size 1145372
unlockingslotattentionbychangingoptimaltransportcosts/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:52286b58d50dbd001f066af280af6e49dbfebcc91cacc4f000fd92046e35057c
3
+ size 673145
unscentedautoencoder/9919ec0e-11db-4e67-a3af-3305e9e64e5f_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f3849d093fe6a08ad1d0cc87b15a44e3b0308499f97cf16343eeaefe0409cf49
3
+ size 148885
unscentedautoencoder/9919ec0e-11db-4e67-a3af-3305e9e64e5f_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:61615ca80161dcecda3bd51f334f0179084cc76ed9da6e95a2c0412bf6b5baf8
3
+ size 171391
unscentedautoencoder/9919ec0e-11db-4e67-a3af-3305e9e64e5f_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:04acc7e0870c9794bbd9ea4764d73b843336e49c08820bc7672e3029fa72c917
3
+ size 1226246
unscentedautoencoder/full.md ADDED
@@ -0,0 +1,520 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Faris Janjoš<sup>1</sup> Lars Rosenbaum<sup>1</sup> Maxim Dolgov<sup>1</sup> J. Marius Zöllner<sup>2</sup>
2
+
3
+ # Abstract
4
+
5
+ The Variational Autoencoder (VAE) is a seminal approach in deep generative modeling with latent variables. Interpreting its reconstruction process as a nonlinear transformation of samples from the latent posterior distribution, we apply the Unscented Transform (UT) - a well-known distribution approximation used in the Unscented Kalman Filter (UKF) from the field of filtering. A finite set of statistics called sigma points, sampled deterministically, provides a more informative and lower-variance posterior representation than the ubiquitous noise-scaling of the reparameterization trick, while ensuring higher-quality reconstruction. We further boost the performance by replacing the Kullback-Leibler (KL) divergence with the Wasserstein distribution metric that allows for a sharper posterior. Inspired by the two components, we derive a novel, deterministic-sampling flavor of the VAE, the Unscented Autoencoder (UAE), trained purely with regularization-like terms on the per-sample posterior. We empirically show competitive performance in Fréchet Inception Distance (FID) scores over closely-related models, in addition to a lower training variance than the VAE<sup>1</sup>.
6
+
7
+ # 1. Introduction
8
+
9
+ The Variational Autoencoder (VAE) (Rezende et al., 2014; Kingma et al., 2015) is a widely used method for learning deep latent variable models via maximization of the data likelihood using a reparametrized version of the Evidence Lower Bound (ELBO). Deep latent variable models are used as generative models in a variety of applica
10
+
11
+ $^{1}$ Robert Bosch GmbH, Corporate Research, 71272 Renningen, Germany $^{2}$ Research Center for Information Technology (FZI), 76131 Karlsruhe, Germany. Correspondence to: <first-name.last-name@de.bosch.com>.
12
+
13
+ Proceedings of the $40^{th}$ International Conference on Machine Learning, Honolulu, Hawaii, USA. PMLR 202, 2023. Copyright 2023 by the author(s).
14
+
15
+ $^{1}$ Code available at: https://github.com/boschresearch/unscented-autoencoder
16
+
17
+ ![](images/28eb52e18ba92c63ea200feba999b13882e7f9e6ba0fb888f1a90fa40d3febf6.jpg)
18
+
19
+ ![](images/340db67280ed30b4d99e5ff95fd0261f72ca19ae7756b2ba900f6e839003fa30.jpg)
20
+ Figure 1: The VAE decoder $f_{\theta}(\cdot)$ can be interpreted as a nonlinear mapping of the Gaussian posterior distribution generated by the encoder, resulting in a non-Gaussian output distribution. The standard VAE (top) samples randomly from the posterior (black points) and matches each decoded sample to the ground truth (green star). Our model (bottom) samples and transforms fixed posterior sigma points (red) instead. By matching the mean of the transformed points, we push the entire output distribution to resemble the ground truth.
21
+
22
+ tion domains such as image (Vahdat & Kautz, 2020), language (Bowman et al., 2015; Kusner et al., 2017), and dynamics modeling (Karl et al., 2016). A good generative model requires the VAE to produce high-quality samples from the prior latent variable distribution and a disentangled latent representation is desired to control the generation process (Higgins et al., 2017). Another important application of deep latent variable models is representation learning, where the goal is to induce a latent representation facilitating downstream tasks (Bengio et al., 2013; Townsend et al., 2019; Tripp et al., 2020; Rombach et al., 2022). In many of these tasks a good sample quality, as well as a 'well-behaved' latent representation with a high reconstruction accuracy is desired.
23
+
24
+ Since their introduction, VAEs have been one of the methods of choice in generative modeling due to their comparatively easy training and the ability to map data to a lower dimensional representation as opposed to generative adversarial networks (Goodfellow et al., 2014). However, despite their popularity there are still open challenges in VAE training addressed by recent works. A major problem of VAEs is their tendency to have a trade-off between the quality of samples from the prior and the reconstruction qual
25
+
26
+ ity. This trade-off can be attributed to overly simplistic priors (Bauer & Mnih, 2019), encoder/decoder variance (Dai & Wipf, 2019), weighting of the KL divergence regularization (Higgins et al., 2017; Tolstikhin et al., 2018), or the aggregated posterior not matching the prior (Tolstikhin et al., 2018; Ghosh et al., 2019). Furthermore, the VAE objective can be prone to spurious local maxima leading to posterior collapse (Chen et al., 2017; Lucas et al., 2019; Dai et al., 2020), which is characterized by the latent posterior (partially) reducing to an uninformative prior. Finally, the variational objective requires approximations of expectations by sampling, which causes increased gradient variance (Burda et al., 2016) and makes the training sensitive to several hyperparameters (Bowman et al., 2015; Higgins et al., 2017).
27
+
28
+ Our main technical contributions are two modifications to the original VAE objective resulting in an improved sample and reconstruction quality. We propose to use a well-known algorithm from the filtering and control literature, the Unscented Transform (UT) (Uhlmann, 1995), to obtain lower-variance, albeit potentially biased gradient estimates for the optimization of the variational objective. A lower variance is achieved by only sampling at the sigma points of the variational posterior and transforming these points with a deterministic decoder. In this context, we show that reconstructing the entire posterior distribution via its sigma points (visualized in Fig. 1) is superior in resulting image quality to reconstructing individual random samples. Furthermore, we observe that the regularization toward a standard normal prior using a KL divergence often harshly penalizes low variance along some components even though the low variance is usually beneficial for reconstruction. Thus, we use a different regularization based on the Wasserstein metric (Patrini et al., 2020). To account for resulting sharper posteriors, we add a regularizer for decoder smoothness around the mean encoded value, similar to (Ghosh et al., 2019). We conduct rigorous experiments on several standard image datasets to compare our modifications against the VAE baseline, the closely-related Regularized Autoencoder (RAE) (Ghosh et al., 2019), the Importance-Weighted Autoencoder (IWAE) (Burda et al., 2016), as well as the Wasserstein Autoencoder (WAE) (Tolstikhin et al., 2018).
29
+
30
+ # 2. Related Work
31
+
32
+ Many recent works on VAEs focus on understanding and addressing still existing problems like undesired posterior collapse (Dai et al., 2020), trade-off between sample and reconstruction quality (Tolstikhin et al., 2018; Bauer & Mnih, 2019), or non-interpretable latent representations (Rolinek et al., 2019; Higgins et al., 2017). Other recent works suggest to move from the probabilistic VAE
33
+
34
+ models to deterministic models, such as the RAE in (Ghosh et al., 2019); our model can be considered as part of this class. As previously mentioned, we employ two major modifications to the VAE, namely the Unscented Transform and the Wasserstein metric, as well as decoder regularization; we outline the section accordingly.
35
+
36
+ We use the Unscented Transform (Uhlmann, 1995) from the field of nonlinear filtering within signal processing. In this context, the signal state estimate is often assumed to be Gaussian in order to maintain tractability. However, nonlinear prediction and measurement models always invalidate this assumption at each time step so that a reapproximation becomes necessary. A commonly used approach is the Extended Kalman Filter (EKF), where a linearization of the models is employed so that the Gaussian state remains Gaussian during filtering. In contrast, alternative approaches that represent the Gaussian state (assuming application in the context of the VAE posterior) with samples for propagation and update have emerged. These approaches can be clustered according to the employed sampling method - random as in (Gaussian) particle filters (Doucet & Johansen, 2011) or deterministic, e.g. in the UKF (Julier et al., 2000). In the UKF, the $n$ -dimensional Gaussian is approximated with $2n + 1$ deterministic samples, which can be propagated through the nonlinearities and are sufficient for computing the statistics of a Gaussian distribution, i.e. its mean and covariance. This procedure is referred to as the Unscented Transform (UT).
37
+
38
+ The use of deterministic sampling<sup>2</sup> aims to achieve a good coverage of the distribution represented with the mean and covariance. Although this approach produces biased estimates of the involved expectations compared to random sampling due to non-i.i.d. samples, it often captures well the nonlinearities applied to the distribution, for a finite, small set of samples in the filtering context. This observation can transfer to neural networks due to their Lipschitz continuity (Khromov & Singh, 2023). Our UT experiments empirically underline this expectation. For a more comprehensive overview of the UT and the UKF, we refer the reader to (Menegaz et al., 2015).
39
+
40
+ The UT uses several samples to get an estimate of the moments of a nonlinearly transformed probability distribution. Along those lines, our method also relates to the IWAE (Burda et al., 2016) and some of its extensions (Tucker et al., 2018). IWAE uses importance weighting of $K$ posterior samples to obtain a variational distribution closer to the true posterior (Cremer et al., 2017). The method is known to have a diminishing gradient signal for the inference network (Rainforth et al., 2018) if no additional improvements are used (Tucker et al., 2018). Using the Wasserstein metric, the inference distribution is sharp,
41
+
42
+ so practically there is not much gain in a more complex distribution. However, multiple samples can help to obtain lower variance gradient estimates, which also applies to the IWAE by taking a multiple of $K$ samples. Sampling only at the sigma points reduces this variance even more and is known to empirically work well in filtering and control.
43
+
44
+ The Wasserstein metric is used in (Tolstikhin et al., 2018; Patrini et al., 2020) to regularize the aggregated posterior $q_{\mathrm{agg}}(\mathbf{z}) = \mathbb{E}_{p(\mathbf{x})}[q(\mathbf{z}|\mathbf{x})]$ toward the standard normal prior. The authors also show that such an objective is an upper bound to the Wasserstein distance between the sampling distribution of the generative model and the data distribution if the regularization is scaled by the Lipschitz constant of the generator. In contrast, we do not regularize the aggregated posterior, but use the Wasserstein distance to weakly regularize the mean and variance of the encoder, such that neither explodes and we can do ex-post density estimation. From a theoretical point of view, we do not fix the prior but learn the manifold; the aggregated posterior is learned by fitting a mixture to the encoded data points.
45
+
46
+ Finally, our work incorporates several ideas from the recently published RAE (Ghosh et al., 2019). We also use a decoder regularization term based on the decoder Jacobian in our loss, which promotes smoothness of the latent space. In contrast to the RAE however, we generalize the term from a deterministic to a stochastic encoder as not every data point might be encoded with the same fidelity. Furthermore, we employ ex-post density estimation as we do not explicitly regularize the aggregated posterior toward a prior. Conceptually, the UAE can be placed between the VAE, characterized by significant sampling variance, and the purely deterministic RAE.
47
+
48
+ # 3. Problem Description
49
+
50
+ Most generative models take a max-likelihood approach to model a real-world distribution $p(\mathbf{x})$ via the $\theta$ -parameterized probabilistic generator model $p_{\theta}(\mathbf{x})$
51
+
52
+ $$
53
+ \theta \leftarrow \arg \max _ {\theta} \quad \mathbb {E} _ {\mathbf {x} \sim p (\mathbf {x})} [ \log p _ {\theta} (\mathbf {x}) ]. \tag {1}
54
+ $$
55
+
56
+ In this setting, latent variable generative approaches assume an underlying structure in $p(\mathbf{x})$ not directly observable from the data and model this structure with a latent variable $\mathbf{z}$ , which is well-motivated by de Finetti's theorem (Accardi, 2001). As a result, the distribution $p(\mathbf{x})$ can be represented as a product of tractable distributions. However, directly incorporating $\mathbf{z}$ via an integral $\int p_{\theta}(\mathbf{x}|\mathbf{z})p(\mathbf{z})d\mathbf{z}$ is intractable; thus, one introduces an amortized variational distribution $q_{\phi}(\mathbf{z}|\mathbf{x})$ (Zhang et al., 2018) and obtains
57
+
58
+ $$
59
+ \log p _ {\theta} (\mathbf {x}) = \log \mathbb {E} _ {\mathbf {z} \sim q _ {\phi} (\mathbf {z} | \mathbf {x})} \left[ \frac {p _ {\theta} (\mathbf {x} , \mathbf {z})}{q _ {\phi} (\mathbf {z} | \mathbf {x})} \right]. \tag {2}
60
+ $$
61
+
62
+ This model assumption is the basis of variational inference. Applying Jensen's inequality yields the well-known ELBO, denoted by $\mathcal{L}$
63
+
64
+ $$
65
+ \begin{array}{l} \log p _ {\theta} (\mathbf {x}) \geq \mathcal {L} = \mathbb {E} _ {\mathbf {z} \sim q _ {\phi} (\mathbf {z} | \mathbf {x})} [ \log p _ {\theta} (\mathbf {x} | \mathbf {z}) ] - \tag {3} \\ - D _ {\mathrm {K L}} \left(q _ {\phi} (\mathbf {z} | \mathbf {x}) \| p (\mathbf {z})\right), \\ \end{array}
66
+ $$
67
+
68
+ which is maximized w.r.t. $\theta$ and $\phi$ . The first term accounts for the quality of reconstructed samples and the $D_{\mathrm{KL}}(\ldots)$ term pushes the approximate posterior to mimic the prior, i.e. it enforces a $p(\mathbf{z})$ -like structure to the latent space.
69
+
70
+ Training on $\mathcal{L}$ in Eq. (3) requires computing gradients w.r.t. $\theta$ and $\phi$ . This is relatively straightforward for the generator parameters, however, requiring a high-variance policy gradient for the posterior parameters. To avoid this issue in practice, the reparameterization trick (Kingma et al., 2015) is used to simplify the sampling of the approximate posterior by means of an easy-to-sample distribution. Assuming a Gaussian posterior $\mathcal{N}(\boldsymbol{\mu}, \boldsymbol{\Sigma})$ , we can sample a multivariate normal and obtain the latent feature vector via the deterministic transformation
71
+
72
+ $$
73
+ \mathbf {z} = \boldsymbol {\mu} + \boldsymbol {L} \boldsymbol {\epsilon}, \quad \boldsymbol {\epsilon} \sim \mathcal {N} (\mathbf {0}, \mathbf {I}), \quad \boldsymbol {\Sigma} = \boldsymbol {L} \boldsymbol {L} ^ {T}. \tag {4}
74
+ $$
75
+
76
+ With the help of the reparameterization trick, the VAE (Kingma & Welling, 2013) provides a framework for optimizing the loss function from the condition in Eq. (3) via an encoder-decoder generative latent variable model. The encoder $E_{\phi}(\mathbf{x}) = \{\pmb{\mu}_{\phi}(\mathbf{x}), \pmb{\Sigma}_{\phi}(\mathbf{x})\}$ parameterizes a multivariate Gaussian $q_{\phi}(\mathbf{z}|\mathbf{x}) = \mathcal{N}(\mathbf{z}|\pmb{\mu}_{\phi}(\mathbf{x}), \pmb{\Sigma}_{\phi}(\mathbf{x}))$ , where $\pmb{\Sigma}_{\phi}$ is usually a diagonal matrix, $\pmb{\Sigma}_{\phi} = \mathrm{diag}(\pmb{\sigma}_{\phi})$ . The decoder $D_{\theta}(\mathbf{z}) = \pmb{\mu}_{\theta}(\mathbf{z})$ is in practice rendered deterministic: $p_{\theta}(\mathbf{x}|\mathbf{z}) = \mathcal{N}(\mathbf{x}|\pmb{\mu}_{\theta}(\mathbf{z}), \mathbf{0})$ , reducing the reconstruction term in Eq. (3) to a simple mean-squared error under the expectation of the posterior $\mathbb{E}_{\mathbf{z}\sim q_{\phi}(\mathbf{z}|\mathbf{x})}\| \mathbf{x} - \pmb{\mu}_{\theta}(\mathbf{z})\|_2^2$ . The VAE uses the reparameterization trick for efficient sampling from the posterior $q_{\phi}$ (in practice providing only a single sample to the decoder), which enables a lower-variance gradient backpropagation through the encoder.
77
+
78
+ The deterministic decoder and the reparameterization trick allow for a slightly different interpretation of the reconstruction/generation process: a (highly) nonlinear transformation of an input distribution, represented (usually) only by a single stochastic sample. The sample is white noise<sup>3</sup>, scaled and shifted by the posterior moments. This interpretation serves as the basis for our work, where the unscented transform of the input distribution serves as an alternative to the single-stochastic-sample representation. In the next section, we outline the unscented transform representation of the input to the decoder via a set of deterministically computed and sampled sigma points.
79
+
80
+ # 4. Unscented Transform of the Posterior
81
+
82
+ # 4.1. Background
83
+
84
+ The unscented transform (Uhlmann, 1995) is a method to evaluate a nonlinear transformation of a distribution characterized by its first two moments. Assume a known deterministic function $\pmb{f}$ applied to a distribution $P(\pmb{\mu}, \pmb{\Sigma})$ with mean and covariance $\pmb{\mu} \in \mathbb{R}^n$ and $\pmb{\Sigma} \in \mathbb{R}^{n \times n}$ . If $\pmb{f}$ is a linear transformation, one can describe the distribution $Q(\hat{\pmb{\mu}}, \hat{\pmb{\Sigma}})$ at the output via $\hat{\pmb{\mu}} = \pmb{f}\pmb{\mu}$ and $\hat{\pmb{\Sigma}} = \pmb{f}\pmb{\Sigma}\pmb{f}^T$ . Similarly, for a nonlinear transformation $\pmb{f}$ but a zero covariance matrix $\pmb{\Sigma} = \mathbf{0}$ , the mean of the transformed distribution is $\hat{\pmb{\mu}} = \pmb{f}(\pmb{\mu})$ . However, in the general case it is not possible to determine $\hat{\pmb{\mu}}$ and $\hat{\pmb{\Sigma}}$ of the $\pmb{f}$ -transformed distribution given $\pmb{\mu}$ and $\pmb{\Sigma}$ since the result depends on higher-order moments. Thus, the unscented transform is useful; it provides a mechanism to obtain this result via an approximation of the input distribution while assuming full knowledge of $\pmb{f}$ .
85
+
86
+ In computing the unscented transform, first a set of sigma points characterizing the input $P(\pmb{\mu}, \pmb{\Sigma})$ is chosen. The most common approach (Menegaz et al., 2015) is to take a set $\{\chi_i\}_{i=0}^{2n}$ , $\chi_i \in \mathbb{R}^n$ of $2n + 1$ symmetric points centered around the mean (incl. the mean), e.g. for $1 \leq i \leq n$ ,
87
+
88
+ $$
89
+ \chi_ {0} = \mu ,
90
+ $$
91
+
92
+ $$
93
+ \chi_ {i} = \boldsymbol {\mu} + \sqrt {(\kappa + n) \boldsymbol {\Sigma}} \big | _ {i}, \tag {5}
94
+ $$
95
+
96
+ $$
97
+ \chi_ {i + n} = \boldsymbol {\mu} - \sqrt {(\kappa + n) \boldsymbol {\Sigma}} \big | _ {i},
98
+ $$
99
+
100
+ where $\kappa > - n$ is a real constant and $\left|_{i}\right.$ denotes the $i$ -th column. The approximation in Eq. (5) is unbiased; the mean and covariance of the sigma points are $\pmb{\mu}$ and $\pmb{\Sigma}$ . Thus, one can compute the transformation $\hat{\chi}_i = f(\chi_i)$ and estimate the mean and covariance of the $\pmb{f}$ -transformed distribution
101
+
102
+ $$
103
+ \hat {\boldsymbol {\mu}} = \frac {1}{2 n + 1} \sum_ {i = 0} ^ {2 n} \hat {\chi} _ {i}, \tag {6}
104
+ $$
105
+
106
+ $$
107
+ \hat {\boldsymbol {\Sigma}} = \frac {1}{2 n + 1} \sum_ {i = 0} ^ {2 n} \left(\hat {\chi} _ {i} - \hat {\boldsymbol {\mu}}\right) \left(\hat {\chi} _ {i} - \hat {\boldsymbol {\mu}}\right) ^ {T}. \tag {7}
108
+ $$
109
+
110
+ A visualization of the sigma points and their transformation is depicted in Fig. 2a. The procedure in Eq. (5-7) effectively applies the fully-known function $f$ to an approximating set of points whose mean and covariance equal the original distribution's. Therefore, in the context of the commonly used VAE decoder nonlinearities, the mean and covariance of the transformed sigma points can be closer to the true transformed mean and covariance compared to the ones computed by propagating the same number of random samples from the original distribution.
111
+
112
+ # 4.2. Unscented Transform in the VAE
113
+
114
+ In an ELBO maximization setting from Eq. (3), the nonlinear transformation of the posterior in the decoder lends itself straightforwardly to the unscented transform approximation. Given any posterior defined by $\mu$ and $\Sigma$ , we
115
+
116
+ can compute the sigma points (for example according to Eq. (5)) and provide them to the decoder. In a VAE, the sigma points provide a deterministic-sampling alternative to the reparameterization-trick-computed random samples of the latent space. Furthermore, computing the average reconstruction of the sigma points at the output of the decoder provides an approximation of the mean of the entire transformed posterior distribution in Eq. (6), while implicitly taking into account the variance in Eq. (7), as opposed to the per-sample reconstructions.
117
+
118
+ The choice of the number of sigma points provided to the decoder is similar to the sampling in Eq. (4), where one can realize a single latent vector with a single sample from $\mathcal{N}(\mathbf{0},\mathbf{I})$ or multiple latents, resulting in a trade-off between reconstruction quality and computation demands (Ghosh et al., 2019). However, taking a single or few random samples in the VAE setting can produce instances very far from the mean, especially in high dimensional spaces. In contrast, sampling sigma points produces a more controlled overall estimate of the posterior (as well as producing a more accurate transformed posterior, see Eq. (6-7)) since the samples lie on the border of a hyperellipsoid induced by the covariance matrix $\boldsymbol{\Sigma}$ (example in Fig. 2b). Thus, while computing the loss function gradients (which are a function of the samples), the sigma-sampling has the potential to bring a more accurate and lower-variance estimate when all the sigma points are considered. This is illustrated in Fig 2c. Further empirical arguments validating the lower gradient variance claim are provided in Appendix B.
119
+
120
+ The sigma-sampling of the UT can be applied to any learned posterior described by its first two moments (as common in generative models), not only the VAE standard normal. With this description, the sigma points cannot be the uniquely optimal representation of the distribution since there is an infinite number of distributions that share the first two moments. However, the UT has shown superior empirical performance over other representations in extensive experiments in (Julier et al., 2000) and (Zhang et al., 2009), under various distributions and nonlinear functions, and especially for the case of differentiable functions. This has led to the UKF, built on this paradigm, being one of the major algorithms in filtering and control. Guided by the success of the method, we hypothesize that applying the UT in the VAE setting has the potential to, for a finite set of samples, provide a better approximation of the learned two-moment Gaussian posterior than the ubiquitous independent random sampling and reconstruction. With these insights, we develop the UAE model presented in the next section.
121
+
122
+ ![](images/110787ef9cf470a3d73afd7ef9a1237147b80a8efdb3f51dc5c6a22914f111a4.jpg)
123
+ (a)
124
+
125
+ ![](images/d787fd56961cdad0e4f0ebfc21f0b1f5bf4a2c40d68eaed26fbf46fee71f9bd7.jpg)
126
+ (b)
127
+
128
+ ![](images/48becdb9fd74a06d365cdb8b679b7df29dd257883c5b0794347e00012daac578.jpg)
129
+ (c)
130
+ Figure 2: (best viewed in color) (a) (transforming 2D sigma points) Left: a Gaussian with its Monte Carlo approximation (blue), sigma points computed according to Eq. (5) (red), and five random samples (black points). Right: nonlinear RReLU activation (Xu et al., 2015) applied to the distribution, sigma points, and the random samples. In this example, the five sigma points provide a better approximation of the transformed distribution than the five random samples.
131
+
132
+ (b) (3D sigma points) Sigma points (red) on an ellipsoid spanned by a $3 \times 3$ covariance matrix, consisting of a central sigma point and a pair of sigma points on each axis.
133
+
134
+ (c) (gradient variance) Left: loss function (blue) at a sample (gray) corresponding to the standard normal (yellow) mean. The gradient of the loss function (red) at the mean is not representative of the true gradient. Middle: a high-variance gradient computed from the gradients at the three random samples drawn from the standard normal, potentially far away from the true gradient. Right: gradient of the loss function computed from the gradients at the three sigma points; although the estimate is potentially biased due to the applied nonlinear transformation, it has lower variance than if computed from the random points. The three provided examples can be interpreted as the RAE-(Ghosh et al., 2019), VAE-, and UAE-like sampling procedures.
135
+
136
+ # 5. Unscented Autoencoder (UAE)
137
+
138
+ The UAE is a deterministic-sampling autoencoder model maximizing the ELBO. It addresses the maximum likelihood optimization problem from Sec. 3, namely the $\mathcal{L}$ maximization from Eq. (3), by computing the UT of the posterior $q_{\phi}(\mathbf{z}|\mathbf{x})$ parameterized by the encoder $E_{\phi}(\mathbf{x}) = \{\pmb{\mu}_{\phi}(\mathbf{x}), \pmb{\Sigma}_{\phi}(\mathbf{x})\}$ (see Eq. (5-7)). The latent features $\mathbf{z}$ can be obtained by deterministically sampling multiple sigma points, resulting in a lower variance sampling than of the reparameterization trick in Eq. (4). Good performance of the model is further boosted by replacing the vanilla KL divergence with the Wasserstein distribution metric, which effectively performs a regularization of the posterior moments. The decoder regularization applies an additional smoothing effect on the latent space - it is formally derived in Sec. 5.2. The full training objective consists of optimizing $\phi, \theta \gets \arg \min_{\phi, \theta} \mathcal{L}_{\mathrm{UAE}}$ ,
139
+
140
+ $$
141
+ \mathcal {L} _ {\mathrm {U A E}} = \mathbb {E} _ {\mathbf {x} \sim p _ {\text {d a t a}}} \mathcal {L} _ {\mathrm {R E C}} + \beta \mathcal {L} _ {W} + \gamma \mathcal {L} _ {D _ {\theta} \mathrm {R E G}}, \tag {8}
142
+ $$
143
+
144
+ where $\beta$ (from the $\beta$ -VAE (Higgins et al., 2017)) and $\gamma$ are weights.
145
+
146
+ The reconstruction term $\mathcal{L}_{\mathrm{REC}}$ is an $L_{2}$ loss function incorporating the average of decoded sigma points
147
+
148
+ $$
149
+ \begin{array}{l} \mathcal {L} _ {\mathrm {R E C}} = \left\| \mathbf {x} - \frac {1}{K} \sum_ {k = 1} ^ {K} D _ {\theta} \left(\mathbf {z} _ {k}\right) \right\| _ {2} ^ {2}, \tag {9} \\ \mathbf {z} _ {k} \sim \left\{\chi_ {i} \left(\boldsymbol {\mu} _ {\phi}, \boldsymbol {\Sigma} _ {\phi}\right) \right\} _ {i = 0} ^ {2 n}, \\ \end{array}
150
+ $$
151
+
152
+ where $K$ $n$ -dimensional vectors $\mathbf{z}_k$ are sampled from the set of sigma points, $K \leq 2n + 1$ . Various sampling
153
+
154
+ heuristics are investigated in Appendix C. Note that this reconstruction loss function differs from the commonly used $\frac{1}{K}\sum_{k=1}^{K}\|\mathbf{x} - D_{\theta}(\mathbf{z}_{k})\|_{2}^{2}$ , where each decoded sample is matched to the ground truth. This strategy, employed in the standard multi-sample VAE, aims at getting the same output image for different samples thus demanding a certain attenuation property from the deterministic decoder. In contrast, Eq. (9) is motivated by the application of the UT in filtering where after propagating the sigma points through a nonlinear function a Gaussian is fit to the posterior (see Eq. (6-7)). By applying the loss to the mean output image, we essentially maintain a probability distribution at the output.
155
+
156
+ We use the Wasserstein metric term $\mathcal{L}_{\mathrm{W}}$ as an alternative to the KL divergence. For a multivariate posterior and a multivariate normal prior, the KL divergence is defined as
157
+
158
+ $$
159
+ \mathcal {L} _ {\mathrm {K L}} = \left\| \boldsymbol {\mu} _ {\phi} \right\| _ {2} ^ {2} + \operatorname {t r} \left(\boldsymbol {\Sigma} _ {\phi}\right) - n - 2 \operatorname {t r} \left(\log \boldsymbol {L} _ {\phi}\right), \tag {10}
160
+ $$
161
+
162
+ in the general case $^4$ of a full-covariance matrix $\boldsymbol{\Sigma}_{\phi} = \boldsymbol{L}_{\phi}\boldsymbol{L}_{\phi}^{T}$ . Instead, due to favorable optimization properties and higher-quality reconstruction, we use the Wasserstein metric between distributions. This metric effectively replaces the covariance part of the KL term, $\mathrm{tr}(\boldsymbol{\Sigma}_{\phi}) - 2\mathrm{tr}(\log \boldsymbol{L}_{\phi})$ , with the squared Frobenius norm of the mismatch between the lower triangular matrix and the identity
163
+
164
+ $$
165
+ \mathcal {L} _ {W} = \left\| \boldsymbol {L} _ {\phi} - \mathbf {I} \right\| _ {F} ^ {2} = \operatorname {t r} \left(\boldsymbol {\Sigma} _ {\phi}\right) - 2 \operatorname {t r} \left(\boldsymbol {L} _ {\phi}\right). \tag {11}
166
+ $$
167
+
168
+ It differs from the original objective in Eq. (10) only in the lack of a logarithm while sharing the same global minimum. Further details are provided in Sec. 5.3. Such a loss function allows the variance to approach zero (which is instead strongly penalized by the logarithm in Eq. (10)), yielding a sharper posterior.
169
+
170
+ The decoder regularization term $\mathcal{L}_{D_{\theta}\mathrm{REG}}$ is a generalization of the gradient penalty term in (Ghosh et al., 2019), accounting for a fully probabilistic formulation. It can be realized as a penalty on the input-output gradient of the posterior mean, weighted by the largest eigenvalue of the covariance matrix
171
+
172
+ $$
173
+ \mathcal {L} _ {D _ {\theta} \mathrm {R E G}} = \lambda_ {\max } \left(\boldsymbol {\Sigma} _ {\phi}\right) \| \nabla_ {\boldsymbol {\mu} _ {\phi}} D _ {\theta} \left(\boldsymbol {\mu} _ {\phi}\right) \| _ {2} ^ {2}. \tag {12}
174
+ $$
175
+
176
+ We approximate $\lambda_{\mathrm{max}}(\Sigma_{\phi})$ by the largest diagonal, which is correct for a diagonal $\Sigma_{\phi}$ .
177
+
178
+ We provide an overview of the VAE, RAE, and UAE loss functions in Tab. 1, together with the models that are conceptually between the VAE and UAE. Additional models employing different combinations of the loss function components are provided in Appendix D, Tab. 7.
179
+
180
+ # 5.1. Sampling From the Prior-Less UAE
181
+
182
+ Since the UAE model doesn't regularize the aggregated posterior toward the prior using the KL divergence (Hoffman & Johnson, 2016) or the Wasserstein metric (Patrini et al., 2020) (we use the per-posterior Wasserstein metric), it is not equipped with an easy-to-use sampling procedure as the VAE. To remedy this, we use the straightforward ex-post density estimation procedure described in (Ghosh et al., 2019) for the deterministic RAE model. We fit the latent means $\mu_{\phi}$ for each input sample $\mathbf{x}$ to a 10-component Gaussian Mixture Model (GMM) (which has shown good performance and generalization ability in the experiments of (Ghosh et al., 2019) even for VAE models) and use the mixture to sample from the latent space. For a fair comparison, we utilize this procedure in all models.
183
+
184
+ # 5.2. ELBO Derivation
185
+
186
+ In the following, we analytically derive the UAE model in Eq. (8). The derivation is largely inspired from (Ghosh et al., 2019), with a few crucial differences allowing for greater generalizability and less restrictive assumptions. We start with the general ELBO minimization formulation in Eq. (3), augmented with a constraint
187
+
188
+ $$
189
+ \begin{array}{l} \arg \min _ {\phi , \theta} E _ {x \sim p _ {\text {d a t a}}} \mathcal {L} _ {\mathrm {R E C}} + \mathcal {L} _ {\mathrm {K L}} (13) \\ \text {s . t .} \quad \| D _ {\theta} (\mathbf {z} _ {1}) - D _ {\theta} (\mathbf {z} _ {2}) \| _ {p} < \epsilon , (14) \\ \mathbf {z} _ {1}, \mathbf {z} _ {2} \sim q _ {\phi} (\mathbf {z} | \mathbf {x}), \forall \mathbf {x} \sim p _ {\mathrm {d a t a}}. \\ \end{array}
190
+ $$
191
+
192
+ Here, the decoder outputs given any two latent vectors $\mathbf{z}_1$ and $\mathbf{z}_2$ (any two draws from the posterior $q_{\phi}(\mathbf{z}|\mathbf{x})$ ) are bounded via their $p$ -norm difference, for a deterministic decoder $D_{\theta}$ . It was shown in (Ghosh et al., 2019) that the constraint in Eq. (14) can be reformulated as
193
+
194
+ $$
195
+ \sup \left\{\| \nabla_ {\mathbf {z}} D _ {\theta} (\mathbf {z}) \| _ {p} \right\} \cdot \sup \left\{\| \mathbf {z} _ {1} - \mathbf {z} _ {2} \| _ {p} \right\} < \epsilon . \tag {15}
196
+ $$
197
+
198
+ We provide the full derivation in Appendix E. In Eq. (15), $\nabla_{\mathbf{z}}D_{\theta}(\mathbf{z})$ is the derivative of the decoder output w.r.t. its input (not the parameterization $\theta$ ). The second term in the product depends on the parameterization of the posterior $q_{\phi}(\mathbf{z}|\mathbf{x})$ . For a Gaussian, $\sup \{\| \mathbf{z}_1 - \mathbf{z}_2\| _p\}$ becomes a functional $r$ of the posterior entropy, $r(\mathbb{H}(q_{\phi}(\mathbf{z}|\mathbf{x})))$ . At this point, the RAE derivation from (Ghosh et al., 2019) takes a strong simplifying assumption of constant entropy for all samples $\mathbf{x}$ , effectively asserting constant variance in the posterior. This allows to incorporate a simplified version of Eq. (15) into Eq. (13) via the Lagrange multiplier $\gamma$ , obtaining the following RAE loss function<sup>5</sup>
199
+
200
+ $$
201
+ \mathcal {L} _ {\mathrm {R A E}} = \left\| \mathbf {x} - D _ {\theta} (\mathbf {z}) \right\| _ {2} ^ {2} + \beta \| \mathbf {z} \| _ {2} ^ {2} + \gamma \| \nabla_ {\mathbf {z}} D _ {\theta} (\mathbf {z}) \| _ {2} ^ {2}. \tag {16}
202
+ $$
203
+
204
+ Here, the KL-term from Eq. (13) is approximated by $\| \mathbf{z}\| _2^2$ due to the constant variance assumption.
205
+
206
+ In the UAE formulation, the samples $\mathbf{z}_1$ and $\mathbf{z}_2$ in Eq. (15) simply correspond to the sigma points of $q_{\phi}(\mathbf{z}|\mathbf{x})$ parameterized by $E_{\phi}(\mathbf{x}) = \{\pmb{\mu}_{\phi}(\mathbf{x}), \pmb{\Sigma}_{\phi}(\mathbf{x})\}$ . Therefore, the term $\sup \{\| \mathbf{z}_1 - \mathbf{z}_2 \|_p\}$ can be computed analytically as the largest eigenvalue $\lambda_{\mathrm{max}}$ of the covariance matrix $\pmb{\Sigma}_{\phi}$ . We regularize the decoder in an RAE-manner around the posterior mean with $\| \nabla_{\pmb{\mu}_{\phi}} D_{\theta}(\pmb{\mu}_{\phi}) \|_p$ to enforce smoothness. Finally, the UAE does not require the constant variance assumption; we can incorporate a posterior KL-term or the Wasserstein metric used in Eq. (8). Thus, we arrive at the following analytical UAE loss function from Eq. (8)
207
+
208
+ $$
209
+ \begin{array}{l} \mathcal {L} _ {\mathrm {U A E}} = E _ {\mathbf {x} \sim p _ {\mathrm {d a t a}}} \mathcal {L} _ {\mathrm {R E C}} + \beta \mathcal {L} _ {\mathrm {W}} + \tag {17} \\ + \gamma \lambda_ {\max } (\boldsymbol {\Sigma} _ {\phi}) \| \nabla_ {\boldsymbol {\mu} _ {\phi}} D _ {\theta} (\boldsymbol {\mu} _ {\phi}) \| _ {p}, \\ \end{array}
210
+ $$
211
+
212
+ where a more general form of the Eq. (15) constraint is used than in Eq. (16).
213
+
214
+ It follows from the derivation that the major difference between the RAE on the one hand and VAE and UAE on the other is that the RAE assumes constant variance in mapping the training data distribution into the latent space, thus not including any variance-compensating terms in the loss function. In effect, the RAE considers all the dimensions equally and cannot take into account that the encoder might have different uncertainty per dimension and data point.
215
+
216
+ Table 1: A comparison of the VAE, RAE-GP (employing a Gradient Penalty (GP) on the decoder, a less general version of Eq. (12)), and UAE loss functions, including the intermediate models UT-VAE, $\mathrm{VAE^{*}}$ , UT-VAE*, (weights omitted for clarity). UT-VAE uses the unscented transform in the VAE, $\mathrm{VAE^{*}}$ uses the Wasserstein metric from Eq. (11), and UT-VAE* differs from the UAE only in the lack of a decoder regularization term. All models use a diagonal posterior representation (except RAE, which does not model uncertainty). The terms $\mathbf{z}$ , $\pmb{\mu}_{\phi}$ , and $\sigma_{\phi}$ are realized given the sample $\mathbf{x}$ .
217
+
218
+ Loss function
219
+ Posterior sampling
220
+
221
+ <table><tr><td>LVAE</td><td>1/K ∑k=1K ||x-Dθ(zk)||2+ ||μφ||2- n+ ∑i σ2φ,i- 2 log σφ,i</td><td>zk=μφ+σφ⊙εk, εk~N(0,I)</td></tr><tr><td>LUT-VAE</td><td>||x-1/K ∑k=1K Dθ(zk)||2+ ||μφ||2- n+ ∑i σ2φ,i- 2 log σφ,i</td><td>zk~{χi(μφ, diag(σφ2))}2n i=0</td></tr><tr><td>RAE-GP</td><td>||x-Dθ(z)||2+ ||z||2+ ||∇zDθ(z)||2</td><td>None, z=μφ</td></tr><tr><td>LVAE*</td><td>1/K ∑k=1K ||x-Dθ(zk)||2+ ||μφ||2+ ||diag(σφ2)-I||F</td><td>zk=μφ+σφ⊙εk, εk~N(0,I)</td></tr><tr><td>LUT-VAE*</td><td>||x-1/K ∑k=1K Dθ(zk)||2+ ||μφ||2+ ||diag(σφ2)-I||F</td><td>zk~{χi(μφ, diag(σφ2))}2n i=0</td></tr><tr><td>LUAE</td><td>||x-1/K ∑k=1K Dθ(zk)||2+ ||μφ||2+ ||diag(σφ2)-I||F+ max(σφ2)||∇μφDθ(μφ)||2</td><td>zk~{χi(μφ, diag(σφ2))}2n i=0</td></tr></table>
222
+
223
+ Additionally, the difference between VAE and UAE is that the VAE incorporates a sampling procedure with higher variance than the deterministic sigma-point sampling used in the unscented transform. Therefore, loss function-wise, the UAE can be regarded as a middle-ground between the VAE and RAE - deterministic and lower-variance in training than the VAE, but with greater generalization capabilities than the RAE due to the probabilistic formulation.
224
+
225
+ # 5.3. Posterior Regularization via the Wasserstein Metric
226
+
227
+ The usage of the Wasserstein metric is motivated by practical properties of VAE model optimization. The training can be sensitive to the weighting of the KL divergence term, which can lead to posterior collapse (Dai et al., 2020). The main factor is the strong variance regularization of the KL divergence with its log term, which can be written as
228
+
229
+ $$
230
+ \mathcal {L} _ {\mathrm {K L}} = \left\| \boldsymbol {\mu} _ {\phi} \right\| _ {2} ^ {2} + \operatorname {t r} \left(\boldsymbol {\Sigma} _ {\phi}\right) - n - 2 \sum_ {i} \log L _ {\phi , i i} \tag {18}
231
+ $$
232
+
233
+ If the posterior gets more peaked, which might be necessary for good reconstructions, the divergence quickly grows toward infinity. We observed such problems in particular with full-covariance posteriors (see Appendix F).
234
+
235
+ Despite these problems the KL divergence is theoretically sound. It was shown in (Hoffman & Johnson, 2016) that $D_{\mathrm{KL}}(q_{\phi}(\mathbf{z}|\mathbf{x})\| p(\mathbf{z}))$ can be reformulated into two terms, one that weakly pushes toward overlapping per-sample posterior distributions and a KL divergence between the aggregated posterior and the prior. The latter is required if samples are drawn from the prior and the former prevents the latent encoding from becoming a lookup table (Mathieu et al., 2019). Replacing the KL divergence with the Wasserstein-2 metric preserves the tendency toward overlapping posteriors, but does not match the aggregated posterior to a predefined prior. However, a simple connection can be found to such models, see Appendix G. Nevertheless
236
+
237
+ less, this matching is not required in our setup due to the ex-post density estimation. Furthermore, successful practical approaches like Stable Diffusion (Rombach et al., 2022) only require correctly learning the manifold and therefore do not need a certain aggregated posterior to sample from.
238
+
239
+ We use the Wasserstein-2 metric between two Gaussian distributions. Mathematically, it can be written as
240
+
241
+ $$
242
+ \begin{array}{l} W _ {2} \left(\mathcal {N} _ {1}, \mathcal {N} _ {2}\right) = \left\| \boldsymbol {\mu} _ {\phi} \right\| _ {2} ^ {2} + \operatorname {t r} \left(\boldsymbol {\Sigma} _ {\phi}\right) + n - 2 \operatorname {t r} \left(\boldsymbol {\Sigma} _ {\phi} ^ {1 / 2}\right) \tag {19} \\ = \| \boldsymbol {\mu} _ {\phi} \| _ {2} ^ {2} + \operatorname {t r} \left(\boldsymbol {\Sigma} _ {\phi}\right) + n - 2 \operatorname {t r} \left(\boldsymbol {L} _ {\phi}\right), \\ \end{array}
243
+ $$
244
+
245
+ for $\mathcal{N}_1 = \mathcal{N}(\pmb{\mu}_{\phi}, \pmb{\Sigma}_{\phi})$ and $\mathcal{N}_2 = \mathcal{N}(\mathbf{0}, \mathbf{I})$ . The last three terms can be reformulated into Eq. (11)
246
+
247
+ $$
248
+ \begin{array}{l} \operatorname {t r} \left(\boldsymbol {\Sigma} _ {\phi}\right) + n - 2 \operatorname {t r} \left(\boldsymbol {L} _ {\phi}\right) = \operatorname {t r} \left(\boldsymbol {L} _ {\phi} ^ {T} \boldsymbol {L} _ {\phi} - 2 \boldsymbol {L} _ {\phi} + \boldsymbol {I}\right) = \tag {20} \\ = \operatorname {t r} \left(\left(\boldsymbol {L} _ {\phi} - \mathbf {I}\right) ^ {T} \left(\boldsymbol {L} _ {\phi} - \mathbf {I}\right)\right) = \left\| \boldsymbol {L} _ {\phi} - \mathbf {I} \right\| _ {F} ^ {2}. \\ \end{array}
249
+ $$
250
+
251
+ Disregarding the constant terms, it is clear that Eq. (18) and Eq. (19) differ in the lack of the log term that infinitely penalizes zero-variance latents. In contrast, the Wasserstein metric even allows the posterior variance to approach zero if it helps to significantly reduce the reconstruction loss. This is evidenced in the aggregated posterior visualization of our model provided in Appendix H.
252
+
253
+ Naturally, the reduced reconstruction losses brought on by the per-sample Wasserstein metric in place of the KL divergence come at the cost of losing the ELBO formulation of the overall optimization problem. Furthermore, the Wasserstein distance between the aggregated posterior and the standard normal prior (Patrini et al., 2020) is not optimized either. Nevertheless, our empirical analysis shows that replacing the KL divergence with a Wasserstein metric regularization of the per-sample posterior results in significantly better reconstruction performance.
254
+
255
+ # 6. Results
256
+
257
+ In the following, we present quantitative and qualitative results of the UAE and its precursors compared to the VAE and RAE baselines on Fashion-MNIST (Xiao et al., 2017), CIFAR10 (Krizhevsky et al., 2009), and CelebA (Liu et al., 2015). We aim to delineate the effects of the UT (along with the reconstruction loss in Eq. (9), Wasserstein metric, and the decoder regularization. Furthermore, we investigate multi-sampling and various sigma-point heuristics in Appendix C and ablate the entire loss function from Eq. (8) in Appendix D. In addition to evaluating the reconstruction and sampling quality (using a mixture for all models, see Sec. 5.1), we investigate if sampling only at the sigmas in training preserves the latent space structure (e.g. does not create 'holes') by evaluating interpolated samples. The metric is the widely-used FID (Heusel et al., 2017), which quantifies the distance between two distributions of images. Detailed information about the network architecture, training, and the choice of FID datasets is given in Appendix A.
258
+
259
+ The main results are provided in Tab. 2. The table is divided into three parts: the first part shows the effects of applying the Unscented Transform to the vanilla VAE model; the second part shows the baseline results of the RAE, while the third part shows the results of Wasserstein metric models. In the UT-VAE row of Tab. 2, we tweak the VAE sampling to select instances at the sigma points while averaging the resulting images in the reconstruction loss, as consistent with the definition in Eq. (5-6). This simple change brings a remarkable near $40\%$ improvement on Fashion-MNIST on average, near $15\%$ on CIFAR10, and near $30\%$ on CelebA. It provides strong evidence that a higher-quality, lower-variance representation of the posterior distribution results in higher-quality decoded images.
260
+
261
+ The deterministic baseline RAE model in Tab. 2 sets the context with a significantly higher performance than the vanilla VAE. The Wasserstein metric of the VAE*, which preserves the latent space regularization in spirit of the RAE but extends it to a probabilistic, non-constant variance setting, can be considered close to the non-regularized RAE: outperforms it on CIFAR10 while being behind on Fashion-MNIST and CelebA. More importantly, the VAE* model also achieves a large improvement over the classical VAE in all metrics and on all datasets, achieved effectively only by replacing the logarithm term with a linear term. This indicates that the rigidity of the KL divergence w.r.t. posterior variance potentially harms the quality of decoded samples, particularly on the richer CIFAR10 and CelebA.
262
+
263
+ Observing the UT-VAE* row in Tab. 2, it can be seen that the unscented transform (UT) sampling in the VAE* context gives a further, albeit lesser boost in most metrics than with the KL divergence. Due to the Wasserstein metric's ability to shrink the posterior variance while approaching
264
+
265
+ convergence, the effect of any sampling is reduced. Nevertheless, it provides a considerable, approximately $10\%$ boost on CelebA and Fashion-MNIST as well as a larger relative improvement with multiple samples than in VAE* (see Tab. 5, 6 in Appendix C). Finally, the generalized decoder regularization from Eq. (12) of the UAE applies a strong smoothing effect and further boosts the performance on CelebA and especially CIFAR10. Surprisingly, it yields a regression on Fashion-MNIST; similar effect of the gradient penalty harming the RAE performance compared to no-regularization is observable in (Ghosh et al., 2019) MNIST experiments. Overall, compared to the RAE, the UAE achieves significant improvements on CIFAR10 and a minor improvement on CelebA, while interestingly, the best model on Fashion-MNIST can be considered the UT-VAE.
266
+
267
+ In Tab. 3, we take a deeper look at the performance of the UT reconstruction loss term from Eq. (9). We empirically compare two strategies for designing the loss function: (i) use the mean reconstruction loss of images for each selected sample from the posterior (consistent with the standard VAE reconstruction loss) and (ii) apply the reconstruction loss to the mean image of samples from the posterior. Quantitative results in Tab. 3 consistently show the advantages of strategy (ii) for both the VAE and UT-VAE models using random samples and sigma points, respectively.
268
+
269
+ CelebA qualitative results are shown in Fig. 3 and reflect the FID scores: the UAE images appear similar to the RAE but significantly more realistic than the VAE. Fashion-MNIST and CIFAR10 images are provided in Appendix I.
270
+
271
+ # 7. Conclusion
272
+
273
+ In this paper, we introduced a novel VAE architecture employing the Unscented Transform, a lower-variance alternative to the reparameterization trick. We have challenged one of the core components of the VAE by showing that a sigma-point transform of the posterior significantly outperforms propagating random samples through the decoder. This was empirically shown for a small number of sigma points (2, 4, and 8) while taking more becomes impractical due to computationally-intensive training. Additionally, we proposed to use the Wasserstein metric, which does not optimize the ELBO. Although it can be considered as the main theoretical limitation of our model, it is a sound practical alternative to the KL divergence. By breaking its rigidity w.r.t. posterior variance, we unlocked performance improvements brought on by sharper posteriors that preserve a smooth latent space. Our work contributes an important step toward establishing competitive deterministic and deterministic-sampling generative models. Future work will thus focus on expanding the classes of supported generative models and on evaluation of further deterministic and quasi-deterministic sampling methods.
274
+
275
+ Table 2: Comparison of the architectures from Tab. 1. In all sampling instances, we select 8 random samples or sigma points. In the unscented transform models (UT-VAE, UT-VAE*, UAE), we select random sigma points on all datasets apart from CIFAR10, where pairs of sigma points along the largest eigenvalue axes are selected (see Appendix C). All RAE variants from (Ghosh et al., 2019) are provided: RAE-no-reg. without decoder regularization, RAE-GP with the Gradient Penalty (GP) from Eq. (16), RAE-L2 with decoder weight decay, and RAE-SN with spectral normalization.
276
+
277
+ <table><tr><td rowspan="2"></td><td colspan="3">Fashion-MNIST</td><td colspan="3">CIFAR10</td><td colspan="3">CelebA</td></tr><tr><td>Rec.</td><td>Sample</td><td>Interp.</td><td>Rec.</td><td>Sample</td><td>Interp.</td><td>Rec.</td><td>Sample</td><td>Interp.</td></tr><tr><td>VAE8x</td><td>44.29</td><td>48.73</td><td>61.99</td><td>110.0</td><td>120.6</td><td>118.3</td><td>65.86</td><td>68.53</td><td>68.75</td></tr><tr><td>UT-VAE8x</td><td>27.79</td><td>30.39</td><td>39.92</td><td>91.04</td><td>111.7</td><td>104.3</td><td>50.11</td><td>54.15</td><td>54.32</td></tr><tr><td>RAE-no-reg.</td><td>21.56</td><td>34.79</td><td>50.27</td><td>86.79</td><td>102.1</td><td>96.80</td><td>40.79</td><td>47.88</td><td>49.97</td></tr><tr><td>RAE-GP</td><td>22.91</td><td>33.80</td><td>50.74</td><td>85.70</td><td>100.7</td><td>96.06</td><td>39.89</td><td>46.67</td><td>46.18</td></tr><tr><td>RAE-L2</td><td>20.28</td><td>32.06</td><td>48.52</td><td>84.27</td><td>99.26</td><td>94.23</td><td>38.78</td><td>46.44</td><td>50.33</td></tr><tr><td>RAE-SN</td><td>21.40</td><td>33.50</td><td>49.60</td><td>85.75</td><td>101.1</td><td>96.48</td><td>41.23</td><td>48.39</td><td>50.23</td></tr><tr><td>VAE*8x</td><td>27.36</td><td>36.63</td><td>52.61</td><td>82.22</td><td>99.11</td><td>92.84</td><td>45.02</td><td>50.81</td><td>53.64</td></tr><tr><td>UT-VAE*8x</td><td>23.64</td><td>31.51</td><td>48.06</td><td>81.12</td><td>100.6</td><td>93.80</td><td>40.18</td><td>47.39</td><td>49.62</td></tr><tr><td>UAE8x</td><td>25.07</td><td>35.19</td><td>54.24</td><td>71.97</td><td>89.91</td><td>83.50</td><td>38.48</td><td>45.60</td><td>45.88</td></tr></table>
278
+
279
+ Table 3: Comparison of a VAE model using the reconstruction loss of the mean image of random samples from the posterior: $\| \mathbf{x} - \frac{1}{K}\sum_{k = 1}^{K}D_{\theta}(\mathbf{z}_k)\| _2^2$ $\mathbf{z}_k = \pmb {\mu}_\phi +\pmb {\sigma}_\phi \odot \pmb {\epsilon}_k$ $\epsilon_{k}\sim \mathcal{N}(\mathbf{0},\mathbf{I})$ , denoted by $\mathrm{VAE}_{2\mathrm{x}}^{\dagger}$ , and a model with the mean reconstruction loss of sigma points from the posterior: $\frac{1}{K}\sum_{k = 1}^{K}\| \mathbf{x} - D_{\theta}(\mathbf{z}_{k})\|_{2}^{2}$ $\mathbf{z}_k\sim \{\chi_i(\pmb {\mu}_\phi ,\mathrm{diag}(\pmb {\sigma}_\phi^2))\}_{i = 0}^{2n}$ , denoted by UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VA E. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UT-VAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVAE. The UTVaeA, while largest-eigenvalue pairs are used in CIFAR10.
280
+
281
+ <table><tr><td rowspan="2"></td><td colspan="3">Fashion-MNIST</td><td colspan="3">CIFAR10</td><td colspan="3">CelebA</td></tr><tr><td>Rec.</td><td>Sample</td><td>Interp.</td><td>Rec.</td><td>Sample</td><td>Interp.</td><td>Rec.</td><td>Sample</td><td>Interp.</td></tr><tr><td>VAE2x</td><td>43.66</td><td>49.01</td><td>61.03</td><td>112.7</td><td>123.2</td><td>120.6</td><td>67.29</td><td>69.92</td><td>70.00</td></tr><tr><td>VAE†2x</td><td>42.22</td><td>47.33</td><td>59.47</td><td>110.0</td><td>121.6</td><td>118.6</td><td>61.71</td><td>65.77</td><td>65.29</td></tr><tr><td>UT-VAE‡2x</td><td>46.79</td><td>52.87</td><td>74.11</td><td>115.2</td><td>128.2</td><td>124.7</td><td>54.61</td><td>61.03</td><td>59.49</td></tr><tr><td>UT-VAE2x</td><td>36.25</td><td>40.30</td><td>53.10</td><td>95.70</td><td>115.4</td><td>107.3</td><td>51.61</td><td>57.42</td><td>56.56</td></tr></table>
282
+
283
+ ![](images/1d031c0f5fb926801adabe5cabb9ccb97856b3c98cd0782d65790293bfb087ac.jpg)
284
+ Figure 3: Qualitative results on the CelebA dataset of the $\mathrm{VAE}_{8\mathrm{x}}$ , RAE-L2, and $\mathrm{UAE}_{8\mathrm{x}}$ models.
285
+
286
+ # References
287
+
288
+ Accardi, L. De Finetti Theorem. *Hazewinkel, Michiel, Encyclopaedia of Mathematics*, Kluwer Academic Publishers, 2001.
289
+ Bauer, M. and Mnih, A. Resampled Priors for Variational Autoencoders. In The 22nd International Conference on Artificial Intelligence and Statistics, pp. 66-75. PMLR, 2019.
290
+ Bengio, Y., Courville, A. C., and Vincent, P. Representation Learning: A Review and New Perspectives. IEEE Trans. Pattern Anal. Mach. Intell., 35(8):1798-1828, 2013. doi: 10.1109/TPAMI.2013.50. URL https://doi.org/10.1109/TPAMI.2013.50.
291
+ Bowman, S. R., Vilnis, L., Vinyals, O., Dai, A. M., Jozefowicz, R., and Bengio, S. Generating Sentences From a Continuous Space. arXiv preprint arXiv:1511.06349, 2015.
292
+ Burda, Y., Grosse, R. B., and Salakhutdinov, R. Importance Weighted Autoencoders. In Bengio, Y. and LeCun, Y. (eds.), 4th International Conference on Learning Representations, ICLR 2016, San Juan, Puerto Rico, May 2-4, 2016, Conference Track Proceedings, 2016. URL http://arxiv.org/abs/1509.00519.
293
+ Chen, X., Kingma, D. P., Salimans, T., Duan, Y., Dhariwal, P., Schulman, J., Sutskever, I., and Abbeel, P. Variational Lossy Autoencoder. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings. OpenReview.net, 2017. URL https://openreview.net/forum?id=BysvGP5ee.
294
+ Cremer, C., Morris, Q., and Duvenaud, D. Reinterpreting Importance-Weighted Autoencoders. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Workshop Track Proceedings. OpenReview.net, 2017. URL https://openreview.net/forum?id=Syw2ZgrFx.
295
+ Dai, B. and Wipf, D. Diagnosing and Enhancing VAE Models. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id=B1e0X3C9tQ.
296
+ Dai, B., Wang, Y., Aston, J., Hua, G., and Wipf, D. Connections with Robust PCA and the Role of Emergent Sparsity In Variational Autoencoder Models. The Journal of Machine Learning Research, 19(1):1573-1614, 2018.
297
+ Dai, B., Wang, Z., and Wipf, D. The Usual Suspects? Reassessing Blame for VAE Posterior Collapse. In International Conference on Machine Learning, pp. 2313-2322. PMLR, 2020.
298
+
299
+ Doucet, A. and Johansen, A. M. A Tutorial On Particle Filtering and Smoothing: Fifteen Years Later. Oxford Handbook of Nonlinear Filtering, 2011.
300
+ Ghosh, P., Sajjadi, M. S., Vergari, A., Black, M., and Scholkopf, B. From Variational to Deterministic Autoencoders. arXiv preprint arXiv:1903.12436, 2019.
301
+ Goodfellow, I. J., Pouget-Abadie, J., Mirza, M., Xu, B., Warde-Farley, D., Ozair, S., Courville, A. C., and Bengio, Y. Generative Adversarial Networks. CoRR, abs/1406.2661, 2014. URL http://arxiv.org/abs/1406.2661.
302
+ Heusel, M., Ramsauer, H., Unterthiner, T., Nessler, B., Klambauer, G., and Hochreiter, S. GANs Trained by a Two Time-scale Update Rule Converge to a Nash Equilibrium. arXiv preprint arXiv:1706.08500, 12(1), 2017.
303
+ Higgins, I., Matthey, L., Pal, A., Burgess, C. P., Glorot, X., Botvinick, M. M., Mohamed, S., and Lerchner, A. Beta-VAE: Learning Basic Visual Concepts with a Constrained Variational Framework. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings. OpenReview.net, 2017. URL https://openreview.net/forum?id=Sy2fzU9gl.
304
+ Hoffman, M. D. and Johnson, M. J. ELBO Surgery: Yet Another Way to Carve Up the Evidence Lower Bound. In Proc. Workshop Adv. Approx. Bayesian Inference, pp. 2, 2016.
305
+ Julier, S., Uhlmann, J., and Durrant-Whyte, H. F. A New Method for the Nonlinear Transformation of Means and Covariances In Filters and Estimators. IEEE Transactions on automatic control, 45(3):477-482, 2000.
306
+ Karl, M., Soelch, M., Bayer, J., and Van der Smagt, P. Deep Variational Bayes Filters: Unsupervised Learning of State Space Models From Raw Data. arXiv preprint arXiv:1605.06432, 2016.
307
+ Khromov, G. and Singh, S. P. Some fundamental aspects about lipschitz continuity of neural network functions, 2023.
308
+ Kingma, D. P. and Welling, M. Auto-encoding Variational Bayes. arXiv preprint arXiv:1312.6114, 2013.
309
+ Kingma, D. P., Salimans, T., and Welling, M. Variational Dropout and the Local Reparameterization Trick. Advances in neural information processing systems, 28, 2015.
310
+ Krizhevsky, A., Hinton, G., et al. Learning Multiple Layers of Features From Tiny Images. 2009.
311
+
312
+ Kusner, M. J., Paige, B., and Hernández-Lobato, J. M. Grammar Variational Autoencoder. In Precup, D. and Teh, Y. W. (eds.), Proceedings of the 34th International Conference on Machine Learning, volume 70 of Proceedings of Machine Learning Research, pp. 1945-1954. PMLR, 06-11 Aug 2017. URL https://proceedings.mlrpress/v70/kusnerl7a.html.
313
+ Liu, Z., Luo, P., Wang, X., and Tang, X. Deep Learning Face Attributes In the Wild. In Proceedings of International Conference on Computer Vision (ICCV), December 2015.
314
+ Lucas, J., Tucker, G., Grosse, R. B., and Norouzi, M. Understanding Posterior Collapse In Generative Latent Variable Models. In Deep Generative Models for Highly Structured Data, ICLR 2019 Workshop, New Orleans, Louisiana, United States, May 6, 2019. OpenReview.net, 2019. URL https://openreview.net/forum?id=r1xaVLUYuE.
315
+ Mathieu, E., Rainforth, T., Siddharth, N., and Teh, Y. W. Disentangling Disentanglement In Variational Autoencoders. In Chaudhuri, K. and Salakhutdinov, R. (eds.), Proceedings of the 36th International Conference on Machine Learning, volume 97 of Proceedings of Machine Learning Research, pp. 4402-4412. PMLR, 09-15 Jun 2019. URL https://proceedings.mlrpress/v97/mathieu19a.html.
316
+ Menegaz, H. M., Ishihara, J. Y., Borges, G. A., and Vargas, A. N. A Systematization of the Unscented Kalman Filter Theory. IEEE Transactions on automatic control, 60 (10):2583-2598, 2015.
317
+ Paszke, A., Gross, S., Massa, F., Lerer, A., Bradbury, J., Chanan, G., Killeen, T., Lin, Z., Gimelshein, N., Antiga, L., et al. Pytorch: An Imperative Style, High-performance Deep Learning Library. Advances in neural information processing systems, 32, 2019.
318
+ Patrini, G., van den Berg, R., Forre, P., Carioni, M., Bhargav, S., Welling, M., Genewein, T., and Nielsen, F. Sinkhorn Autoencoders. In Uncertainty in Artificial Intelligence, pp. 733-743. PMLR, 2020.
319
+ Rainforth, T., Kosiorek, A., Le, T. A., Maddison, C., Igl, M., Wood, F., and Teh, Y. W. Tighter Variational Bounds Are Not Necessarily Better. In International Conference on Machine Learning, pp. 4277-4285. PMLR, 2018.
320
+ Rezende, D. J., Mohamed, S., and Wierstra, D. Stochastic Backpropagation and Approximate Inference in Deep Generative Models. In Proceedings of the 31st International Conference on International Conference on Machine Learning - Volume 32, ICML'14, pp. II-1278-II-1286. JMLR.org, 2014.
321
+
322
+ Rolinek, M., Zietlow, D., and Martius, G. Variational Autoencoders Pursue PCA Directions (by Accident). In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12406-12415, 2019.
323
+ Rombach, R., Blattmann, A., Lorenz, D., Esser, P., and Ommer, B. High-resolution Image Synthesis with Latent Diffusion Models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10684-10695, 2022.
324
+ Seitzer, M. Pytorch-fid: FID Score for PyTorch. https://github.com/mseitzer/pytorch-fid, August 2020. Version 0.2.1.
325
+ Tolstikhin, I. O., Bousquet, O., Gelly, S., and Scholkopf, B. Wasserstein Auto-Encoders. In 6th International Conference on Learning Representations, ICLR 2018, Vancouver, BC, Canada, April 30 - May 3, 2018, Conference Track Proceedings. OpenReview.net, 2018. URL https://openreview.net/forum?id=HkL7n1-0b.
326
+ Townsend, J., Bird, T., and Barber, D. Practical Lossless Compression with Latent Variables Using Bits Back Coding. In 7th International Conference on Learning Representations, ICLR 2019, New Orleans, LA, USA, May 6-9, 2019. OpenReview.net, 2019. URL https://openreview.net/forum?id=ryE98iR5tm.
327
+ Tripp, A., Daxberger, E. A., and Hernández-Lobato, J. M. Sample-Efficient Optimization In the Latent Space of Deep Generative Models Via Weighted Retraining. In Larochelle, H., Ranzato, M., Hadsell, R., Balcan, M., and Lin, H. (eds.), Advances in Neural Information Processing Systems 33: Annual Conference on Neural Information Processing Systems 2020, NeurIPS 2020, December 6-12, 2020, virtual, 2020.
328
+ Tucker, G., Lawson, D., Gu, S., and Maddison, C. J. Doubly Reparameterized Gradient Estimators for Monte Carlo Objectives. arXiv preprint arXiv:1810.04152, 2018.
329
+ Uhlmann, J. Dynamic Map Building and Localization: New Theoretical Foundations. PhD thesis, University of Oxford, 1995.
330
+ Vahdat, A. and Kautz, J. NVAE: A Deep Hierarchical Variational Autoencoder. In Neural Information Processing Systems (NeurIPS), 2020.
331
+ Xiao, H., Rasul, K., and Vollgraf, R. Fashion-MNIST: a Novel Image Dataset for Benchmarking Machine Learning Algorithms. arXiv preprint arXiv:1708.07747, 2017.
332
+ Xu, B., Wang, N., Chen, T., and Li, M. Empirical Evaluation of Rectified Activations In Convolutional Network. arXiv preprint arXiv:1505.00853, 2015.
333
+
334
+ Zhang, C., Butepage, J., Kjellström, H., and Mandt, S. Advances in Variational Inference. IEEE transactions on pattern analysis and machine intelligence, 41(8):2008-2026, 2018.
335
+ Zhang, W., Liu, M., and Zhao, Z.-g. Accuracy Analysis of Unscented Transformation of Several Sampling Strategies. In 2009 10th ACIS International Conference on Software Engineering, Artificial Intelligences, Networking and Parallel/Distributed Computing, pp. 377-380. IEEE, 2009.
336
+ Zietlow, D., Rolinek, M., and Martius, G. Demystifying Inductive Biases for (Beta-) VAE Based Architectures. In International Conference on Machine Learning, pp. 12945-12954. PMLR, 2021.
337
+
338
+ # Appendix
339
+
340
+ # A. Network Architecture and Training
341
+
342
+ Table 4: Network architectures of the implemented VAE, RAE, and UAE models. Batch dimensions omitted for clarity.
343
+
344
+ <table><tr><td>VAE, UAE: xC×W×H → ENCODER → {FC1024×n: μφ, FC1024×n: log σφ2} → z → DECODER → x̂</td></tr><tr><td>RAE: xC×W×H → ENCODER → {FC1024×n: zφ} → DECODER → x̂</td></tr><tr><td>ENCODER: CONV32×64 → CONV64×128 → CONV128×256 → CONV256×512 → CONV512×1024 → FLATTEN</td></tr><tr><td>DECODER: FCn×1024·8·8 → TCONV1024×512 → TCONV512×256[→ TCONV256×128]CelebA → TCONV256or128×C</td></tr><tr><td>MNIST: C = 1, W = H = 32, n = 64</td></tr><tr><td>CIFAR10: C = 3, W = H = 32, n = 128</td></tr><tr><td>CELEBA: C = 3, W = H = 64, n = 64</td></tr></table>
345
+
346
+ Network architectures are given in Tab. 4 and largely follow the architecture in (Ghosh et al., 2019). For consistency, all models share the same encoder/decoder structure. All encoder 2D convolution blocks contain $3 \times 3$ kernels, stride 2, and padding 1, followed by a 2D batch normalization and a Leaky-ReLU activation. The decoder transposed convolutions share the same parameters as the encoder convolutions apart from using a $4 \times 4$ kernel. The last transposed convolution (mapping to channel dimension) however has a $3 \times 3$ kernel and is followed by a tanh activation (without batch normalization).
347
+
348
+ The dataset preprocessing procedure is the following. The Fashion-MNIST images are scaled from $28 \times 28$ to $32 \times 32$ . For the training dataset, we use $50k$ out of the $60k$ provided examples, leaving the remaining $10k$ for the validation dataset. For the test dataset, we use the provided examples. In CIFAR10, we perform a random horizontal flip on the training data followed by a normalization for all dataset subsets. We use the same training/validation/test split method as in Fashion-MNIST. In CelebA, we perform a $148 \times 148$ center crop and resize the images to $64 \times 64$ . We use the provided training/validation/testing subsets.
349
+
350
+ All models are implemented in PyTorch (Paszke et al., 2019) and use the library provided in (Seitzer, 2020) for FID computation. The models are trained for 100 epochs, starting with a 0.005 learning rate that is then halved after every five epochs without improvement. The weights used in the loss functions are the following: KL-divergence (or the Wasserstein metric) terms are weighted with $\beta = 2.5e^{-4}$ in the case of VAE and UAE and $\beta = 1e^{-4}$ for the RAE. The decoder regularization terms are weighted with $\gamma = 1e^{-6}$ for both RAE and UAE. We performed minimal hyperparameter search over the weights.
351
+
352
+ In computing the FID scores, we follow the same procedure as in (Ghosh et al., 2019). In the three cases of reconstruction, sampling, and interpolation, we evaluate the FID to the test set image reconstructions as the ground-truth. In the reconstruction metric, we use the validation set image reconstructions. In sampling, we fit the training dataset latent features to a GMM (see Sec. 5.1) and sample and reconstruct the same number of elements as in the test set. In interpolation, we apply mid-point spherical interpolation between a random pair of validation set embeddings. In all cases, we generate a single image per input; this image corresponds to the posterior mean of the latent distribution. This mean latent feature vector is also used in sampling and interpolation while fitting a mixture ex-post or interpolating the latent space vectors. Thus, the resulting number of generated images for FID computation is the same regardless of the number of sigma points or samples used in training. In all experiments, the average FID score of three runs is reported, while observing a similar variation between scores of individual runs among the models employing the UT compared to the vanilla VAE. In contrast, the scores of RAE and VAE* modes were significantly more consistent.
353
+
354
+ The network architectures largely follow the structure adopted by (Ghosh et al., 2019), with the difference of the added first two encoder layers. Nevertheless, in Tab. 2, we did not manage to reproduce the FID values reported in (Ghosh et al., 2019) on CelebA and CIFAR10, even observing that removing the first two encoder layers reduces the overall performance. We suspect that it is due to the differing Tensorflow and PyTorch model implementations as well as the FID computation libraries. However, in most cases, our implementation of the RAE attains a significantly larger performance gain over the VAE than reported in (Ghosh et al., 2019).
355
+
356
+ ![](images/3fecac6a18d7d08998b57382bb78ac61bd8a5b13849c717aabb5797ca7b07d51.jpg)
357
+ (a) Median of the decoder gradient CV for UT-VAE and $\mathrm{VAE}^{\dagger}$
358
+
359
+ ![](images/72b6d49e04327456b7ccfff8572b892e9e36a05f1486d8489a3aa69ff9f93fa5.jpg)
360
+ (b) Median relative bias based on an estimate of the true gradient using 200 random samples
361
+ Figure 4: Comparison of the variance and bias trade-off for the $\mathrm{VAE}^{\dagger}$ (employing the decoder output mean instead of the sample mean, see Tab. 3) and UT-VAE across approx. 60k training steps (100 epochs) on the CIFAR10 dataset. The data is based on a single training of an UT-VAE where every 50th epoch the gradient variance and bias was estimated using different sampling schemes. In case of $\mathrm{VAE}^{\dagger}$ , two random points are sampled (in accordance with the reparameterization trick), while in case of UT-VAE, a single sigma point pair is sampled.
362
+
363
+ # B. Gradient Variance and Bias
364
+
365
+ In this section, we investigate the gradient variance and bias of the proposed base UT-VAE model. Compared to random sampling of the reparameterization trick, using a different integration scheme like sampling sigma points can be biased. It can nevertheless achieve lower variance depending on the nonlinear function of the decoder. Thus, for our decoder setup, we compare the gradient variance and bias of the UT-VAE (with random sigma pair sampling) and the $\mathrm{VAE}^{\dagger}$ (with random sampling) employing the decoder output mean instead of the sample mean<sup>6</sup> (see Tab. 3 for a performance comparison) in order to isolate the effect of sampling sigma points.
366
+
367
+ We train both models and estimate the gradient variance and bias every 50th iteration. For UT-VAE we independently sample 50 sigma point pairs, pass them through the decoder, and calculate the gradients' mean $m_j$ and standard deviation $\sigma_j$ . For $\mathrm{VAE}^\dagger$ we draw 2 random samples 200 times and perform the same steps to obtain $m_j'$ and $\sigma_j'$ . We calculate the median Coefficient of Variation (CV) of the gradients for both models, assuming that $m_j'$ computed with 200 random samples is a good enough estimate of the true gradient. Furthermore, we compute the median relative bias $b_{rel}$ for the decoder gradients and output of the UT-VAE. The CV (for UT-VAE) and $b_{rel}$ (for decoder gradients bias) are computed as follows
368
+
369
+ $$
370
+ \mathrm {C V} = \operatorname {m e d i a n} \left\{\frac {\sigma_ {j}}{| m _ {j} |} \right\} \quad b _ {r e l} = \operatorname {m e d i a n} \left\{\frac {| m _ {j} - m _ {j} ^ {\prime} |}{| m _ {j} ^ {\prime} |} \right\}. \tag {21}
371
+ $$
372
+
373
+ The gradient variance results are depicted in Fig. 4a. The variance of the sigma pair sampling of the UT-VAE is consistently lower than the gradient variance of the random sampling within $\mathrm{VAE}^{\dagger}$ . Interestingly, for the $\mathrm{VAE}^{\dagger}$ the standard deviation of the gradients is on average larger than the magnitude of the gradient during the whole training, whereas for the UT-VAE this is only the case at the end of the training. Fig. 4b shows the relative decoder output bias as well as the relative gradient bias of the UT-VAE at the same iterations. Whereas the relative bias at the decoder output is below $3\%$ throughout the whole training, the bias of the gradients is around $30\%$ of their magnitude. It is unclear whether such a substantial gradient bias is behind the good performance of the UT-VAE or if there is a performance trade-off between variance and bias. Nevertheless, our experiments show that, under a common decoder architecture, integration schemes like the UT can exhibit lower variance and higher bias while outperforming the standard VAE sampling scheme. Thus, investigating alternative integration schemes for VAEs can be a promising research direction.
374
+
375
+ Table 5: Analysis of the number of sampled sigma points and different heuristics, where the mean image of multiple sigma points is matched to the ground truth in the reconstruction loss. The three investigated heuristics are sampling random sigma points, random pairs of sigma points along an axis, and pairs of sigma points along axes with largest eigenvalues.
376
+
377
+ <table><tr><td rowspan="2"></td><td colspan="3">Fashion-MNIST</td><td colspan="3">CIFAR10</td><td colspan="3">CelebA</td></tr><tr><td>Rec.</td><td>Samp.</td><td>Interp.</td><td>Rec.</td><td>Samp.</td><td>Interp.</td><td>Rec.</td><td>Samp.</td><td>Interp.</td></tr><tr><td>UT-VAE1x,rand.</td><td>47.27</td><td>52.10</td><td>67.16</td><td>119.9</td><td>129.8</td><td>127.9</td><td>55.93</td><td>62.13</td><td>60.54</td></tr><tr><td>UT-VAE2x,rand.</td><td>36.25</td><td>40.30</td><td>53.10</td><td>111.5</td><td>124.7</td><td>121.0</td><td>51.61</td><td>57.42</td><td>56.56</td></tr><tr><td>UT-VAE4x,rand.</td><td>32.13</td><td>36.41</td><td>47.30</td><td>105.9</td><td>119.8</td><td>115.9</td><td>50.85</td><td>55.82</td><td>55.99</td></tr><tr><td>UT-VAE8x,rand.</td><td>27.79</td><td>30.39</td><td>39.92</td><td>95.40</td><td>110.8</td><td>106.4</td><td>50.11</td><td>54.15</td><td>44.32</td></tr><tr><td>UT-VAE*2x,rand.</td><td>28.26</td><td>36.36</td><td>50.69</td><td>85.88</td><td>103.7</td><td>96.90</td><td>44.32</td><td>50.33</td><td>52.40</td></tr><tr><td>UT-VAE*4x,rand.</td><td>24.38</td><td>32.75</td><td>49.40</td><td>81.99</td><td>100.6</td><td>93.52</td><td>42.52</td><td>49.21</td><td>51.35</td></tr><tr><td>UT-VAE*8x,rand.</td><td>23.64</td><td>31.51</td><td>48.06</td><td>81.10</td><td>99.87</td><td>92.48</td><td>40.18</td><td>47.39</td><td>49.62</td></tr><tr><td>UT-VAE2x,rand. pairs</td><td>102.1</td><td>115.1</td><td>112.8</td><td>102.3</td><td>119.6</td><td>114.0</td><td>150.0</td><td>150.4</td><td>151.3</td></tr><tr><td>UT-VAE4x,rand. pairs</td><td>96.85</td><td>110.1</td><td>107.3</td><td>101.0</td><td>119.5</td><td>113.4</td><td>224.3</td><td>225.0</td><td>225.4</td></tr><tr><td>UT-VAE8x,rand. pairs</td><td>90.14</td><td>103.6</td><td>101.5</td><td>100.3</td><td>119.2</td><td>113.2</td><td>173.2</td><td>175.4</td><td>175.8</td></tr><tr><td>UT-VAE*2x,rand. pairs</td><td>32.66</td><td>38.68</td><td>58.72</td><td>85.64</td><td>102.3</td><td>97.00</td><td>45.96</td><td>53.16</td><td>51.49</td></tr><tr><td>UT-VAE*4x,rand. pairs</td><td>32.85</td><td>38.58</td><td>57.70</td><td>84.62</td><td>102.2</td><td>96.14</td><td>252.9</td><td>254.8</td><td>253.8</td></tr><tr><td>UT-VAE*8x,rand. pairs</td><td>30.65</td><td>36.88</td><td>56.42</td><td>80.51</td><td>98.40</td><td>91.96</td><td>141.9</td><td>144.3</td><td>147.4</td></tr><tr><td>UT-VAE2x,larg. λ pairs</td><td>106.6</td><td>118.6</td><td>115.7</td><td>95.70</td><td>115.4</td><td>107.3</td><td>54.02</td><td>60.29</td><td>60.26</td></tr><tr><td>UT-VAE4x,larg. λ pairs</td><td>108.3</td><td>120.1</td><td>117.2</td><td>92.56</td><td>111.6</td><td>104.2</td><td>46.37</td><td>53.53</td><td>52.62</td></tr><tr><td>UT-VAE8x,larg. λ pairs</td><td>115.5</td><td>128.8</td><td>126.3</td><td>91.04</td><td>111.7</td><td>104.3</td><td>48.59</td><td>55.22</td><td>55.29</td></tr><tr><td>UT-VAE*2x,larg. λ pairs</td><td>33.49</td><td>42.63</td><td>61.57</td><td>82.17</td><td>100.7</td><td>93.80</td><td>55.57</td><td>61.42</td><td>61.53</td></tr><tr><td>UT-VAE*4x,larg. λ pairs</td><td>34.94</td><td>43.18</td><td>67.65</td><td>81.61</td><td>101.3</td><td>94.11</td><td>48.41</td><td>54.70</td><td>54.80</td></tr><tr><td>UT-VAE*8x,larg. λ pairs</td><td>31.08</td><td>41.06</td><td>64.58</td><td>81.12</td><td>100.6</td><td>93.80</td><td>45.08</td><td>51.45</td><td>52.05</td></tr></table>
378
+
379
+ # C. Additional Results: Multi-Sigma Heuristics and Multi-Sample Models
380
+
381
+ The UT-VAE loss function defined in Tab. 1 samples $K$ sigma points in the reconstruction term. Increasing the number of sigma points (up to $2n + 1$ ) improves the estimate of the transformed posterior distribution and thus the resulting reconstruction quality, at the expense of an approximately linear increase in training time. We observed this in most cases when training on 2, 4, and 8 sigma points, see Tab. 5. However, a much larger number of sigma points might not result in expected additional performance improvement due to significantly larger batch size, which could be mitigated by constructing approaches to select and train on a fixed, smaller batch size.
382
+
383
+ For $K$ selected sigma points, various strategies can be used instead of sampling a discrete uniform distribution. For example, only pairs of sigma points along an axis can be chosen, conveying the width of the posterior distribution in the given dimension. This strategy can be adapted to select pairs along axes with largest eigenvalues. Tab. 5 also explores different sampling heuristics in the case of UT-VAE and UT-VAE*. We have observed that models trained with KL divergence exhibit larger variation in results w.r.t. the sampling heuristic, which is reasonable since the Wasserstein metric's posterior variance suppression diminishes the effect of sampling. The choice of the sigma-point selection heuristic turns out to have a large effect on the overall performance given a dataset. We have observed that a random selection of sigma points performs consistently well across all datasets while selecting random pairs generates reasonable results only in the case of CIFAR10. Interestingly, random-pairs performs very poorly on Fashion-MNIST and CelebA while largest eigenvalue pairs show very good performance in the UT-VAE case on CIFAR10. In the main experiments of Tab. 2, we used a random selection for the Fashion-MNIST and CelebA models and largest-eigenvalue pairs for CIFAR10, due to its superior performance in the UT-VAE case.
384
+
385
+ Tab. 6 analyzes models using multiple samples in training. We compare the VAE* and the UAE with the classical VAE and the IwAE (Burda et al., 2016) as a baseline where multiple importance-weighted posterior samples help achieve a tighter lower bound. Observing the results, it is clear that models employing the Wasserstein metric can benefit from increasing the number of samples in training despite their ability to reduce the latent space variance, while significantly outperforming the baselines.
386
+
387
+ Table 6: Comparison of models employing multiple samples in training. The UAE uses random sigma points on Fashion-MNIST and CelebA and largest-eigenvalue pairs on CIFAR10.
388
+
389
+ <table><tr><td></td><td colspan="3">Fashion-MNIST</td><td colspan="3">CIFAR10</td><td colspan="3">CelebA</td></tr><tr><td></td><td>Rec.</td><td>Sample</td><td>Interp.</td><td>Rec.</td><td>Sample</td><td>Interp.</td><td>Rec.</td><td>Sample</td><td>Interp.</td></tr><tr><td>VAE1x</td><td>45.64</td><td>49.99</td><td>61.33</td><td>116.4</td><td>126.8</td><td>124.2</td><td>68.32</td><td>71.05</td><td>71.16</td></tr><tr><td>VAE2x</td><td>43.66</td><td>49.01</td><td>61.03</td><td>112.7</td><td>123.2</td><td>120.6</td><td>67.29</td><td>69.92</td><td>70.00</td></tr><tr><td>VAE4x</td><td>44.94</td><td>49.51</td><td>62.29</td><td>111.7</td><td>121.3</td><td>119.5</td><td>66.32</td><td>68.87</td><td>69.06</td></tr><tr><td>VAE8x</td><td>44.29</td><td>48.73</td><td>61.99</td><td>110.0</td><td>120.6</td><td>118.3</td><td>65.86</td><td>68.53</td><td>68.75</td></tr><tr><td>IWAE1x</td><td>49.27</td><td>53.71</td><td>64.50</td><td>111.7</td><td>121.6</td><td>119.6</td><td>68.28</td><td>71.16</td><td>71.17</td></tr><tr><td>IWAE2x</td><td>48.21</td><td>53.11</td><td>65.69</td><td>112.1</td><td>122.4</td><td>119.8</td><td>66.85</td><td>69.81</td><td>69.74</td></tr><tr><td>IWAE4x</td><td>47.40</td><td>51.77</td><td>64.10</td><td>110.6</td><td>120.6</td><td>118.2</td><td>66.01</td><td>68.82</td><td>68.90</td></tr><tr><td>IWAE8x</td><td>46.16</td><td>50.91</td><td>63.68</td><td>108.9</td><td>118.9</td><td>116.9</td><td>64.83</td><td>67.96</td><td>67.86</td></tr><tr><td>VAE*1x</td><td>31.62</td><td>38.44</td><td>52.33</td><td>83.49</td><td>101.5</td><td>94.56</td><td>44.69</td><td>50.55</td><td>53.18</td></tr><tr><td>VAE*2x</td><td>30.07</td><td>37.92</td><td>52.15</td><td>84.57</td><td>102.2</td><td>95.61</td><td>45.18</td><td>50.97</td><td>53.73</td></tr><tr><td>VAE*4x</td><td>28.98</td><td>41.35</td><td>52.17</td><td>84.64</td><td>102.3</td><td>95.96</td><td>45.03</td><td>50.59</td><td>53.32</td></tr><tr><td>VAE*8x</td><td>27.36</td><td>36.63</td><td>52.61</td><td>82.22</td><td>99.11</td><td>92.84</td><td>45.02</td><td>50.81</td><td>53.64</td></tr><tr><td>UAE2x</td><td>29.29</td><td>37.59</td><td>53.69</td><td>77.71</td><td>96.37</td><td>89.71</td><td>40.07</td><td>47.28</td><td>50.51</td></tr><tr><td>UAE4x</td><td>27.11</td><td>38.03</td><td>53.11</td><td>75.63</td><td>93.02</td><td>86.41</td><td>39.48</td><td>46.35</td><td>50.94</td></tr><tr><td>UAE8x</td><td>25.07</td><td>35.19</td><td>54.24</td><td>71.97</td><td>89.91</td><td>83.50</td><td>38.48</td><td>45.60</td><td>45.88</td></tr></table>
390
+
391
+ # D. Additional Results: Ablation Study of the Loss Components
392
+
393
+ This section provides an additional ablation study of the loss components used in the UAE model. The loss functions considered are provided in the upper half of Tab. 7 and the obtained results are in Tab. 8. There are three dimensions along which the results can be interpreted: Wasserstein metric, unscented transform, and the generalized decoder regularization (gradient penalty).
394
+
395
+ Tab. 8 is divided into two parts: the top part models use the analytical form of the KL divergence in Eq. (10) while the bottom part uses the Frobenius norm mismatch derived from the Wasserstein metric in Eq. (11). It is clearly visible that the latter models strongly outperform the former, in all datasets and configurations. The loss function allows for a sharper posterior and thus larger expressiveness of the model (see Appendix H).
396
+
397
+ Similarly, the unscented transform models UT-VAE and UT-VAE* clearly outperform the random sampling and per-sample reconstruction counterparts of VAE and VAE*. In the latter case, the differences are smaller due to the sharper posterior of the VAE*. An ablation study of the unscented transform components can be found in Tab. 3.
398
+
399
+ Considering the gradient penalty models, interesting interplays can be noticed. Applying the decoder regularization on the vanilla VAE and the VAE* (this model can be considered closest to the RAE-GP) brings only minor improvements in the case of CIFAR10 and CelebA for each of the models respectively. The strong smoothing of the latent space however seems detrimental when combined with the unscented transform and the KL divergence training. One can conclude that only the latent space regularization models (such as the Wasserstein metric VAE* or the deterministic RAE) can benefit from decoder regularization. Furthermore, the effect appears to be dataset-dependent since the Fashion-MNIST VAE* and UT-VAE* slightly regress when augmented with decoder regularization.
400
+
401
+ Table 7: The loss functions used for the models in Tab. 8 and Tab. 9. The upper and lower half of the table contain diagonal and full-covariance posterior models, respectively.
402
+
403
+ <table><tr><td colspan="2">Loss function</td><td>Posterior sampling</td></tr><tr><td>LVAE</td><td>1/K ∑k=1K ||x-Dθ(zk)||22+||μφ||22-n+∑iσφ,i-2 log σφ,i</td><td>zk=μφ+σφ⊙εk, εk~N(0,I)</td></tr><tr><td>LVAE-GP</td><td>1/K ∑k=1K ||x-Dθ(zk)||22+||μφ||22+∑iσφ,i-2 log σφ,i+max(σφ)||∇μφDθ(μφ)||2</td><td>zk=μφ+σφ⊙εk, εk~N(0,I)</td></tr><tr><td>LUT-VAE</td><td>||x-1/K ∑k=1KDθ(zk)||22+||μφ||22+∑iσφ,i-2 log σφ,i</td><td>zk~{χi(μφ,diag(σφ))}2n i=0</td></tr><tr><td>LUT-VAE-GP</td><td>||x-1/K ∑k=1KDθ(zk)||22+||μφ||22+∑iσφ,i-2 log σφ,i+max(σφ)||∇μφDθ(μφ)||2</td><td>zk~{χi(μφ,diag(σφ))}2n i=0</td></tr><tr><td>LVAE*</td><td>1/K ∑k=1K ||x-Dθ(zk)||22+||μφ||22+||diag(σφ)-I||F</td><td>zk=μφ+σφ⊙εk, εk~N(0,I)</td></tr><tr><td>LVAE*-GP</td><td>1/K ∑k=1K ||x-Dθ(zk)||22+||μφ||22+||diag(σφ)-I||F+max(σφ)||∇μφDθ(μφ)||2</td><td>zk=μφ+σφ⊙εk, εk~N(0,I)</td></tr><tr><td>LUT-VAE*</td><td>||x-1/K ∑k=1KDθ(zk)||22+||μφ||22+||diag(σφ)-I||F</td><td>zk~{χi(μφ,diag(σφ))}2n i=0</td></tr><tr><td>LUT-VAE*-GP</td><td>||x-1/K ∑k=1KDθ(zk)||22+||μφ||22+||diag(σφ)-I||F+max(σφ)||∇μφDθ(μφ)||2</td><td>zk~{χi(μφ,diag(σφ))}2n i=0</td></tr><tr><td>LVAE-full Σφ</td><td>1/K ∑k=1K ||x-Dθ(zk)||22+||μφ||22+tr(Σφ)-2tr(log Lφ)</td><td>zk=μφ+Lφεk, εk~N(0,I)</td></tr><tr><td>LVAE-full Σφ-GP</td><td>1/K ∑k=1K ||x-Dθ(zk)||22+||μφ||22+tr(Σφ)-2tr(log Lφ)+λmax(Σφ)||∇μφDθ(μφ)||2</td><td>zk=μφ+Lφεk, εk~N(0,I)</td></tr><tr><td>LUT-VAE-full Σφ</td><td>||x-1/K ∑k=1KDθ(zk)||22+||μφ||22+tr(Σφ)-2tr(log Lφ)</td><td>zk~{χi(μφ,Σφ)}2n i=0</td></tr><tr><td>LUT-VAE-full Σφ-GP</td><td>||x-1/K ∑k=1KDθ(zk)||22+||μφ||22+tr(Σφ)-2tr(log Lφ)+λmax(Σφ)||∇μφDθ(μφ)||2</td><td>zk~{χi(μφ,Σφ)}2n i=0</td></tr><tr><td>LVAE*-full Σφ</td><td>1/K ∑k=1K ||x-Dθ(zk)||22+||μφ||22+||Lφ-I||F</td><td>zk=μφ+Lφεk, εk~N(0,I)</td></tr><tr><td>LVAE*-full Σφ-GP</td><td>1/K ∑k=1K ||x-Dθ(zk)||22+||μφ||22+||Lφ-I||F+λmax(Σφ)||∇μφDθ(μφ)||2</td><td>zk=μφ+Lφεk, εk~N(0,I)</td></tr><tr><td>LUT-VAE*-full Σφ</td><td>||x-1/K ∑k=1KDθ(zk)||22+||μφ||22+||Lφ-I||F</td><td>zk~{χi(μφ,Σφ)}2n i=0</td></tr><tr><td>LUT-VAE*-full Σφ-GP</td><td>||x-1/K ∑k=1KDθ(zk)||22+||μφ||22+||Lφ-I||F+λmax(Σφ)||∇μφDθ(μφ)||2</td><td>zk~{χi(μφ,Σφ)}2n i=0</td></tr></table>
404
+
405
+ Table 8: Full ablation study of the models between the VAE and UAE (in the UT-VAE*GP row), using the Wasserstein metric denoted by *, unscented transform (UT), and the decoder gradient penalty (GP) components. See the upper half Tab. 7 for the loss function definitions.
406
+
407
+ <table><tr><td></td><td colspan="3">Fashion-MNIST</td><td colspan="3">CIFAR10</td><td colspan="3">CelebA</td></tr><tr><td></td><td>Rec.</td><td>Sample</td><td>Interp.</td><td>Rec.</td><td>Sample</td><td>Interp.</td><td>Rec.</td><td>Sample</td><td>Interp.</td></tr><tr><td>VAE2x</td><td>43.66</td><td>49.01</td><td>61.03</td><td>112.7</td><td>123.2</td><td>120.6</td><td>67.29</td><td>69.92</td><td>70.00</td></tr><tr><td>VAE-GP2x</td><td>44.17</td><td>48.63</td><td>59.58</td><td>108.9</td><td>120.3</td><td>117.5</td><td>66.94</td><td>70.16</td><td>69.77</td></tr><tr><td>UT-VAE2x</td><td>36.25</td><td>40.30</td><td>53.10</td><td>95.70</td><td>115.4</td><td>107.4</td><td>51.61</td><td>57.42</td><td>56.56</td></tr><tr><td>UT-VAE-GP2x</td><td>47.77</td><td>65.24</td><td>72.43</td><td>102.6</td><td>118.6</td><td>113.1</td><td>100.4</td><td>102.2</td><td>100.3</td></tr><tr><td>VAE*2x</td><td>30.07</td><td>37.92</td><td>52.15</td><td>84.57</td><td>102.2</td><td>95.61</td><td>45.18</td><td>50.97</td><td>53.73</td></tr><tr><td>VAE*-GP2x</td><td>29.40</td><td>38.53</td><td>53.88</td><td>85.19</td><td>103.7</td><td>96.66</td><td>41.69</td><td>48.77</td><td>51.29</td></tr><tr><td>UT-VAE*2x</td><td>28.26</td><td>36.36</td><td>50.69</td><td>82.17</td><td>100.7</td><td>93.80</td><td>44.32</td><td>50.33</td><td>52.40</td></tr><tr><td>UT-VAE* -GP2x</td><td>29.29</td><td>37.59</td><td>53.69</td><td>77.71</td><td>96.37</td><td>89.71</td><td>40.07</td><td>47.28</td><td>50.51</td></tr></table>
408
+
409
+ # E. ELBO Constraint Derivation
410
+
411
+ In this section, we complete the derivation of the constraint in Eq. (14) to the reformulated version in Eq. (15). The constraint in Eq. (14) can be bounded by the maximum of the decoder output in a single dimension $i$ , multiplied by the number of dimensions
412
+
413
+ $$
414
+ \left\| D _ {\theta} \left(\mathbf {z} _ {1}\right) - D _ {\theta} \left(\mathbf {z} _ {2}\right) \right\| _ {p} \leq \dim (\mathbf {x}) \cdot \sup _ {i} \left\{\left\| d _ {i} \left(\mathbf {z} _ {1}\right) - d _ {i} \left(\mathbf {z} _ {2}\right) \right\| _ {p} \right\} < \epsilon . \tag {22}
415
+ $$
416
+
417
+ Using the mean value theorem, the term $\sup_{i}\{\| d_{i}(\mathbf{z}_{1}) - d_{i}(\mathbf{z}_{2})\|_{p}\}$ can be reduced to
418
+
419
+ $$
420
+ \sup _ {i} \left\{\| \nabla_ {t} d _ {i} ((1 - t) \mathbf {z} _ {1} + t \mathbf {z} _ {2}) \| _ {p} \cdot \| \mathbf {z} _ {1} - \mathbf {z} _ {2} \| _ {p} \right\} < \epsilon , \tag {23}
421
+ $$
422
+
423
+ Since $\mathbf{z}_1$ and $\mathbf{z}_2$ are arbitrary, the first part can be simplified and generalized over all dimensions while separating the overall product using the Cauchy-Schwarz inequality
424
+
425
+ $$
426
+ \sup _ {i} \left\{\| \nabla_ {\mathbf {z}} d _ {i} (\mathbf {z}) \| _ {p} \cdot \| \mathbf {z} _ {1} - \mathbf {z} _ {2} \| _ {p} \right\} < \epsilon \tag {24}
427
+ $$
428
+
429
+ $$
430
+ \sup \left\{\| \nabla_ {\mathbf {z}} D _ {\theta} (\mathbf {z}) \| _ {p} \right\} \cdot \sup \left\{\| \mathbf {z} _ {1} - \mathbf {z} _ {2} \| _ {p} \right\} < \epsilon , \tag {25}
431
+ $$
432
+
433
+ obtaining the form in Eq. (15).
434
+
435
+ # F. Full-Covariance Posterior
436
+
437
+ In this section, we aim to investigate the performance of full-covariance posterior models. The non-diagonal posterior representation is naturally supported by the unscented transform and common in filtering. However, it is seldom in VAEs – one of the key ingredients of the standard VAE model is its diagonal Gaussian posterior approximation. The induced orthogonality can implicitly have positive effects on the structure of the latent space and the decoder (Zietlow et al., 2021; Rolinek et al., 2019), but such effects highly depend on implicit biases present in the dataset (Zietlow et al., 2021). Furthermore, the diagonal posterior together with the KL regularization allows for pruning unnecessary latent dimensions, also known as desired posterior collapse (Dai et al., 2020). A full-covariance posterior does not have such implicit biases and pruning properties, but it can have a positive effect on the optimization of the variational objective, as it connects otherwise disconnected global optima (Dai et al., 2018). Furthermore, it allows for modeling correlations in the posterior. We are not aware of a work successfully employing a full-covariance posterior.
438
+
439
+ The full-covariance representation can be practically realized by predicting $n$ -dimensional standard deviations $\sigma_{\phi}$ as well as $n(n - 1) / 2$ -dimensional correlation factors $r_{\phi}$ (followed by a tanh projection into the valid $[-1,1]$ range), and building the lower triangular covariance matrix $L_{\phi}$ . In this way, the full-covariance matrix $\Sigma_{\phi} = L_{\phi}L_{\phi}^{T}$ is ensured to be symmetric and positive semi-definite.
440
+
441
+ The results of the full-covariance models are shown in the bottom half of Tab. 9. In all KL divergence instances, the performance of the models regresses significantly compared to their counterparts in Tab. 8. This indicates that, despite its theoretical potential to connect disconnected global optima of the optimization objective, a non-diagonal latent space is nevertheless difficult to train with KL divergence, regardless of the sampling method. However, the Wasserstein metric models receive a surprising performance boost. In some cases, they significantly outperform the models from Tab. 8 on Fashion-MNIST and CelebA while achieving similar results on CIFAR10, which has less structure in its input data. It is evident that the Wasserstein metric and potentially its lower posterior variance can enable a successful utilization of correlations in the posterior.
442
+
443
+ Table 9: Ablation study of the models in Tab. 8 in a full-covariance setting. See Tab. 7 for the loss function definitions.
444
+
445
+ <table><tr><td rowspan="2"></td><td colspan="3">Fashion-MNIST</td><td colspan="3">CIFAR10</td><td colspan="3">CelebA</td></tr><tr><td>Rec.</td><td>Sample</td><td>Interp.</td><td>Rec.</td><td>Sample</td><td>Interp.</td><td>Rec.</td><td>Sample</td><td>Interp.</td></tr><tr><td>VAE-full Σφ2x</td><td>79.01</td><td>83.15</td><td>91.01</td><td>123.8</td><td>132.6</td><td>130.2</td><td>99.72</td><td>100.9</td><td>99.96</td></tr><tr><td>VAE-full Σφ-GP2x</td><td>180.0</td><td>181.5</td><td>184.4</td><td>158.3</td><td>165.8</td><td>164.0</td><td>244.2</td><td>244.6</td><td>241.8</td></tr><tr><td>UT-VAE-full Σφ2x</td><td>57.93</td><td>58.87</td><td>64.86</td><td>129.6</td><td>141.2</td><td>138.2</td><td>132.1</td><td>132.4</td><td>136.0</td></tr><tr><td>UT-VAE-full Σφ-GP2x</td><td>133.6</td><td>136.7</td><td>136.9</td><td>208.9</td><td>217.7</td><td>212.2</td><td>303.5</td><td>304.5</td><td>303.3</td></tr><tr><td>VAE*-full Σφ2x</td><td>31.16</td><td>40.99</td><td>54.73</td><td>85.47</td><td>103.9</td><td>96.55</td><td>42.07</td><td>48.59</td><td>50.72</td></tr><tr><td>VAE*-full Σφ-GP2x</td><td>19.86</td><td>32.71</td><td>48.84</td><td>84.19</td><td>102.9</td><td>95.63</td><td>39.69</td><td>46.76</td><td>49.70</td></tr><tr><td>UT-VAE*-full Σφ2x</td><td>21.96</td><td>34.17</td><td>48.32</td><td>79.51</td><td>98.32</td><td>91.82</td><td>41.54</td><td>48.32</td><td>50.29</td></tr><tr><td>UT-VAE*-full Σφ-GP2x</td><td>24.37</td><td>34.43</td><td>51.58</td><td>82.15</td><td>100.9</td><td>94.65</td><td>39.48</td><td>46.60</td><td>48.97</td></tr></table>
446
+
447
+ # G. Connection to Wasserstein Autoencoders
448
+
449
+ Wasserstein-distance autoencoders (Patrini et al., 2020; Tolstikhin et al., 2018) use the Wasserstein distance $W_{p}(q_{\mathrm{agg}}(\mathbf{z}), p(\mathbf{z}))$ to regularize the aggregated posterior $q_{\mathrm{agg}}(\mathbf{z})$ toward the prior $p(\mathbf{z}) = \mathcal{N}(\mathbf{0}, \mathbf{I})$ . Instead, we use the Wasserstein distance as a simple regularization of the per-sample posterior. However, there is a simple connection of our posterior regularization to the aggregated posterior regularization. Assuming standard normal posteriors, the aggregated posterior can be represented as a mixture
450
+
451
+ $$
452
+ q _ {\mathrm {a g g}} (\mathbf {z}) = \frac {1}{N} \sum_ {n} q (\mathbf {z} | \mathbf {x} _ {n}) = \frac {1}{N} \sum_ {n} \mathcal {N} \left(\boldsymbol {\mu} _ {n}, \boldsymbol {\Sigma} _ {n}\right). \tag {26}
453
+ $$
454
+
455
+ In the one-dimensional case (generalizable to multiple dimensions) the mean and variance of the mixture are
456
+
457
+ $$
458
+ \mathcal {N} \left(\mu_ {n}, \sigma_ {n} ^ {2}\right) \stackrel {i. d.} {=} \mathcal {N} \left(\frac {1}{N} \sum_ {n} \mu_ {n}, \frac {1}{N} \sum_ {n} \left(\sigma_ {n} ^ {2} + \mu_ {n} ^ {2}\right) - \left(\frac {1}{N} \sum_ {n} \mu_ {n}\right) ^ {2}\right). \tag {27}
459
+ $$
460
+
461
+ Thus, the aggregated posterior Wasserstein metric can be represented as
462
+
463
+ $$
464
+ \begin{array}{l} W _ {2} \left(q _ {\mathrm {a g g}} (\mathbf {z}), p (\mathbf {z})\right) = \left(\frac {1}{N} \sum_ {n} \mu_ {n}\right) ^ {2} + \frac {1}{N} \sum_ {n} \left(\sigma_ {n} ^ {2} + \mu_ {n} ^ {2}\right) - \left(\frac {1}{N} \sum_ {n} \mu_ {n}\right) ^ {2} - 2 \sqrt {\frac {1}{N} \sum_ {n} \left(\sigma_ {n} ^ {2} + \mu_ {n} ^ {2}\right) - \left(\frac {1}{N} \sum_ {n} \mu_ {n}\right) ^ {2}} = \\ = \frac {1}{N} \sum_ {n} \left(\sigma_ {n} ^ {2} + \mu_ {n} ^ {2}\right) - 2 \sqrt {\frac {1}{N} \sum_ {n} \left(\sigma_ {n} ^ {2} + \mu_ {n} ^ {2}\right) - \left(\frac {1}{N} \sum_ {n} \mu_ {n}\right) ^ {2}}, \tag {28} \\ \end{array}
465
+ $$
466
+
467
+ in the case $p = 2$ and while discarding constants. Similarly, the average per-sample posterior metric is
468
+
469
+ $$
470
+ \frac {1}{N} \sum_ {n} W _ {2} \left(q _ {\mathrm {p p}} (\mathbf {z} | \mathbf {x}), p (\mathbf {z})\right) = \frac {1}{N} \sum_ {n} \left(\mu_ {n} ^ {2} + \sigma_ {n} ^ {2} - 2 \sigma_ {n}\right) = \frac {1}{N} \sum_ {n} \mu_ {n} ^ {2} + \frac {1}{N} \sum_ {n} \sigma_ {n} ^ {2} - 2 \frac {1}{N} \sum_ {n} \sigma_ {n}. \tag {29}
471
+ $$
472
+
473
+ Table 10: Comparison of the Wasserstein autoencoder that utilizes the aggregated posterior Wasserstein metric, and the VAE*, utilizing the per-sample posterior Wasserstein metric in the loss.
474
+
475
+ <table><tr><td></td><td colspan="3">Fashion-MNIST</td><td colspan="3">CIFAR10</td><td colspan="3">CelebA</td></tr><tr><td></td><td>Rec.</td><td>Sample</td><td>Interp.</td><td>Rec.</td><td>Sample</td><td>Interp.</td><td>Rec.</td><td>Sample</td><td>Interp.</td></tr><tr><td>WAE-MMD</td><td>47.58</td><td>62.44</td><td>73.94</td><td>88.31</td><td>100.35</td><td>94.78</td><td>67.54</td><td>75.92</td><td>73.21</td></tr><tr><td>VAE*1x</td><td>31.62</td><td>38.44</td><td>52.33</td><td>83.49</td><td>101.5</td><td>94.56</td><td>44.69</td><td>50.55</td><td>53.18</td></tr></table>
476
+
477
+ Comparing the aggregated posterior metric with the average per-sample posterior metric yields
478
+
479
+ $$
480
+ \frac {1}{N} \sum_ {n} \left(\sigma_ {n} ^ {2} + \mu_ {n} ^ {2}\right) - 2 \sqrt {\frac {1}{N} \sum_ {n} \left(\sigma_ {n} ^ {2} + \mu_ {n} ^ {2}\right) - \left(\frac {1}{N} \sum_ {n} \mu_ {n}\right) ^ {2}} \leq \frac {1}{N} \sum_ {n} \mu_ {n} ^ {2} + \frac {1}{N} \sum_ {n} \sigma_ {n} ^ {2} - 2 \frac {1}{N} \sum_ {n} \sigma_ {n} \tag {30}
481
+ $$
482
+
483
+ $$
484
+ - 2 \sqrt {\frac {1}{N} \sum_ {n} \left(\sigma_ {n} ^ {2} + \mu_ {n} ^ {2}\right) - \left(\frac {1}{N} \sum_ {n} \mu_ {n}\right) ^ {2}} \leq - 2 \frac {1}{N} \sum_ {n} \sigma_ {n} \tag {31}
485
+ $$
486
+
487
+ $$
488
+ \sqrt {\frac {1}{N} \sum_ {n} \left(\sigma_ {n} ^ {2} + \mu_ {n} ^ {2}\right) - \left(\frac {1}{N} \sum_ {n} \mu_ {n}\right) ^ {2}} \geq \frac {1}{N} \sum_ {n} \sigma_ {n} \tag {32}
489
+ $$
490
+
491
+ $$
492
+ \frac {1}{N} \sum_ {n} \left(\sigma_ {n} ^ {2} + \mu_ {n} ^ {2}\right) - \left(\frac {1}{N} \sum_ {n} \mu_ {n}\right) ^ {2} \geq \left(\frac {1}{N} \sum_ {n} \sigma_ {n}\right) ^ {2} \tag {33}
493
+ $$
494
+
495
+ $$
496
+ \frac {1}{N} \sum_ {n} \left(\sigma_ {n} ^ {2} + \mu_ {n} ^ {2}\right) \geq \left(\frac {1}{N} \sum_ {n} \mu_ {n}\right) ^ {2} + \left(\frac {1}{N} \sum_ {n} \sigma_ {n}\right) ^ {2}. \tag {34}
497
+ $$
498
+
499
+ Eq. (34) can be regarded as two Jensen's inequalities $f(\mathbb{E}[x]) \leq \mathbb{E}[f(x)]$ , where $f(x) = x^2$ , and $\mathbb{E}[x] = \frac{1}{N} \sum_{n} x_{n}$ . Thus, the initial inequality holds. It shows that the per-sample posterior Wasserstein metric is an upper bound to the aggregated posterior Wasserstein metric, commonly used in the WAE (Tolstikhin et al., 2018). Therefore, we can guarantee that the Wasserstein distance of the aggregated posterior to the assumed standard normal prior will not be larger than the average distance of per-sample posteriors.
500
+
501
+ In addition to the theoretical argument, in Tab. 10 we offer an empirical comparison of the VAE* with the WAE-MMD model from (Tolstikhin et al., 2018) with aggregated posterior weight $\lambda = 10$ . We observed that the per-sample posterior regularization significantly outperforms the WAE on Fashion-MNIST and CelebA, while being on par on CIFAR10.
502
+
503
+ # H. Wasserstein Metric Aggregated Posterior Visualization
504
+
505
+ In Fig. 5 we present detailed plots on the posterior distributions of VAE and VAE* for the first 16 dimensions. The VAE clearly shows signs of posterior collapse (so-called polarized regime (Rolinek et al., 2019)); we have observed that more than half of the 128 dimensions are nearly equal to the prior. This considerably hurts the generative power of the VAE model. In contrast, the VAE* model has very low variance in all dimensions, which reflects a nearly deterministic encoder at the end of the training.
506
+
507
+ ![](images/2d8f01ed13d2ddd63adf1b7a87ec186961459dc7ab4064f77e965b7c326ed979.jpg)
508
+
509
+ ![](images/1691430b3e89d777b6761a64c5e6ee22c50bb7a62cf70a0c374b16bbf831cf13.jpg)
510
+ Figure 5: Comparison of the distribution of absolute means and variances of 1000 posterior samples for the $\mathrm{VAE}_{1\mathrm{x}}$ and the $\mathrm{VAE}^{*}_{1\mathrm{x}}$ models trained with 100 epochs on the CIFAR10 dataset. Top rows show the absolute means and the lower rows the variances of the first 16 dimensions. For the $\mathrm{VAE}^{*}_{1\mathrm{x}}$ all means differ from zero while the variances are close to zero, whereas for the $\mathrm{VAE}_{1\mathrm{x}}$ , 10 of 16 dimensions are effectively deactivated.
511
+
512
+ # I. Qualitative Results on Fashion-MNIST and CIFAR10
513
+
514
+ Qualitative results on Fashion-MNIST and CIFAR10 are provided in Fig. 6 and Fig. 7. The same setup as in Fig. 3 is employed. It can be seen that the CIFAR10 images appear considerably richer and sharper, consistent with the results in Tab. 2 and Tab. 6.
515
+
516
+ ![](images/a9bd4bbb8919cb52deef0869924babbc615c0d48ea010cad7232ea7aa847b570.jpg)
517
+ Figure 6: Qualitative results on the CIFAR10 dataset.
518
+
519
+ ![](images/417107875711666c6b29f371e4cae0e3acf274a2548c9add31fe1e86e8eb19c5.jpg)
520
+ Figure 7: Qualitative results on the Fashion-MNIST dataset.
unscentedautoencoder/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34180d9ebccfbb73789e9f7366d9349f6073d4de307230dbfd349b40b4a8ecba
3
+ size 1428297
unscentedautoencoder/layout.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8cfc6b95048c636ebadaa4c7b925de15359714393164ad38226e656a51abe682
3
+ size 658751
unsupervisedoutofdistributiondetectionwithdiffusioninpainting/baa6865d-100e-4e48-bb92-b5c7e697f9db_content_list.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4b73633192f9df6463913480c14bee7d4074e6a9ad49cf7d5693629861b55177
3
+ size 77978
unsupervisedoutofdistributiondetectionwithdiffusioninpainting/baa6865d-100e-4e48-bb92-b5c7e697f9db_model.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:795a59cf50332aa9774dad976e0cbfc56d7c17184e5ff80bb742e70838074535
3
+ size 100396