Is Attention Better Than Matrix Decomposition?

Zhengyang Geng, Meng-Hao Guo, Hongxu Chen, Xia Li, Ke Wei, Zhouchen Lin

Introduction

Since self-attention and transformer (Vaswani et al., 2017) showed significant advantages over recurrent neural networks and convolutional neural networks in capturing long-distance dependencies, attention has been widely adopted by computer vision (Wang et al., 2018; Zhang et al., 2019a) and natural language processing (Devlin et al., 2019) for global information mining. However, is hand-crafted attention irreplaceable when modeling the global context?

This paper focuses on a new approach to design global context modules. The key idea is, if we formulate the inductive bias like the global context into an objective function, the optimization algorithm to minimize the objective function can construct a computational graph, i.e., the architecture we need in the networks. We particularize this idea by developing a counterpart for the most representative global context module, self-attention. Considering extracting global information in the networks as finding a dictionary and the corresponding codes to capture the inherent correlation, we model the context discovery as low-rank recovery of the input tensor and solve it via matrix decomposition. This paper then proposes a global correlation block, Hamburger, by employing matrix decomposition to factorize the learned representation into sub-matrices so as to recover the clean low-rank signal subspace. The iterative optimization algorithm to solve matrix decomposition defines the central computational graph, i.e., Hamburger’s architecture.

Our work takes advantage of the matrix decomposition models as the foundation of Hamburger, including Vector Quantization (VQ) (Gray & Neuhoff, 1998), Concept Decomposition (CD) (Dhillon & Modha, 2001), and Non-negative Matrix Factorization (NMF) (Lee & Seung, 1999). Additionally, instead of directly applying backpropagation Through Time (BPTT) algorithm (Werbos et al., 1990) to differentiate the iterative optimization, we adopt a truncated BPTT algorithm, i.e., one-step gradient, to back-propagate the gradient effectively. We illustrate the advantages of Hamburger in the fundamental vision tasks where global context has been proven crucial, including semantic segmentation and image generation. The experiments prove that optimization-designed Hamburger can perform competitively with state-of-the-art attention models when avoiding the unstable gradient back-propagated through the iterative computational graph of MD. Hamburger sets new state-of-the-art records on the PASCAL VOC dataset (Everingham et al., 2010) and PASCAL Context dataset (Mottaghi et al., 2014) for semantic segmentation and surpasses existing attention modules for GANs in the large-scale image generation on ImageNet (Deng et al., 2009).

The contributions of this paper are listed as follows:

We show a white-box approach to design global information blocks, i.e., by turning the optimization algorithm that minimizes an objective function, in which modeling the global correlation is formulated as a low-rank recovery problem, into the architecture.

We propose Hamburger, a light yet powerful global context module with O(n)\mathcal{O}(n) complexity, surpassing various attention modules on semantic segmentation and image generation.

We figure out that the main obstacle of applying MD in the networks is the unstable backward gradient through its iterative optimization algorithm. As a practical solution, the proposed one-step gradient facilitates the training of Hamburger with MDs.

Methodology

Since matrix decomposition is pivotal to the proposed Hamburger, we first review the idea of matrix decomposition. A common view is that matrix decomposition factorizes the observed matrix into a product of several sub-matrices, e.g., Singular Value Decomposition. However, a more illuminating perspective is that, by assuming the generation process, matrix decomposition acts as the inverse of the generation, disassembling the atoms that make up the complex data. From the reconstruction of the original matrices, matrix decomposition recovers the latent structure of observed data.

Different MDs can be derived by assuming structures to matrices D\bm{D}, C\bm{C}, and E\bm{E} (Kolda & Bader, 2009; Udell et al., 2016). MD is usually formulated as an objective with various constraints and then solved by optimization algorithms, with classic applications to image denoising (Wright et al., 2009; Lu et al., 2014), inpainting (Mairal et al., 2010), and feature extraction (Zhang et al., 2012).

2 Proposed Method

We focus on building global context modules for the networks without painstaking hand-crafted design. Before starting our discussion, we review the representative hand-designed context block self-attention pithily.

The attention mechanism aims at finding a group of concepts for further conscious reasoning from massive unconscious context (Xu et al., 2015; Bengio, 2017; Goyal et al., 2019). As a representative, self-attention (Vaswani et al., 2017) is proposed for learning long-range dependencies in machine translation,

Though self-attention and its variants achieved great success, researchers are confronted with (1) developing new global context modules based on self-attention, typically via hand-crafted engineering, and (2) explaining why current attention models work. This paper bypasses both issues and finds a method to easily design global context modules via a well-defined white-box toolkit. We try to formulate the human inductive bias, like the global context, as an objective function and use the optimization algorithm to solve such a problem to design the module’s architecture. The optimization algorithm creates a computational graph, takes some input, and finally outputs the solution. We apply the computational graph of optimization algorithms for the central part of our context module.

where L\mathcal{L} is the reconstruction loss, R1\mathcal{R}_{1} and R2\mathcal{R}_{2} are regularization terms for the dictionary D\bm{D} and the codes C\bm{C}. Denote the optimization algorithm to minimize Eq. 4 as M\mathcal{M}. M\mathcal{M} is the core architecture we deploy in our global context module. To help readers further understand this modeling, We also provide a more intuitive illustration in Appendix G.

In the later sections, we introduce our global context block, Hamburger, and then discuss detailed MD models and optimization algorithms for M\mathcal{M}. Finally, we handle the gradient issue for backpropagation through matrix decomposition.

where M\mathcal{M} is matrix decomposition to recover the clear latent structure, functioning as a global nonlinearity. Detailed architectures of M\mathcal{M}, i.e., optimization algorithms to factorize X\bm{X}, are discussed in Sec. 2.2.2. Fig. 1 describes the architecture of Hamburger, where it collaborates with the networks via Batch Normalization (BN) (Ioffe & Szegedy, 2015), a skip connection, and finally outputs Y\bm{Y},

2.2 Hams

This section describes the structure of “ham”, i.e., M\mathcal{M} in Eq. 5. As discussed in the previous section, by formulating the global information discovery as an optimization problem of MD, algorithms to solve MD naturally compose M\mathcal{M}. M\mathcal{M} takes the output of “lower bread” as its input and computes a low-rank reconstruction as its output, denoted as X\bm{X} and Xˉ\bar{\bm{X}}, respectively.

We investigate two MD models for M\mathcal{M}, Vector Quantization (VQ), and Non-negative Matrix Factorization (NMF) to solve D\bm{D} and C\bm{C} and reconstruct Xˉ\bar{\bm{X}}, while leaving Concept Decomposition (CD) to Appendix B. The selected MD models are introduced briefly because we endeavor to illustrate the importance of the low-rank inductive bias and the optimization-driven designing method for global context modules rather than any specific MD models. It is preferred to abstract the MD part as a whole, i.e., M\mathcal{M} in the context of this paper, and focus on how Hamburger can show the superiority in its entirety.

Vector Quantization (VQ) (Gray & Neuhoff, 1998), a classic data compression algorithm, can be formulated as an optimization problem in term of matrix decomposition:

If we impose non-negative constraints on the dictionary D\bm{D} and the codes C\bm{C}, it leads to Non-negative Matrix Factorization (NMF) (Lee & Seung, 1999):

To satisfy the non-negative constraints, we add a ReLU non-linearity before putting X\bm{X} into NMF. We apply the Multiplicative Update (MU) rules (Lee & Seung, 2001) in Alg. 2 to solve NMF, which guarantees the convergence.

As white-box global context modules, VQ, CD, and NMF are straightforward and light, showing remarkable efficiency. They are formulated into optimization algorithms that mainly consist of matrix multiplications with the complexity O(ndr)\mathcal{O}(ndr), much cheaper than complexity O(n2d)\mathcal{O}(n^{2}d) in self-attention as r≪nr\ll n. All three MDs are memory-friendly since they avoid generating a large n×nn\times n matrix as an intermediate variable, like the product of Q\bm{Q} and K\bm{K} of self-attention in Eq. 3. In the later section, our experiments prove MDs are at least on par with self-attention, though the architectures of M\mathcal{M} are created by optimization and look different from classic dot product self-attention.

3 One-Step Gradient

Since M\mathcal{M} involves an optimization algorithm as its computational graph, a crux to fuse it into the networks is how the iterative algorithm back-propagates gradient. The RNN-like behavior of optimization suggests backpropagation Through Time (BPTT) algorithm (Werbos et al., 1990) as the standard choice to differentiate the iterative process. We first review the BPTT algorithm below. However, in practice, the unstable gradient from BPTT does harm Hamburger’s performances. Hence we build an abstract model to analyze the drawbacks of BPTT and try to find a pragmatic solution while considering MD’s nature as an optimization algorithm.

As shown in Fig. 2, x\mathbf{x}, y\mathbf{y} and hi\mathbf{h}^{i} denote input, output and intermediate result at time step ii, respectively, while F\mathcal{F} and G\mathcal{G} are operators. At each time step, the model receives the same input x\mathbf{x} processed by the underlying networks.

ww The intermediate results hi\mathbf{h}^{i} are all discarded. Only the output of the last step ht\mathbf{h}^{t}, is passed through G\mathcal{G} for output y\mathbf{y},

In the BPPT algorithm, the Jacobian matrix from output y\mathbf{y} to input x\mathbf{x} is given, according to the Chain rule:

A thought experiment is to consider t→∞t\to\infty, leading to a fully converged result h∗\mathbf{h}^{*} and infinite terms in Eq. 12. We suppose that both F\mathcal{F} and G\mathcal{G} are Lipschitz with constants LhL_{h} w.r.t. h\mathbf{h}, LxL_{x} w.r.t. x\mathbf{x}, and LGL_{\mathcal{G}}, and Lh<1L_{h}<1. Note that these assumptions apply to a large number of optimization or numerical methods. Then we have:

{hi}t\{\mathbf{h}^{i}\}_{t} has linear convergence.

lim⁡t→∞∂y∂x=∂y∂h∗(I−∂F∂h∗)−1∂F∂x\underset{t\to\infty}{\lim}\frac{\partial\mathbf{y}}{\partial\mathbf{x}}=\frac{\partial\mathbf{y}}{\partial\mathbf{h}^{*}}(\bm{I}-\frac{\partial\mathcal{F}}{\partial\mathbf{h}^{*}})^{-1}\frac{\partial\mathcal{F}}{\partial\mathbf{x}}.

lim⁡t→∞∥∂y∂h0∥=0\underset{t\to\infty}{\lim}\|\frac{\partial\mathbf{y}}{\partial\mathbf{h}^{0}}\|=0, lim⁡t→∞∥∂y∂x∥≤LGLx1−Lh\underset{t\to\infty}{\lim}\|\frac{\partial\mathbf{y}}{\partial\mathbf{x}}\|\leq\frac{L_{\mathcal{G}}L_{x}}{1-L_{h}}.

Experiments

In this section we present experimental results demonstrating the techniques described above. Two vision tasks that benefit a lot from global information and attention mechanism attract us, including semantic segmentation (over 50 papers using attention) and deep generative models like GANs (most state-of-the-art GANs adopt self-attention since SAGAN (Zhang et al., 2019a)). Both tasks are highly competitive and thus enough for comparing Hamburger with self-attention. Ablation studies show the importance of MD in Hamburger as well as the necessity of the one-step gradient. We emphasize the superiority of Hamburger on modeling global context over self-attention regarding both performance and computational cost.

We ablate each part of the Hamburger. Removing MD (ham) causes the most severe decay in performance, attesting to the importance of MD. Even if only the parameter-free MD is added (only ham), the performance can visibly improve. Parameterization also helps the Hamburger process the extracted features. Bread, especially upper bread, contributes considerable performance.

It is worth noting that there is no simple linear relation between dd and rr with performances measured by mIoU, though d=8rd=8r is a satisfactory choice. Experiments show that even r=8r=8 performs well, revealing that it can be very cheap for modeling the global context.

We test more optimization steps in the evaluation stage. In general, the same KK for training and test is recommended. K=6K=6 is enough for CD and NMF, while even K=1K=1 is acceptable for VQ. Typically 3∼\sim6 steps are enough since simple MD’s prior is still biased, and full convergence can overfit it. The few iterations are cheap and act as early stopping.

2 A Close Look at Hamburger

3 A Comparison with Attention

4 Semantic Segmentation

We benchmark Hamburger on the PASCAL VOC dataset (Everingham et al., 2010), and the PASCAL Context dataset (Mottaghi et al., 2014), against state-of-the-art attentions. We use ResNet-101 (He et al., 2016) as our backbone. The output stride of the backbone is 8. The segmentation head is the same as ablation experiments. NMF is usually better than CD and VQ in ablation studies (see Sec. 2.3). Therefore, we mainly test NMF in further experiments. We use HamNet to represent ResNet with Hamburger in the following section.

Results on the PASCAL VOC test set, and the PASCAL Context validation set, are illustrated in Sec. 3.4, and Sec. 3.4, respectively. We mark all attention-based models with ∗ in which diverse attentions compose the segmentation heads. Though semantic segmentation is a saturated task, and most contemporary published works have approximate performances, Hamburger shows considerable improvements over previous state-of-the-art attention modules.

5 Image Generation

Attention presents as the global context description block in deep generative models like GANs. Most state-of-the-art GANs for conditional image generation integrate self-attention into their architectures since SAGAN (Zhang et al., 2019a), e.g., BigGAN (Brock et al., 2018), S3GAN (Lučić et al., 2019), and LOGAN (Wu et al., 2019). It is convincing to benchmark MD-based Hamburger in the challenging conditional image generation task on ImageNet (Deng et al., 2009).

Experiments are conducted to compare Hamburger with self-attention on ImageNet 128×\times128. Self-attention is replaced by Hamburger with NMF ham in both generator and discriminator at feature resolution 32×\times32, named as HamGAN-baby. HamGAN achieves an appreciable improvement in Freˊ\acute{\text{e}}chet Inception Distance (FID) (Heusel et al., 2017) over SAGAN. Additionally, we compare Hamburger with a recently developed attention variant Your Local GAN (YLG) (Daras et al., 2020) using their codebase and the same training settings, named HamGAN-strong. HamGAN-strong offers over 5% improvement in FID while being 15% faster for the total training time and 3.6×\times faster for the module time (1.54 iters/sec of HamGAN, 1.31 iters/sec of YLG, and 1.65 iters/sec without both context modules, averaged from 1000 iterations) on the same TPUv3 training platform.

Related Work

The last five years have witnessed a roaring success of attention mechanisms (Bahdanau et al., 2015; Mnih et al., 2014; Xu et al., 2015; Luong et al., 2015) in deep learning. Roughly speaking, the attention mechanism is a term of adaptively generating the targets’ weights to be attended according to the requests. Its architectures are diverse, and the most well-known one is dot product self-attention (Vaswani et al., 2017). The attention mechanism has a wide range of applications, from a single source (Lin et al., 2017) to multi-source inputs (Luong et al., 2015; Parikh et al., 2016), from global information discovery (Wang et al., 2018; Zhang et al., 2019a) to local feature extraction (Dai et al., 2017; Parmar et al., 2019).

Previous researchers attempt to explain the effectiveness of attention mechanisms from numerous aspects. Capturing long-range dependencies (Wang et al., 2018), sequentially decomposing visual scenes (Eslami et al., 2016; Kosiorek et al., 2018), inferring relationships between the part and the whole (Sabour et al., 2017; Hinton et al., 2018), simulating interactions between objects (Greff et al., 2017; van Steenkiste et al., 2018), and learning the dynamics of environments (Goyal et al., 2019) are often considered as the underlying mechanisms of attention.

One common idea from biology is that attention simulates the emergence of concerns in many unconscious contexts (Xu et al., 2015). Some work tries to interpret the attention mechanism by visualizing or attacking attention weights (Serrano & Smith, 2019; Jain & Wallace, 2019; Wiegreffe & Pinter, 2019), while others formulate attention into non-local operation (Wang et al., 2018) or diffusion models (Tao et al., 2018; Lu et al., 2019) or build attention-like models via Expectation Maximization (Greff et al., 2017; Hinton et al., 2018; Li et al., 2019a) or Variational Inference (Eslami et al., 2016) on a mixture model. A connection between transformer and graph neural network is discussed as well (Liang et al., 2018; Zhang et al., 2019c). Overall, discussions towards attention are still far from reaching agreements or consistent conclusions.

Recent works develop efficient attention modules via low-rank approximation in both computer vision (Chen et al., 2018b; Zhu et al., 2019; Chen et al., 2019; Li et al., 2019a; Guo et al., 2021b) and natural language processing (Mehta et al., 2019; Katharopoulos et al., 2020; Wang et al., 2020; Song et al., 2020). Technically, the low-rank approximation usually targets at the correlation matrix, i.e., the product of Q\bm{Q} and K\bm{K} after the softmaxsoftmax operation, using a product of two smaller matrices to approximate the correlation matrix and applying the associative law to save the memory cost and computation, where the approximation involves kernel functions or other similarity functions. Other works (Babiloni et al., 2020; Ma et al., 2019) make efforts to formulate attention into tensor form but may generate large intermediate variables. In this paper, we do not approximate attention or make it efficient. This paper formulates modeling the global context as a low-rank recovery problem. The computation and memory efficiency is a by-product of the low-rank assumption on the clean signal subspace and optimization algorithms as architectures.

There is a long history of combining MD with deep learning. Researchers focus on reducing the parameters in the networks via factorization on the weights, including the softmax layer (Sainath et al., 2013), the convolutional layer (Zhong et al., 2019), and the embedding layer (Lan et al., 2019). Tariyal et al. (2016) attempts to construct deep dictionary learning for feature extraction and trains the model greedily. This paper tries to factorize the representations to recover a clean signal subspace as the global context and provide a new formulation for modeling the long-range dependencies via matrix decomposition.

Conclusion

This paper studies modeling long-range dependencies in the networks. We formulate learning the global context as a low-rank recovery problem. Inspired by such a low-rank formulation, we develop the Hamburger module based on well-studied matrix decomposition models. By specializing matrix decomposition’s objective function, the computational graph created by its optimization algorithm naturally defines ham, Hamburger’s core architecture. Hamburger learns interpretable global context via denoising and completing its input and rescales the spectrum’s concentration. It is startling that, when prudently coped with the backward gradient, even simple matrix decomposition proposed 20 years ago is as powerful as self-attention in challenging vision tasks semantic segmentation and image generation, as well as light, fast, and memory-efficient. We plan to extend Hamburger to natural language processing by integrating positional information and designing a decoder like Transformer, build a theoretical foundation for the one-step gradient trick or find a better method to differentiate MDs, and integrate advanced MDs in the future.

Zhouchen Lin is supported by NSF China (grant no.s 61625301 and 61731018), Major Scientific Research Project of Zhejiang Lab (grant no.s 2019KB0AC01 and 2019KB0AB02), Beijing Academy of Artificial Intelligence, and Qualcomm. We thank Google’s Tensorflow Research Cloud (TFRC) for providing us Cloud TPUs.

References

Appendix A Table of Notion

Appendix B Hams

Additionally, we introduce another type of ham adopted by Hamburger, Concept Decomposition.

We first enhance Concept Decomposition (Dhillon & Modha, 2001) to the following form:

This problem has a closed solution w.r.t. C\bm{C} under a given D\bm{D}, i.e., C=(D⊤D+βI)−1D⊤X\bm{C}=(\bm{D}^{\top}\bm{D}+\beta\bm{I})^{-1}\bm{D}^{\top}\bm{X}. Since D⊤D+βI\bm{D}^{\top}\bm{D}+\beta\bm{I} is a positive definite matrix with a regularized condition number, the inverse can be more numerically stable than the original one where a semi-positive definite matrix D⊤D\bm{D}^{\top}\bm{D} is given under β=0\beta=0. In practice, 0.01 or 0.1 makes no difference for β\beta.

The dictionary in CD is given by spherical K-means (Dhillon & Modha, 2001) with objective Q(D,X)\mathcal{Q}\left(\bm{D},\bm{X}\right), as mentioned in Eq. 14.

The same strategy as VQ is adopted to make the whole algorithm differentiable, however, in which each column of D\bm{D} is normalized to be a unit vector and thus differs from VQ.

Appendix C Proof of Propositions

We investigate an abstract RNN model inspired by numerical methods to understand the drawbacks of BPTT algorithm in differentiating the optimization algorithm of MDs, M\mathcal{M}. We show the propositions in Sec. 2.3 to illustrate the unstable gradient from M\mathcal{M} when using BPTT algorithm, considering MDs’ nature as optimization algorithms.

The iterations of F\mathcal{F} have linear convergence.

Proof. It is obvious that F\mathcal{F} is a contraction mapping w.r.t. h\mathbf{h} under arbitrary given x\mathbf{x}. We can then conclude {ht}\{\mathbf{h}^{t}\} is a Cauthy sequence and F(∗,x)\mathcal{F}(*,\mathbf{x}) admits a unique fixed point h∗\mathbf{h}^{*} due to Banach Fixed Point Theorem.

lim⁡t→∞∂y∂x=∂y∂h∗(I−∂F∂h∗)−1∂F∂x\underset{t\to\infty}{\lim}\frac{\partial\mathbf{y}}{\partial\mathbf{x}}=\frac{\partial\mathbf{y}}{\partial\mathbf{h}^{*}}(\bm{I}-\frac{\partial\mathcal{F}}{\partial\mathbf{h}^{*}})^{-1}\frac{\partial\mathcal{F}}{\partial\mathbf{x}}.

Proof. Note that F(∗,x)\mathcal{F}(*,\mathbf{x}) admits a unique fixed point h∗\mathbf{h}^{*} under arbitrary given x\mathbf{x}, i.e.,

By differentiating the above equation, we can obtain

The Jacobian matrix I−∂F∂h∗\bm{I}-\frac{\partial\mathcal{F}}{\partial\mathbf{h}^{*}} is invertible, which implies the existence of the implicit function h∗(x)\mathbf{h}^{*}(\mathbf{x}). Immediately, we have

lim⁡t→∞∥∂y∂h0∥=0\underset{t\to\infty}{\lim}\|\frac{\partial\mathbf{y}}{\partial\mathbf{h}^{0}}\|=0, lim⁡t→∞∥∂y∂x∥≤LGLx1−Lh\underset{t\to\infty}{\lim}\|\frac{\partial\mathbf{y}}{\partial\mathbf{x}}\|\leq\frac{L_{\mathcal{G}}L_{x}}{1-L_{h}}.

Appendix D Datasets

The PASCAL VOC dataset (Everingham et al., 2010) is a widely used dataset in both semantic segmentation and detection. For segmentation, it contains 10,582 images for training, 1,449 images for validation and 1,456 images for testing. PASCAL VOC dataset involves 20 foreground object classes and a background class for segmentation and detection.

The PASCAL Context dataset (Mottaghi et al., 2014) is a challenging dataset in semantic segmentation, which provides detailed labels and involves 59 foreground object classes and a background class for segmentation. It consists of 4,998 and 5,105 images in training and validation set, respectively.

The ILSVRC 2012 (ImageNet) (Deng et al., 2009) dataset contains 1.3M training samples and 50k test images, categorized into 1000 object classes. We resize images to resolution 128 ×\times 128, as done in SNGAN with projection (Miyato & Koyama, 2018) and SAGAN (Zhang et al., 2019a).

Appendix E Details of Experiments

We use dilated ResNet-50 (He et al., 2016) with the output stride 16 as the backbone. The backbone is pre-trained on ImageNet (Deng et al., 2009). We apply a poly-learning rate policy under batch size 12 and 30k iterations (about 35 epochs) for fast experiments (less than 12 hours using 1 NVIDIA TITAN Xp GPU). The initial learning rate is set to 0.009, multiplied by (1−iteritermax)0.9(1-\frac{iter}{iter_{max}})^{0.9} after each iteration, with momentum 0.9 and weight decay 0.0001. Hyperparameters of Hamburger are the same as Sec. E.3.

E.2 A Comparison with Attention Mechanism

E.3 Semantic Segmentation

In the training stage, we apply random left-right flipping, random scaling (from 0.5 to 2), and cropping to augment the training data. Images are resized to 513×\times513 for the PASCAL VOC dataset and the PASCAL Context dataset. In the test stage, the multi-scale and flipping strategy is applied as other state-of-the-art attention-based models (Fu et al., 2019; Yuan & Wang, 2018; Yuan et al., 2020).

We use mini-batch SGD with momentum 0.9 to train HamNet. Synchronized Batch Normalization is adopted in experiments on semantic segmentation. All backbones are fine-tuned from ImageNet (Deng et al., 2009) pre-training. Following previous works (Zhao et al., 2017; Chen et al., 2018a), we apply a poly-learning rate policy. The initial learning rate is multiplied by (1−iteritermax)0.9(1-\frac{iter}{iter_{max}})^{0.9}. For the PASCAL VOC dataset, learning rate, weight decay, batch size, iterations are set to 0.009, 0.0001, 16, and 60k, respectively. We fine-tune HamNet on the PASCAL VOC trainval set with the learning rate down to a tenth. The learning rate, weight decay, batch size, iterations are 0.002, 0.0001, 16, and 25k for the PASCAL-Context dataset.

E.4 Image Generation

We use the official GAN codebasehttps://github.com/tensorflow/gan from Tensorflow (Abadi et al., 2016) and TF-GAN to train HamGAN and evaluate FID.

Experiments on ImageNet are conducted using the same architecture as SAGAN (Zhang et al., 2019a), and YLG (Daras et al., 2020), including Spectral Normalization (Miyato et al., 2018) in both the generator and the discriminator, conditional Batch Normalization in the generator, and class projection in the discriminator (Miyato & Koyama, 2018). Hamburger with NMF ham is placed at feature resolution 32×\times32 in both the generator and the discriminator where self-attention can obtain the best FID according to Zhang et al. (2019a). We use d=8rd=8r for Hamburger, and dd is the same as the input channels, while the optimization steps KK are 6. Restricted to expenditures of training GANs on ImageNet, dd, rr, and KK are decided according to the ablation experiments on semantic segmentation without new ablation experiments.

For all models, we use Adam (Kingma & Ba, 2015) optimizer with TTUR (Heusel et al., 2017). HamGAN employs the same training settings as SAGAN (Miyato et al., 2018) and YLG (Daras et al., 2020), respectively.

The quality of images generated by GANs are evaluated by Freˊ\acute{\text{e}}chet Inception Distance (FID) (Heusel et al., 2017). Lower FID indicates that the model can generate higher-fidelity images. In our experiments, 50k images are sampled from the generator to compute FID. We evaluate HamGAN for 6 runs and report the best FID to approximately match the convention in the modern GAN research like Kurach et al. (2019) and CR-GAN (Zhang et al., 2020), reporting top 5%/15% results in the experiments.

Appendix F Further Results from Ablation Experiments

We test four types of initialization for the dictionary D\bm{D}, including fixed initialization, learned initialization, random initialization, and warm start with online update. Usually, random initialization is the best choice that means we can sample each entry of D\bm{D} from a given distribution like Uniform(0,1)\text{Uniform}(0,1) as the initialization of the optimization algorithm M\mathcal{M}. For NMF, after initializing D\bm{D}, we initialize C=softmax(1Tcosine(D,X))\bm{C}=softmax(\frac{1}{T}cosine(\bm{D},\bm{X})) since K-means is usually applied for initializing NMF and this initialization for C\bm{C} is equivalent to a single update in Spherical K-means. A special reminder is that it is not suitable to initialize either D\bm{D} or C\bm{C} to values too close to 0 due to the property of the MU rule. So the temperature TT is recommended to be a higher value like 1 in this initialization for C\bm{C}. Random initialization also works for C\bm{C} in NMF with scores 77.8(77.6) when sampling Cij∼Uniform(0,1)C_{ij}\sim\text{Uniform}(0,1). Note that learned initialization is always the worst one since the BPTT algorithm is employed to learn the initialization that the gradient from M\mathcal{M} may impede the training of the backbone, instead of the one-step gradient. Warm start benefits MD with unit vectors in the dictionary D\bm{D} like CD. In general, random initialization is good enough for all three selected MD models. A possible reason is that it can enforce the network to adapt to the results solved by different initializations during the training process, acting like an inner augmentation.

As we have claimed, when TT approaches 0, we can get a solution close to the original problem in both VQ and CD. In VQ and CD experiments, a relatively low temperature TT is more recommended to solve a better D\bm{D} for MD. However, it will not receive more gains but increase the variance during training if we further lower TT.

We take the iterations KK of optimization algorithms M\mathcal{M} for all three MD models, NMF, CD, and VQ, into our consideration. More iterations and even fully converged results for M\mathcal{M} are tested in the evaluation stage but worse than little optimization steps. The smaller KK, ranging from 1 to 8, can be treated as early stopping for the optimization algorithm M\mathcal{M}, obtaining satisfactory performances. For a detailed visualization, see Fig. 8, Fig. 8, Fig. 9.

Appendix G An Intuitive Illustration

In this section, we hope to give an example to help our readers develop insight into why the low-rank assumption is useful for modeling the representations’ global context.

The low-rank assumption helps because it represents the inductive bias that the low-level representations contain limited and much less high-level concepts than the scale of the representations themselves. Imagine an image in which a person walks on the road. Many hyper-pixels extracted by the backbone CNN will describe the road. Note that the road can be considered as repetitions of small road patches, which means that we can represent the road via modeling the basic road patches and repeating them. Mathematically, it is equivalent to finding a small set of bases D\bm{D} corresponding to different road patches and a coefficient matrix C\bm{C} that captures the relation between the elementary road patches and the hyper-pixels. This example illustrates that the high-level concepts, i.e., the global context, can be low-rank in the ideal situation.

The hyper-pixels describing the road patches have close semantic attributes. However, due to the vanilla CNN’s inefficiency for modeling the long-range dependencies, the learned representation contains too many local details and incorrect information, lacking global guidance. Imagine that the person in the image wears gloves. When we see the gloves patch locally, we think that this patch describes gloves. When we consider the global context, we can understand that this patch is a part of a person. The semantic information is hierarchical, depending on at which level we hope to comprehend.

This work aims at enabling the networks to understand the context globally via the low-rank recovery formulation. We thus model the incorrect information, namely the redundancies and incompleteness, as a noise matrix. To emphasize the global context, we decompose the representations into two parts, a low-rank global information matrix and a noise matrix, by employing the optimization algorithm to recover the clean signal subspace, discard the noises, and enhance the global information via the skip connection. It could be learned from the data on how much global information the networks need for a specific task.

Appendix H Miscellaneous

As a miscellaneous discussion, note that we choose these MD models combined with early stopping not because they are the best models to capture the low-rank prior, but they are simple and famous enough to validate the generality of the proposed approach in modeling the global context, i.e., various MD models can all work when dealing with the gradient carefully. Hence we choose several MD models rather than only one model. Further, it will be convincing if even the simplest MD models (regarding the proposed time and the complexity) can be powerful enough to compare with state-of-the-art attention modules for encoding the global context in the highly competitive vision tasks. So we choose VQ, CD, and NMF, three simple, lightweight MD models proposed 20 years ago and tested by time to support our claim.

A critical question is what makes an MD model perform better than others for modeling global context. From our perspective, the differences among these models in performance might depend on which objective function models the prior we want the best, e.g., recovering the latent structure of the input tensor in this paper, the quality of the solution from the corresponding optimization algorithm, and which optimization algorithm is more friendly to the backward gradient, especially ∂F∂x\frac{\partial\mathcal{F}}{\partial\mathbf{x}} for one-step gradient.

According to this paper, NMF performs better than VQ and CD in the given tasks and datasets, perhaps because NMF models the latent structure better than VQ and CD since the representations in the classic backbones are usually non-negative due to the ReLU non-linearity and NMF is considered as a more powerful MD model than VQ. VQ is known more as a data compression algorithm than its MD’s formulation. The MU rule for solving NMF is also a practice-tested algorithm in the past years.

However, there is no guarantee that NMF can always perform better than other MD models. Hamburger in the current version is more illustrative than finally practical because it endeavors to carefully and experimentally verify several hypotheses and ideas in modeling global context and develop them, including the low-rank formulation, decomposition (independent of low-rankness), optimization-driven methods as semi-implicit models, as well as the very important one-step gradient. Though Hamburger can be quite powerful in the current version, we still do not push it to the limit.

Appendix I Future Works

For modeling global context and finally learn better representations, interesting research problems naturally arise based on this paper:

∙ \bullet\> How can we determine the best low-rank structure and corresponding MD models for the arbitrarily given tasks and dataset? Can we automatically learn the best low-dimensional structure and “decomposition” as global context rather than using simple MD models manually designed for particular types of noises or structures? Is it still necessary to early stop under such circumstances?

∙  \bullet\; How can we explicitly encode positional information and locality into MD? It is worth noting that current MD models used in Hamburger do not formulate or consider neither positional information nor the locality into the objective function. Thus, there are no explicit operations in the forward solvers, i.e., architectures, to handle the input representations’ permutation, rotation, or translation. It might not be a major concern when we implicitly inject position information and locality into representations through convolutions as done in the HamNet. However, when we try to build a pure Hamburger-based model like Transformer and make efforts to learn coarse and fine-grained information together from both local and global perspectives, it is of primary concern. A special bonus from the encapsulation of MD models is that we can design the objective function such that the positional information and locality are reflected in the regularization on D\bm{D} and C\bm{C}.

∙  \bullet\; Can decomposition work independently of the low-rank assumption for modeling the context in deep learning? Because decomposition generally characterizes the structured properties of representations and low-rankness is only a subclass, it has the potential to capture more complex structures beyond the global low-rankness in context modeling according to proper premises. For example, regarding the hierarchical matrix at play in the generating process, the decomposition results can be hierarchically low-rank rather than globally, which also can be an implication of locality, as mentioned in the above item. Plus, if we have priors on multiple components in the generating process with physical senses like a sparse component S\bm{S} (Wright et al., 2009; Lin et al., 2009) for the foreground, different operators like convolution instead of matrix multiplication (Li et al., 2019b), or intrinsic geometrical properties (Belkin & Niyogi, 2003; Ng et al., 2002; Saul & Roweis, 2003), the decomposition (or splitting, deconvolution, etc.) can be more powerful (although more computationally expensive). When we change its formulation, we assign different physical senses to the variables for context modeling as well as different solvers as architectures. Decomposition is undoubtedly beneficial because it provides the flexibility to extend context modeling via better objective functions and optimization methods in a mathematically sound and easily organized way.

∙  \bullet\; Incorporate learning-based optimizers (Gregor & LeCun, 2010) into the framework of Hamburger to accelerate solving different MD models and gain better solutions for context modeling. When the bridge between classic MD models (and/or inverse problem) and attention-related context modules is set up, the applications of attention modules can also become a standard benchmark for learned optimizers, which shares a similar motivation with the recent work (Chen et al., 2021a) for testing learning-based optimizers.

∙  \bullet\; It is also intriguing to understand Hamburger from nested optimization/multi-level optimization’s view (Amos & Kolter, 2017; Shaban et al., 2019; Lorraine et al., 2020; Liu et al., 2021a) as the unrolling (Monga et al., 2021) of MD’s optimization leads to an approximate solution to a lower-level objective function nested and evaluated by the upper-level training objective. Note that nested optimization plays an architectural element in this work and is subtly different from the formulation of meta learning (Rajeswaran et al., 2019).

∙  \bullet\; Build transformer-alike models via advanced structured decomposition for large-scale representation learning on high resolution images (Dosovitskiy et al., 2020; Liu et al., 2021b), point cloud (Guo et al., 2021a; Zhao et al., 2020), or video processing (Neimark et al., 2021; Arnab et al., 2021).

∙  \bullet\; The structures like symmetries define the types of data. For example, we may expect the learned system for vision data can meet the translation equivariance and the rotation equivariance, which means the effect of given operations on data would be predictable from the final representation. A rising trend in machine learning tries to incorporate equivariance either on linear layers (Cohen & Welling, 2016; Kondor & Trivedi, 2018; Bekkers, 2019; Shen et al., 2020) or on non-linear layers (Romero et al., 2020; He et al., 2021b; Romero & Cordonnier, 2021; He et al., 2021a), which can improve the performance of the network and speed up training convergence (Weiler & Cesa, 2019). We expect equivariance to benefit structured decomposition and implicit models like Hamburger for faster convergence in the inner loop.

∙  \bullet\; Diagnose the training of Hamburger, especially understanding under which circumstances the approximate One-Step Gradient is on par with the exact gradient or even better and vice versa. Given the differences of loss landscapes (jointly determined by the network architectures and intrinsic attributes of datasets) and the abilities of different optimizers to escape sharp minima, extra noise can be a bonus in some cases and poison in others. The devil is indeed in the gradient.

∙  \bullet\; How well are the global context modules trained, especially attention? Although it seems that Hamburger and self-attention have different mechanisms, MoCo v3 (Chen et al., 2021c) reports similar observations in the training dynamics, e.g., secretly generalization deterioration, revealing the gradient issue in training Transformer. A possible direction is to formulate attention into an optimization problem (Ramsauer et al., 2020) or implicit model (Bai et al., 2019) and consider the gradient properties from the aspect of differentiation through dynamics. Deeper analysis may focus on the connections between structured properties of the Jacobian matrix and Hessian matrix and the generalization as recent work (Chen et al., 2021b), especially the condition number and its implied loss landscape.

∙  \bullet\; If we have the available modeling for global context, how can we improve representations based on the global context? A slightly vague term in deep learning is fusion, as the skip connection in Hamburger. There could be clearer mathematical modeling and analysis for the fusion from the global context. Because modeling global context is not final and the ultimate goal is to learn better representations, if we can figure out how the global context takes effect in the learning phenomenon and interacts with representations, like playing as a spectral function to rescale (both improve or reduce) the concentration of spectrum as hypothesized in this paper, it is possible that generally powerful spectral function can serve as the context module, including but surely not limited to matrix decomposition.

∙  \bullet\; Can we build abstraction for the “context operator” or “attention” by characterizing the general properties on M\mathcal{M}? The research community has witnessed a booming number in attention-related methods. Although differences in the formulation and implementation among proposed operators indeed exist, they may have common features, e.g., smoothing the local or global representations or rescaling the concentration of spectrum. Mathematically, defining a category to depict the minimal properties for the context operators is possible. We may expect that any instantiation of the class can properly work in practice. Hence we can analyze the category and build theory for it instead of analyzing any specific operator, while the latter is not universal and can be out of date when new instantiation is proposed.

∙  \bullet\; How can we balance the smoothing effect introduced by the context module? Commonly, context modules offer a smoothing effect on the representations via spectral functions, low-rankness, sparsity, etc. Recent work (Dong et al., 2021) reveals the rank collapse from pure attention, which is congruent with recurrently applying low-rank models without skip connection. (It is interesting and implies that attention models may have subtle links to MD models from the theoretical perspective.) Nevertheless, given the empirical results that the smoothing effect helps model the context in the learning problem, it remains unknown how we can mathematically quantify and characterize the smoothing effect and understand the extent it should be to avoid over smoothing or rank collapse via practical solutions, as patch diversity (Gong et al., 2021) has also demonstrated its utility in training vision transformers. Abstraction (i.e., smoothing) for perception tasks like classification and segmentation is beneficial and easy to understand intuitively because not all details are equally important, as one of the motivations of attention methods as well as Hamburger. However, if the network maps all the patches (or data points) equally to the same representation, i.e., over smoothing, it is hard to train (Mellor et al., 2021). The trade-off might inspire deep insights, as architecture design for more powerful forward inference meets the dilemma of optimization under its implication on the loss landscape.