Skip to content
ImagineWorld

Geometric Deep Learning Models

node_idnode-book_geometric-deep-learning-grids-groups-geodesics-and-gauges_chapter-05-geometric-deep-learning-models
node_typechapter-node
schema_profileworld.chapter_node.v1
statusactive
entropyhigh
manifoldworld
domainimagineworld.net
authorityinforms
layercorpus
chapter_num5
chapter_titleGeometric Deep Learning Models
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph

Chapter 5 — Geometric Deep Learning Models

Section titled “Chapter 5 — Geometric Deep Learning Models”

Re-transcribed on 2026-10-09 from the authors’ LaTeX source (arXiv 2104.13478v2). Margin notes are shown as quotations after the paragraph they annotate; figures are the scan crops already in the corpus where one exists.

Having thoroughly studied various instantiations of our Geometric Deep Learning blueprint (for different choices of domain, symmetry group, and notions of locality), we are ready to discuss how enforcing these prescriptions can yield some of the most popular deep learning architectures.

Our exposition, once again, will not be in strict order of generality. We initially cover three architectures for which the implementation follows nearly-directly from our preceding discussion: convolutional neural networks (CNNs), group-equivariant CNNs, and graph neural networks (GNNs).

We will then take a closer look into variants of GNNs for cases where a graph structure is not known upfront (i.e. unordered sets), and through our discussion we will describe the popular Deep Sets and Transformer architectures as instances of GNNs.

Following our discussion on geometric graphs and meshes, we first describe equivariant message passing networks, which introduce explicit geometric symmetries into GNN computations. Then, we show ways in which our theory of geodesics and gauge symmetries can be materialised within deep learning, recovering a family of intrinsic mesh CNNs (including Geodesic CNNs, MoNet and gauge-equivariant mesh CNNs).

Lastly, we look back on the grid domain from a temporal angle. This discussion will lead us to recurrent neural networks (RNNs). We will demonstrate a manner in which RNNs are translation equivariant over temporal grids, but also study their stability to time warping transformations. This property is highly desirable for properly handling long-range dependencies, and enforcing class invariance to such transformations yields exactly the class of gated RNNs (including popular RNN models such as the LSTM or GRU).

While we hope the above canvasses most of the key deep learning architectures in use at the time of writing, we are well aware that novel neural network instances are proposed daily. Accordingly, rather than aiming to cover every possible architecture, we hope that the following sections are illustrative enough, to the point that the reader is able to easily categorise any future Geometric Deep Learning developments using the lens of invariances and symmetries.

Convolutional Neural Networks are perhaps the earliest and most well known example of deep learning architectures following the blueprint of Geometric Deep Learning outlined in Section 3.5. In Section 4.2 we have fully characterised the class of linear and local translation equivariant operators, given by convolutions C(θ)x=x⋆θ{\bf C(\boldsymbol{\theta})}{\bf x} = {\bf x} \star \boldsymbol{\theta} with a localised filter θ\boldsymbol{\theta}. Let us first focus on scalar-valued (‘single-channel’ or ‘grayscale’) discretised images, where the domain is the grid Ω=[H]×[W]\Omega = [H] \times [W] with u=(u1,u2)\mathbf{u} = (u_1, u_2) and x∈X(Ω,R){\bf x} \in {\mathcal{X}}(\Omega, \mathbb{R}).

Recall, C(θ){\bf C}(\boldsymbol{\theta}) is a circulant matrix with parameters θ\boldsymbol{\theta}.

Any convolution with a compactly supported filter of size Hf×WfH^f \times W^f can be written as a linear combination of generators θ1,1,…,θHf,Wf\boldsymbol{\theta}_{1,1}, \dots, \boldsymbol{\theta}_{{H^f,W^f}}, given for example by the unit peaks θvw(u1,u2)=δ(u1−v,u2−w)\boldsymbol{\theta}_{vw}(u_1, u_2) = \delta(u_1 - v, u_2 - w). Any local linear equivariant map is thus expressible as

Note that we usually imagine x\mathbf{x} and θvw\boldsymbol{\theta}_{vw} as 2D matrices, but in this equation, both x\mathbf{x} and θvw\boldsymbol{\theta}_{vw} have their two coordinate dimensions flattened into one—making x\mathbf{x} a vector, and C(θvw)\mathbf{C}(\boldsymbol{\theta}_{vw}) a matrix.

F(x)=∑v=1Hf∑w=1WfαvwC(θvw)x ,(26)\mathbf{F}(\mathbf{x}) = \sum_{v=1}^{H^f}\sum_{w=1}^{W^f} \alpha_{vw} \mathbf{C}(\boldsymbol{\theta}_{vw})\mathbf{x}~, \tag{26}

which, in coordinates, corresponds to the familiar 2D convolution (see Figure 14 for an overview):

gdl-fig-14-convolution-example.png

Figure 14: The process of convolving an image x\mathbf{x} with a filter C(θ)\mathbf{C}(\boldsymbol{\theta}). The filter parameters θ\boldsymbol{\theta} can be expressed as a linear combination of generators θvw\boldsymbol{\theta}_{vw}.

F(x)uv=∑a=1Hf∑b=1Wfαabxu+a,v+b .(27)\mathbf{F}(\mathbf{x})_{uv}= \sum_{a=1}^{H^f}\sum_{b=1}^{W^f} {\alpha}_{ab} x_{u+a, v+b}~. \tag{27}

Other choices of the basis θvw\boldsymbol{\theta}_{vw} are also possible and will yield equivalent operations (for potentially different choices of αvw\alpha_{vw}). A popular example are directional derivatives: θvw(u1,u2)=δ(u1,u2)−δ(u1−v,u2−w),(v,w)≠(0,0)\boldsymbol{\theta}_{vw}(u_1,u_2) = \delta(u_1, u_2) - \delta(u_1-v,u_2-w), (v,w) \neq (0,0) taken together with the local average θ0(u1,u2)=1HfWf\boldsymbol{\theta}_{0}(u_1,u_2) = \frac{1}{H_fW_f}. In fact, directional derivatives can be considered a grid-specific analogue of diffusion processes on graphs, which we recover if we assume each pixel to be a node connected to its immediate neighbouring pixels in the grid.

When the scalar input channel is replaced by multiple channels (e.g., RGB colours, or more generally an arbitrary number of feature maps), the convolutional filter becomes a convolutional tensor expressing arbitrary linear combinations of input features into output feature maps. In coordinates, this can be expressed as

F(x)uvj=∑a=1Hf∑b=1Wf∑c=1Mαjabcxu+a,v+b,c , j∈[N] ,(28)\mathbf{F}(\mathbf{x})_{uvj}= \sum_{a=1}^{H^f}\sum_{b=1}^{W^f}\sum_{c=1}^M {\alpha}_{jabc} x_{u+a, v+b, c}~,~ j\in[N]~, \tag{28}

where MM and NN are respectively the number of input and output channels. This basic operation encompasses a broad class of neural network architectures, which, as we will show in the next section, have had a profound impact across many areas of computer vision, signal processing, and beyond. Here, rather than dissecting the myriad of possible architectural variants of CNNs, we prefer to focus on some of the essential innovations that enabled their widespread use.

Efficient multiscale computation. As discussed in the GDL template for general symmetries, extracting translation invariant features out of the convolutional operator F\mathbf{F} requires a non-linear step. Convolutional features are processed through a non-linear activation function σ\sigma, acting element-wise on the input—i.e., σ:X(Ω)→X(Ω)\sigma: {\mathcal{X}}(\Omega) \to {\mathcal{X}}(\Omega), as σ(x)(u)=σ(x(u))\sigma(\mathbf{x})(u) = \sigma(\mathbf{x}(u)). Perhaps the most popular example at the time of writing is the Rectified Linear Unit (ReLU): σ(x)=max⁡(x,0)\sigma(x) = \max(x, 0). This non-linearity effectively rectifies the signals, pushing their energy towards lower frequencies, and enabling the computation of high-order interactions across scales by iterating the construction.

(Figure not in the corpus: relu.pdf.) \ ReLU, often considered a ‘modern’ architectural choice, was already used in the Neocognitron (Fukushima and Miyake, 1982). Rectification is equivalent to the principle of demodulation, which is fundamental in electrical engineering as the basis for many transmission protocols, such as FM radio; and also has a prominent role in models for neuronal activity.

Already in the early works of Fukushima and Miyake (1982) and LeCun et al. (1998), CNNs and similar architectures had a multiscale structure, where after each convolutional layer (30) one performs a grid coarsening P:X(Ω)→X(Ω′)\mathbf{P} : {\mathcal{X}}(\Omega) \to {\mathcal{X}}(\Omega'), where the grid Ω′\Omega' has coarser resolution than Ω\Omega. This enables multiscale filters with effectively increasing receptive field, yet retaining a constant number of parameters per scale. Several signal coarsening strategies P\mathbf{P} (referred to as pooling) may be used, the most common are applying a low-pass anti-aliasing filter (e.g. local average) followed by grid downsampling, or non-linear max-pooling.

In summary, a ‘vanilla’ CNN layer can be expressed as the composition of the basic objects already introduced in our Geometric Deep Learning blueprint:

h=P(σ(F(x))) ,(29)\mathbf{h} = \mathbf{P}(\sigma(\mathbf{F}( \mathbf{x})))~, \tag{29}

i.e. an equivariant linear layer F\mathbf{F}, a coarsening operation P\mathbf{P}, and a non-linearity σ\sigma. It is also possible to perform translation invariant global pooling operations within CNNs. Intuitively, this involves each pixel—which, after several convolutions, summarises a patch centered around it—proposing the final representation of the image, with the ultimate choice being guided by a form of aggregation of these proposals. A popular choice here is the average function, as its outputs will retain similar magnitudes irrespective of the image size (Springenberg et al., 2014).

CNNs which only consist of the operations mentioned in this paragraph are often dubbed “all-convolutional”. In contrast, many CNNs flatten the image across the spatial axes and pass them to an MLP classifier, once sufficient equivariant and coarsening layers have been applied. This loses translation invariance.

Prominent examples following this CNN blueprint (some of which we will discuss next) are displayed in Figure 15.

gdl-fig-15-cnn-architectures.png

Figure 15: Prominent examples of CNN architectures. Top-to-bottom: LeNet (LeCun et al., 1998), AlexNet (Krizhevsky et al., 2012), ResNet (He et al., 2016) and U-Net (Ronneberger et al., 2015). Drawn using the PlotNeuralNet package (Iqbal, 2018).

Deep and Residual Networks. A CNN architecture, in its simplest form, is therefore specified by hyperparameters (Hkf,Wkf,Nk,pk)k≤K(H^f_k, W^f_k, N_k, p_k )_{k \leq K}, with Mk+1=NkM_{k+1} = N_k and pk=0,1p_k=0,1 indicating whether grid coarsening is performed or not. While all these hyperparameters are important in practice, a particularly important question is to understand the role of depth KK in CNN architectures, and what are the fundamental tradeoffs involved in choosing such a key hyperparameter, especially in relation to the filter sizes (Hkf,WkfH_k^f, W_k^f).

While a rigorous answer to this question is still elusive, mounting empirical evidence collected throughout the recent years suggests a favourable tradeoff towards deeper (large KK) yet thinner (small (Hkf,Wkf)(H^f_k, W^f_k)) models. In this context, a crucial insight by He et al. (2016) was to reparametrise each convolutional layer to model a perturbation of the previous features, rather than a generic non-linear transformation:

Historically, ResNet models are predated by highway networks (Srivastava et al., 2015), which allow for more general gating mechanisms to control the residual information flow.

h=P(x+σ(F(x))) .(30)\mathbf{h} = \mathbf{P}\left(\mathbf{x} + \sigma(\mathbf{F}(\mathbf{x})) \right)~. \tag{30}

The resulting residual networks provide several key advantages over the previous formulation. In essence, the residual parametrisation is consistent with the view that the deep network is a discretisation of an underlying continuous dynamical system, modelled as an ordinary differential equation (ODE). Crucially, learning a dynamical system by modeling its velocity turns out to be much easier than learning its position directly. In our learning setup, this translates into an optimisation landscape with more favorable geometry, leading to the ability to train much deeper architectures than was possible before. As will be discussed in future work, learning using deep neural networks defines a non-convex optimisation problem, which can be efficiently solved using gradient-descent methods under certain simplifying regimes. The key advantage of the ResNet parametrisation has been rigorously analysed in simple scenarios (Hardt and Ma, 2016), and remains an active area of theoretical investigation. Finally, Neural ODEs (Chen et al., 2018) are a recent popular architecture that pushes the analogy with ODEs even further, by learning the parameters of the ODE x˙=σ(F(x))\dot{\mathbf{x}} = \sigma( \mathbf{F}(\mathbf{x})) directly and relying on standard numerical integration.

In this case, the ResNet is performing a Forward Euler discretisation of an ODE: x˙=σ(F(x))\dot{\mathbf{x}} = \sigma( \mathbf{F}(\mathbf{x}))

Normalisation. Another important algorithmic innovation that boosted the empirical performance of CNNs significantly is the notion of normalisation. In early models of neural activity, it was hypothesised that neurons perform some form of local ‘gain control’, where the layer coefficients xk\mathbf{x}_{k} are replaced by x~k=σk−1⊙(xk−μk)\mathbf{\tilde{x}}_{k} = \sigma_k^{-1} \odot (\mathbf{x}_{k} - \mu_k). Here, μk\mu_k and σk\sigma_k encode the first and second-order moment information of xk\mathbf{x}_k, respectively. Further, they can be either computed globally or locally.

In the context of Deep Learning, this principle was widely adopted through the batch normalisation layer (Ioffe and Szegedy, 2015), followed by several variants (Ba et al., 2016; Salimans and Kingma, 2016; Ulyanov et al., 2016; Cooijmans et al., 2016; Wu and He, 2018). Despite some attempts to rigorously explain the benefits of normalisation in terms of better conditioned optimisation landscapes (Santurkar et al., 2018), a general theory that can provide guiding principles is still missing at the time of writing.

We note that normalising activations of neural networks has seen attention even before the advent of batch normalisation. See, e.g., Lyu and Simoncelli (2008).

Data augmentation. While CNNs encode the geometric priors associated with translation invariance and scale separation, they do not explicitly account for other known transformations that preserve semantic information, e.g lightning or color changes, or small rotations and dilations. A pragmatic approach to incorporate these priors with minimal architectural changes is to perform data augmentation, where one manually performs said transformations to the input images and adds them into the training set.

Data augmentation has been empirically successful and is widely used—not only to train state-of-the-art vision architectures, but also to prop up several developments in self-supervised and causal representation learning (Chen et al., 2020; Grill et al., 2020; Mitrovic et al., 2020). However, it is provably sub-optimal in terms of sample complexity (Mei et al., 2021); a more efficient strategy considers instead architectures with richer invariance groups—as we discuss next.

As discussed in Section 4.3, we can generalise the convolution operation from signals on a Euclidean space to signals on any homogeneous space Ω\Omega acted upon by a group G{\mathfrak{G}}. By analogy to the Euclidean convolution where a translated filter is matched with the signal, the idea of group convolution is to move the filter around the domain using the group action, e.g. by rotating and translating. By virtue of the transitivity of the group action, we can move the filter to any position on Ω\Omega. In this section, we will discuss several concrete examples of the general idea of group convolution, including implementation aspects and architectural choices.

Recall that a homogeneous space is a set Ω\Omega equipped with a transitive group action, meaning that for any u,v∈Ωu,v \in \Omega there exists g∈G{\mathfrak{g}} \in {\mathfrak{G}} such that g.u=v{\mathfrak{g}}. u = v.

Discrete group convolution.

We begin by considering the case where the domain Ω\Omega as well as the group G{\mathfrak{G}} are discrete. As our first example, we consider medical volumetric images represented as signals of on 3D grids with discrete translation and rotation symmetries. The domain is the 3D cubical grid Ω=Z3\Omega = \mathbb{Z}^3 and the images (e.g. MRI or CT 3D scans) are modelled as functions x:Z3→Rx : \mathbb{Z}^3 \rightarrow \mathbb{R}, i.e. x∈X(Ω)x \in \mathcal{X}(\Omega). Although in practice such images have support on a finite cuboid [W]×[H]×[D]⊂Z3[W] \times [H] \times [D] \subset \mathbb{Z}^3, we instead prefer to view them as functions on Z3\mathbb{Z}^3 with appropriate zero padding. As our symmetry, we consider the group G=Z3⋊Oh{\mathfrak{G}} = \mathbb{Z}^3 \rtimes O_h of distance- and orientation-preserving transformations on Z3\mathbb{Z}^3. This group consists of translations (Z3\mathbb{Z}^3) and the discrete rotations OhO_h generated by 9090 degree rotations about the three axes (see Figure 16).

gdl-fig-16-rotated-filters-oh.png

Figure 16: A 3×33 \times 3 filter, rotated by all 2424 elements of the discrete rotation group OhO_h, generated by 9090-degree rotations about the vertical axis (red arrows), and 120120-degree rotations about a diagonal axis (blue arrows).

As our second example, we consider DNA sequences made up of four letters: C, G, A, and T. The sequences can be represented on the 1D grid Ω=Z\Omega = \mathbb{Z} as signals x:Z→R4x : \mathbb{Z} \rightarrow \mathbb{R}^4, where each letter is one-hot coded in R4\mathbb{R}^4. Naturally, we have a discrete 1D translation symmetry on the grid, but DNA sequences have an additional interesting symmetry. This symmetry arises from the way DNA is physically embodied as a double helix, and the way it is read by the molecular machinery of the cell. Each strand of the double helix begins with what is called the 5′5'-end and ends with a 3′3'-end, with the 5′5' on one strand complemented by a 3′3' on the other strand. In other words, the two strands have an opposite orientation. Since the DNA molecule is always read off starting at the 5′5'-end, but we do not know which one, a sequence such as ACCCTGG is equivalent to the reversed sequence with each letter replaced by its complement, CCAGGGT. This is called reverse-complement symmetry of the letter sequence. We thus have the two-element group Z2={0,1}\mathbb{Z}_2 = \{0, 1\} corresponding to the identity 00 and reverse-complement transformation 11 (and composition 1+1=0mod  21 + 1 = 0 \mod{2}). The full group combines translations and reverse-complement transformations.

gdl-fig-dna-double-helix.png

\ A schematic of the DNA’s double helix structure, with the two strands coloured in blue and red. Note how the sequences in the helices are complementary and read in reverse (from 5’ to 3’).

DNA is a biopolymer molecule made of four repeating units called nucleotides (Cytosine, Guanine, Adenine, and Thymine), arranged into two strands coiled around each other in a double helix, where each nucleotide occurs opposite of the complementary one (base pairs A/T and C/G).

In our case, the group convolution (18) we defined in Section 4.3 is given as

(x⋆θ)(g)=∑u∈Ωxuρ(g)θu,(31)(x \star \theta)({\mathfrak{g}}) = \sum_{u \in \Omega} x_u \rho({\mathfrak{g}}) \theta_u, \tag{31}

the inner product between the (single-channel) input signal xx and a filter θ\theta transformed by g∈G{\mathfrak{g}} \in {\mathfrak{G}} via ρ(g)θu=θg−1u\rho({\mathfrak{g}}) \theta_u = \theta_{{\mathfrak{g}}^{-1} u}, and the output x⋆θx\star \theta is a function on G{\mathfrak{G}}. Note that since Ω\Omega is discrete, we have replaced the integral from equation (18) by a sum.

Transform+Convolve approach. We will show that the group convolution can be implemented in two steps: a filter transformation step, and a translational convolution step. The filter transformation step consists of creating rotated (or reverse-complement transformed) copies of a basic filter, while the translational convolution is the same as in standard CNNs and thus efficiently computable on hardware such as GPUs. To see this, note that in both of our examples we can write a general transformation g∈G{\mathfrak{g}} \in {\mathfrak{G}} as a transformation h∈H{\mathfrak{h}} \in {\mathfrak{H}} (e.g. a rotation or reverse-complement transformation) followed by a translation k∈Zd{\mathfrak{k}} \in \mathbb{Z}^d, i.e. g=kh{\mathfrak{g}} = {\mathfrak{k}} {\mathfrak{h}} (with juxtaposition denoting the composition of the group elements k{\mathfrak{k}} and h{\mathfrak{h}}). By properties of the group representation, we have ρ(g)=ρ(kh)=ρ(k)ρ(h)\rho({\mathfrak{g}}) = \rho({\mathfrak{k}} {\mathfrak{h}}) = \rho({\mathfrak{k}}) \rho({\mathfrak{h}}). Thus,

(x⋆θ)(kh)=∑u∈Ωxuρ(k)ρ(h)θu=∑u∈Ωxu(ρ(h)θ)u−k(32)\begin{aligned} (x\star \theta )({\mathfrak{k}} {\mathfrak{h}}) &= \sum_{u \in \Omega} x_u \rho({\mathfrak{k}}) \rho({\mathfrak{h}}) \theta_{u} \\ &= \sum_{u \in \Omega} x_u (\rho({\mathfrak{h}}) \theta)_{u - {\mathfrak{k}}} \end{aligned} \tag{32}

We recognise the last equation as the standard (planar Euclidean) convolution of the signal xx and the transformed filter ρ(h)θ\rho({\mathfrak{h}}) \theta. Thus, to implement group convolution for these groups, we take the canonical filter θ\theta, create transformed copies θh=ρ(h)θ\theta_{\mathfrak{h}} = \rho({\mathfrak{h}}) \theta for each h∈H{\mathfrak{h}} \in {\mathfrak{H}} (e.g. each rotation h∈Oh{\mathfrak{h}} \in O_h or reverse-complement DNA symmetry h∈Z2{\mathfrak{h}} \in \mathbb{Z}_2), and then convolve xx with each of these filters: (x⋆θ)(kh)=(x⋆θh)(k)(x\star \theta )({\mathfrak{k}} {\mathfrak{h}}) = (x\star \theta_{{\mathfrak{h}}} )({\mathfrak{k}}). For both of our examples, the symmetries act on filters by simply permuting the filter coefficients, as shown in Figure 16 for discrete rotations. Hence, these operations can be implemented efficiently using an indexing operation with pre-computed indices.

While we defined the feature maps output by the group convolution x⋆θx \star \theta as functions on G{\mathfrak{G}}, the fact that we can split g{\mathfrak{g}} into h{\mathfrak{h}} and k{\mathfrak{k}} means that we can also think of them as a stack of Euclidean feature maps (sometimes called orientation channels), with one feature map per filter transformation / orientation k{\mathfrak{k}}. For instance, in our first example we would associate to each filter rotation (each node in Figure 16) a feature map, which is obtained by convolving (in the traditional translational sense) the rotated filter. These feature maps can thus still be stored as a W×H×CW \times H \times C array, where the number of channels CC equals the number of independent filters times the number of transformations h∈H{\mathfrak{h}} \in {\mathfrak{H}} (e.g. rotations).

As shown in Section 4.3, the group convolution is equivariant: (ρ(g)x)⋆θ=ρ(g)(x⋆θ)(\rho({\mathfrak{g}}) x) \star \theta = \rho({\mathfrak{g}}) (x \star \theta). What this means in terms of orientation channels is that under the action of h{\mathfrak{h}}, each orientation channel is transformed, and the orientation channels themselves are permuted. For instance, if we associate one orientation channel per transformation in Figure 16 and apply a rotation by 9090 degrees about the z-axis (corresponding to the red arrows), the feature maps will be permuted as shown by the red arrows. This description makes it clear that a group convolutional neural network bears much similarity to a traditional CNN. Hence, many of the network design patterns discussed in the Section 5.1, such as residual networks, can be used with group convolutions as well.

Spherical CNNs in the Fourier domain. For the continuous symmetry group of the sphere that we saw in Section 4.3, it is possible to implement the convolution in the spectral domain, using the appropriate Fourier transform (we remind the reader that the convolution on S2\mathbb{S}^2 is a function on SO(3)\mathrm{SO}(3), hence we need to define the Fourier transform on both these domains in order to implement multi-layer spherical CNNs). Spherical harmonics are an orthogonal basis on the 2D sphere, analogous to the classical Fourier basis of complex exponential. On the special orthogonal group, the Fourier basis is known as the Wigner D-functions. In both cases, the Fourier transforms (coefficients) are computed as the inner product with the basis functions, and an analogy of the Convolution Theorem holds: one can compute the convolution in the Fourier domain as the element-wise product of the Fourier transforms. Furthermore, FFT-like algorithms exist for the efficient computation of Fourier transform on S2\mathbb{S}^2 and SO(3)\mathrm{SO}(3). We refer for further details to Cohen et al. (2018).

Graph Neural Networks (GNNs) are the realisation of our Geometric Deep Learning blueprint on graphs leveraging the properties of the permutation group. GNNs are among the most general class of deep learning architectures currently in existence, and as we will see in this text, most other deep learning architectures can be understood as a special case of the GNN with additional geometric structure.

As per our discussion in Section 4.1, we consider a graph to be specified with an adjacency matrix A\mathbf{A} and node features X\mathbf{X}. We will study GNN architectures that are permutation equivariant functions F(X,A)\mathbf{F}(\mathbf{X},\mathbf{A}) constructed by applying shared permutation invariant functions ϕ(xu,XNu)\phi(\mathbf{x}_u, \mathbf{X}_{\mathcal{N}_u}) over local neighbourhoods. Under various guises, this local function ϕ\phi can be referred to as “diffusion”, “propagation”, or “message passing”, and the overall computation of such F\mathbf{F} as a “GNN layer”.

The design and study of GNN layers is one of the most active areas of deep learning at the time of writing, making it a landscape that is challenging to navigate. Fortunately, we find that the vast majority of the literature may be derived from only three “flavours” of GNN layers (Figure 17), which we will present here. These flavours govern the extent to which ϕ\phi transforms the neighbourhood features, allowing for varying degrees of complexity when modelling interactions across the graph.

In all three flavours, permutation invariance is ensured by aggregating features from XNu\mathbf{X}_{\mathcal{N}_u} (potentially transformed, by means of some function ψ\psi) with some permutation-invariant function ⨁\bigoplus, and then updating the features of node uu, by means of some function ϕ\phi. Typically, ψ\psi and ϕ\phi are learnable, whereas ⨁\bigoplus is realised as a nonparametric operation such as sum, mean, or maximum, though it can also be constructed e.g. using recurrent neural networks (Murphy et al., 2018).

Most commonly, ψ\psi and ϕ\phi are learnable affine transformations with activation functions; e.g. ψ(x)=Wx+b\psi(\mathbf{x}) = {\bf W}\mathbf{x} + \mathbf{b}; ϕ(x,z)=σ(Wx+Uz+b)\phi(\mathbf{x}, \mathbf{z}) = \sigma\left({\bf W}\mathbf{x} + {\bf U}\mathbf{z} + \mathbf{b}\right), where W,U,b{\bf W}, {\bf U}, \mathbf{b} are learnable parameters and σ\sigma is an activation function such as the rectified linear unit. The additional input of xu\mathbf{x}_u to ϕ\phi represents an optional skip-connection, which is often very useful.

Figure 17: A visualisation of the dataflow for the three flavours of GNN layers, gg. We use the neighbourhood of node bb from Figure 10 to illustrate this. Left-to-right: convolutional, where sender node features are multiplied with a constant, cuvc_{uv}; attentional, where this multiplier is implicitly computed via an attention mechanism of the receiver over the sender: αuv=a(xu,xv)\alpha_{uv}=a(\mathbf{x}_u, \mathbf{x}_v); and message-passing, where vector-based messages are computed based on both the sender and receiver: muv=ψ(xu,xv)\mathbf{m}_{uv}=\psi(\mathbf{x}_u, \mathbf{x}_v). (Figure not in the corpus: GNN_GDL_TYPES_C.pdf, GNN_GDL_TYPES_A.pdf, GNN_GDL_TYPES_MP.pdf.)

In the convolutional flavour (Kipf and Welling, 2016a; Defferrard et al., 2016; Wu et al., 2019), the features of the neighbourhood nodes are directly aggregated with fixed weights,

hu=ϕ(xu,⨁v∈Nucuvψ(xv)).(33)\mathbf{h}_u = \phi\left(\mathbf{x}_u, \bigoplus\limits_{v\in\mathcal{N}_u}c_{uv}\psi(\mathbf{x}_v)\right). \tag{33}

Here, cuvc_{uv} specifies the importance of node vv to node uu‘s representation. It is a constant that often directly depends on the entries in A{\bf A} representing the structure of the graph. Note that when the aggregation operator ⨁\bigoplus is chosen to be the summation, it can be considered as a linear diffusion or position-dependent linear filtering, a generalisation of convolution. In particular, the spectral filters we have seen in Sections 4.4 and 4.6 fall under this category, as they amount to applying fixed local operators (e.g. the Laplacian matrix) to node-wise signals.

It is worthy to note that this flavour does not express every GNN layer that is convolutional (in the sense of commuting with the graph structure), but covers most such approaches proposed in practice. We will provide detailed discussion and extensions in future work.

In the attentional flavour (Veličković et al., 2018; Monti et al., 2017; Zhang et al., 2018), the interactions are implicit

hu=ϕ(xu,⨁v∈Nua(xu,xv)ψ(xv)).(34)\mathbf{h}_u = \phi\left(\mathbf{x}_u, \bigoplus\limits_{v\in\mathcal{N}_u}a(\mathbf{x}_u, \mathbf{x}_v)\psi(\mathbf{x}_v)\right). \tag{34}

Here, aa is a learnable self-attention mechanism that computes the importance coefficients αuv=a(xu,xv)\alpha_{uv} = a(\mathbf{x}_u, \mathbf{x}_v) implicitly. They are often softmax-normalised across all neighbours. When ⨁\bigoplus is the summation, the aggregation is still a linear combination of the neighbourhood node features, but now the weights are feature-dependent.

Finally, the message-passing flavour (Gilmer et al., 2017; Battaglia et al., 2018) amounts to computing arbitrary vectors (“messages”) across edges,

hu=ϕ(xu,⨁v∈Nuψ(xu,xv)).(35)\mathbf{h}_u = \phi\left(\mathbf{x}_u, \bigoplus\limits_{v\in\mathcal{N}_u}\psi(\mathbf{x}_u, \mathbf{x}_v)\right). \tag{35}

Here, ψ\psi is a learnable message function, computing vv‘s vector sent to uu, and the aggregation can be considered as a form of message passing on the graph.

One important thing to note is a representational containment between these approaches: convolution ⊆\subseteq attention ⊆\subseteq message-passing. Indeed, attentional GNNs can represent convolutional GNNs by an attention mechanism implemented as a look-up table a(xu,xv)=cuva(\mathbf{x}_u, \mathbf{x}_v) = c_{uv}, and both convolutional and attentional GNNs are special cases of message-passing where the messages are only the sender nodes’ features: ψ(xu,xv)=cuvψ(xv)\psi(\mathbf{x}_u, \mathbf{x}_v) = c_{uv}\psi(\mathbf{x}_v) for convolutional GNNs and ψ(xu,xv)=a(xu,xv)ψ(xv)\psi(\mathbf{x}_u, \mathbf{x}_v) = a(\mathbf{x}_u, \mathbf{x}_v)\psi(\mathbf{x}_v) for attentional GNNs.

This does not imply that message passing GNNs are always the most useful variant; as they have to compute vector-valued messages across edges, they are typically harder to train and require unwieldy amounts of memory. Further, on a wide range of naturally-occurring graphs, the graph’s edges encode for downstream class similarity (i.e. an edge (u,v)(u, v) implies that uu and vv are likely to have the same output). For such graphs (often called homophilous), convolutional aggregation across neighbourhoods is often a far better choice, both in terms of regularisation and scalability. Attentional GNNs offer a “middle-ground”: they allow for modelling complex interactions within neighbourhoods while computing only scalar-valued quantities across the edges, making them more scalable than message-passing.

The “three flavour” categorisation presented here is provided with brevity in mind and inevitably neglects a wealth of nuances, insights, generalisations, and historical contexts to GNN models. Importantly, it excludes higher-dimensional GNN based on the Weisfeiler-Lehman hierarchy and spectral GNNs relying on the explicit computation of the graph Fourier transform.

5.4 Deep Sets, Transformers, and Latent Graph Inference

Section titled “5.4 Deep Sets, Transformers, and Latent Graph Inference”

We close the discussion on GNNs by remarking on permutation-equivariant neural network architectures for learning representations of unordered sets. While sets have the least structure among the domains we have discussed in this text, their importance has been recently highlighted by highly-popular architectures such as Transformers (Vaswani et al., 2017) and Deep Sets (Zaheer et al., 2017). In the language of Section 4.1, we assume that we are given a matrix of node features, X{\bf X}, but without any specified adjacency or ordering information between the nodes. The specific architectures will arise by deciding to what extent to model interactions between the nodes.

Empty edge set.

Unordered sets are provided without any additional structure or geometry whatsoever—hence, it could be argued that the most natural way to process them is to treat each set element entirely independently. This translates to a permutation equivariant function over such inputs, which was already introduced in Section 4.1: a shared transformation applied to every node in isolation. Assuming the same notation as when describing GNNs (Section 5.3), such models can be represented as

hu=ψ(xu),\mathbf{h}_u = \psi(\mathbf{x}_u),

where ψ\psi is a learnable transformation. It may be observed that this is a special case of a convolutional GNN with Nu={u}\mathcal{N}_u = \{u\}—or, equivalently, A=I{\bf A} = {\bf I}. Such an architecture is commonly referred to as Deep Sets, in recognition of the work of Zaheer et al. (2017) that have theoretically proved several universal-approximation properties of such architectures. It should be noted that the need to process unordered sets commonly arises in computer vision and graphics when dealing with point clouds; therein, such models are known as PointNets (Qi et al., 2017).

Complete edge set.

While assuming an empty edge set is a very efficient construct for building functions over unordered sets, often we would expect that elements of the set exhibit some form of relational structure—i.e., that there exists a latent graph between the nodes. Setting A=I{\bf A} = {\bf I} discards any such structure, and may yield suboptimal performance. Conversely, we could assume that, in absence of any other prior knowledge, we cannot upfront exclude any possible links between nodes. In this approach we assume the complete graph, A=11⊤{\bf A} = {\bf 1}{\bf 1}^\top; equivalently, Nu=V\mathcal{N}_u = \mathcal{V}. As we do not assume access to any coefficients of interaction, running convolutional-type GNNs over such a graph would amount to:

hu=ϕ(xu,⨁v∈Vψ(xv)),\mathbf{h}_u = \phi\left(\mathbf{x}_u, \bigoplus_{v\in \mathcal{V}} \psi(\mathbf{x}_v)\right),

where the second input, ⨁v∈Vψ(xv)\bigoplus_{v\in \mathcal{V}} \psi(\mathbf{x}_v) is identical for all nodes uu, and as such makes the model equivalently expressive to ignoring that input altogether; i.e. the A=I{\bf A} = {\bf I} case mentioned above.

This is a direct consequence of the permutation invariance of ⨁\bigoplus.

This motivates the use of a more expressive GNN flavour, the attentional,

hu=ϕ(xu,⨁v∈Va(xu,xv)ψ(xv))(36)\mathbf{h}_u = \phi\left(\mathbf{x}_u, \bigoplus_{v\in \mathcal{V}} a(\mathbf{x}_u, \mathbf{x}_v)\psi(\mathbf{x}_v)\right) \tag{36}

which yields the self-attention operator, the core of the Transformer architecture (Vaswani et al., 2017). Assuming some kind of normalisation over the attentional coefficients (e.g. softmax), we can constrain all the scalars a(xu,xv)a(\mathbf{x}_u, \mathbf{x}_v) to be in the range [0,1][0, 1]; as such, we can think of self-attention as inferring a soft adjacency matrix, auv=a(xu,xv)a_{uv} = a(\mathbf{x}_u, \mathbf{x}_v), as a byproduct of gradient-based optimisation for some downstream task.

The above perspective means that we can pose Transformers exactly as attentional GNNs over a complete graph (Joshi, 2020). However, this is in apparent conflict with Transformers being initially proposed for modelling sequences—the representations of hu\mathbf{h}_u should be mindful of node uu‘s position in the sequence, which complete-graph aggregation would ignore. Transformers address this issue by introducing positional encodings: the node features xu\mathbf{x}_u are augmented to encode node uu‘s position in the sequence, typically as samples from a sine wave whose frequency is dependent on uu.

It is also appropriate to apply the message-passing flavour. While popular for physics simulations and relational reasoning (e.g. Battaglia et al. (2016); Santoro et al. (2017)), they have not been as widely used as Transformers. This is likely due to the memory issues associated with computing vector messages over a complete graph, or the fact that vector-based messages are less interpretable than the “soft adjacency” provided by self-attention.

On graphs, where no natural ordering of nodes exists, multiple alternatives were proposed to such positional encodings. While we defer discussing these alternatives for later, we note that one promising direction involves a realisation that the positional encodings used in Transformers can be directly related to the discrete Fourier transform (DFT), and hence to the eigenvectors of the graph Laplacian of a “circular grid”. Hence, Transformers’ positional encodings are implicitly representing our assumption that input nodes are connected in a grid. For more general graph structures, one may simply use the Laplacian eigenvectors of the (assumed) graph—an observation exploited by Dwivedi and Bresson (2020) within their empirically powerful Graph Transformer model.

Inferred edge set.

Finally, one can try to learn the latent relational structure, leading to some general A{\bf A} that is neither I{\bf I} nor 11⊤{\bf 1}{\bf 1}^\top. The problem of inferring a latent adjacency matrix A{\bf A} for a GNN to use (often called latent graph inference) is of high interest for graph representation learning. This is due to the fact that assuming A=I{\bf A} = {\bf I} may be representationally inferior, and A=11⊤{\bf A} = {\bf 1}{\bf 1}^\top may be challenging to implement due to memory requirements and large neighbourhoods to aggregate over. Additionally, it is closest to the “true” problem: inferring an adjacency matrix A{\bf A} implies detecting useful structure between the rows of X{\bf X}, which may then help formulate hypotheses such as causal relations between variables.

Unfortunately, such a framing necessarily induces a step-up in modelling complexity. Specifically, it requires properly balancing a structure learning objective (which is discrete, and hence challenging for gradient-based optimisation) with any downstream task the graph is used for. This makes latent graph inference a highly challenging and intricate problem.

In many applications of Graph Neural Networks, node features (or parts thereof) are not just arbitrary vectors but coordinates of geometric entities. This is the case, for example, when dealing with molecular graphs: the nodes representing atoms may contain information about the atom type as well as its 3D spatial coordinates. It is desirable to process the latter part of the features in a manner that would transform in the same way as the molecule is transformed in space, in other words, be equivariant to the Euclidean group E(3)\mathrm{E}(3) of rigid motions (rotations, translations, and reflections) in addition to the standard permutation equivariance discussed before.

To set the stage for our (slightly simplified) analysis, we will make a distinction between node features fu∈Rd\mathbf{f}_u \in \mathbb{R}^d and node spatial coordinates xu∈R3\mathbf{x}_u\in \mathbb{R}^3; the latter are endowed with Euclidean symmetry structure. In this setting, an equivariant layer explicitly transforms these two inputs separately, yielding modified node features fu′\mathbf{f}'_u and coordinates xu′\mathbf{x}'_u.

We can now state our desirable equivariance property, following the Geometric Deep Learning blueprint. If the spatial component of the input is transformed by g∈E(3){\mathfrak{g}}\in \mathrm{E}(3) (represented as ρ(g)x=Rx+b\rho({\mathfrak{g}})\mathbf{x} = \mathbf{R}\mathbf{x} + \mathbf{b}, where R\mathbf{R} is an orthogonal matrix modeling rotations and reflections, and b\mathbf{b} is a translation vector), the spatial component of the output transforms in the same way (as xu′↦Rxu′+b\mathbf{x}'_u \mapsto \mathbf{R}\mathbf{x}'_u + \mathbf{b}), whereas fu′\mathbf{f}'_u remains invariant.

Much like the space of permutation equivariant functions we discussed before in the context of general graphs, there exists a vast amount of E(3)\mathrm{E}(3)-equivariant layers that would satisfy the constraints above—but not all of these layers would be geometrically stable, or easy to implement. In fact, the space of practically useful equivariant layers may well be easily described by a simple categorisation, not unlike our “three flavours” of spatial GNN layers. One elegant solution was suggested by Satorras et al. (2021) in the form of equivariant message passing. Their model operates as follows:

fu′=ϕ(fu,⨁v∈Nuψf(fu,fv,∥xu−xv∥2)),xu′=xu+∑v≠u(xu−xv)ψc(fu,fv,∥xu−xv∥2)\begin{aligned}\mathbf{f}'_u &=& \phi\left(\mathbf{f}_u, \bigoplus\limits_{v\in\mathcal{N}_u}\psi_\mathrm{f}(\mathbf{f}_u, \mathbf{f}_v, \| \mathbf{x}_u - \mathbf{x}_v \|^2)\right),\\ \mathbf{x}'_u &=& \mathbf{x}_u + \sum_{v\neq u} (\mathbf{x}_u - \mathbf{x}_v) \psi_\mathrm{c}(\mathbf{f}_u, \mathbf{f}_v, \| \mathbf{x}_u - \mathbf{x}_v \|^2)\end{aligned}

where ψf\psi_\mathrm{f} and ψc\psi_\mathrm{c} are two distinct (learnable) functions. It can be shown that such an aggregation is equivariant under Euclidean transformations of the spatial coordinates. This is due to the fact that the only dependence of fu′\mathbf{f}'_u on xu\mathbf{x}_u is through the distances ∥xu−xv∥2\| \mathbf{x}_u - \mathbf{x}_v \|^2, and the action of E(3)\mathrm{E}(3) necessarily leaves distances between nodes unchanged. Further, the computations of such a layer can be seen as a particular instance of the “message-passing” GNN flavour, hence they are efficient to implement.

To summarise, in contrast to ordinary GNNs, Satorras et al. (2021) enable the correct treatment of ‘coordinates’ for each point in the graph. They are now treated as a member of the E(3)\mathrm{E}(3) group, which means the network outputs behave correctly under rotations, reflections and translations of the input. The features, fu\mathbf{f}_u, however, are treated in a channel-wise manner and still assumed to be scalars that do not change under these transformations. This limits the type of spatial information that can be captured within such a framework. For example, it may be desirable for some features to be encoded as vectors—e.g. point velocities—which should change direction under such transformations. Satorras et al. (2021) partially alleviate this issue by introducing the concept of velocities in one variant of their architecture. Velocities are a 3D vector property of each point which rotates appropriately. However, this is only a small subspace of the general representations that could be learned with an E(3)\mathrm{E}(3) equivariant network. In general, node features may encode tensors of arbitrary dimensionality that would still transform according to E(3)\mathrm{E}(3) in a well-defined manner.

gdl-fig-rotation-scalar-vs-vector-features.png

\ While scalar features (heatmap) do not change under rotations, vector features (arrows) may change direction. The simple E(3)\mathrm{E}(3) equivariant GNN given before does not take this into account.

Hence, while the architecture discussed above already presents an elegant equivariant solution for many practical input representations, in some cases it may be desirable to explore a broader collection of functions that satisfy the equivariance property. Existing methods dealing with such settings can be categorised into two classes: irreducible representations (of which the previously mentioned layer is a simplified instance) and regular representations. We briefly survey them here, leaving detailed discussion to future work.

Irreducible representations. Irreducible representations build on the finding that all elements of the roto-translation group can be brought into an irreducible form: a vector that is rotated by a block diagonal matrix. Crucially, each of those blocks is a Wigner D-matrix (the aforementioned Fourier basis for Spherical CNNs). Approaches under this umbrella map from one set of irreducible representations to another using equivariant kernels. To find the full set of equivariant mappings, one can then directly solve the equivariance constraint over these kernels. The solutions form a linear combination of equivariant basis matrices derived by Clebsch-Gordan matrices and the spherical harmonics.

Early examples of the irreducible representations approach include Tensor Field Networks (Thomas et al., 2018) and 3D Steerable CNNs (Weiler et al., 2018), both convolutional models operating on point clouds. The SE(3)\mathrm{SE}(3)-Transformer of Fuchs et al. (2020) extends this framework to the graph domain, using an attentional layer rather than convolutional. Further, while our discussion focused on the special case solution of Satorras et al. (2021), we note that the motivation for rotation or translation equivariant predictions over graphs had historically been explored in other fields, including architectures such as Dynamic Graph CNN (Wang et al., 2019b) for point clouds and efficient message passing models for quantum chemistry, such as SchNet (Schütt et al., 2018) and DimeNet (Klicpera et al., 2020).

Regular representations. While the approach of irreducible representations is attractive, it requires directly reasoning about the underlying group representations, which may be tedious, and only applicable to groups that are compact. Regular representation approaches are more general, but come with an additional computational burden – for exact equivariance they require storing copies of latent feature embeddings for all group elements.

This approach was, in fact, pioneered by the group convolutional neural networks we presented in previous sections.

One promising approach in this space aims to observe equivariance to Lie groups—through definitions of exponential and logarithmic maps—with the promise of rapid prototyping across various symmetry groups. While Lie groups are out of scope for this section, we refer the reader to two recent successful instances of this direction: the LieConv of Finzi et al. (2020), and the LieTransformer of Hutchinson et al. (2020).

The approaches covered in this section represent popular ways of processing data on geometric graphs in an way that is explicitly equivariant to the underlying geometry. As discussed in Section 4.6, meshes are a special instance of geometric graphs that can be understood as discretisations of continuous surfaces. We will study mesh-specific equivariant neural networks next.

Meshes, in particular, triangular ones, are the ‘bread and butter’ of computer graphics and perhaps the most common way of modeling 3D objects. The remarkable success of deep learning in general and CNNs in computer vision in particular has lead to a keen interest in the graphics and geometry processing community around the mid-2010s to construct similar architectures for mesh data.

gdl-fig-geodesic-patches-human.png

Examples of geodesic patches. In order for the resulting patch to be a topological disk, its radius RR must be smaller than the injectivity radius.

Geodesic patches. Most of the architectures for deep learning on meshes implement convolutional filters of the form (23) by discretising or approximating the exponential map and expressing the filter in a coordinate system of the tangent plane. Shooting a geodesic γ:[0,T]→Ω\gamma:[0,T]\rightarrow \Omega from a point u=γ(0)u=\gamma(0) to nearby point v=γ(T)v=\gamma(T) defines a local system of geodesic polar coordinates (r(u,v),ϑ(u,v))(r(u,v),\vartheta(u,v)) where rr is the geodesic distance between uu and vv (length of the geodesic γ\gamma) and ϑ\vartheta is the angle between γ′(0)\gamma'(0) and some local reference direction. This allows to define a geodesic patch x(u,r,ϑ)=x(exp⁡uω~(r,ϑ))x(u,r,\vartheta) = x(\exp_u \tilde{\omega}(r,\vartheta)), where ω~u:[0,R]×[0,2π)→TuΩ\tilde{\omega}_u: [0,R]\times [0,2\pi) \rightarrow T_u\Omega is the local polar frame.

On a surface discretised as a mesh, a geodesic is a poly-line that traverses the triangular faces. Traditionally, geodesics have been computed using the Fast Marching algorithm Kimmel and Sethian (1998), an efficient numerical approximation of a nonlinear PDE called the eikonal equation encountered in physical models of wave propagation in a medium. This scheme was adapted by Kokkinos et al. (2012) for the computation of local geodesic patches and later reused by Masci et al. (2015) for the construction of Geodesic CNNs, the first intrinsic CNN-like architectures on meshes.

gdl-fig-discrete-geodesics-mesh.png

Construction of discrete geodesics on a mesh.

Isotropic filters. Importantly, in the definition of the geodesic patch we have ambiguity in the choice of the reference direction and the patch orientation. This is exactly the ambiguity of the choice of the gauge, and our local system of coordinates is defined up to arbitrary rotation (or a shift in the angular coordinate, x(u,r,ϑ+ϑ0)x(u,r,\vartheta+\vartheta_0)), which can be different at every node. Perhaps the most straightforward solution is to use isotropic filters of the form θ(r)\theta(r) that perform a direction-independent aggregation of the neighbour features,

(x⋆θ)(u)=∫0R∫02πx(u,r,ϑ)θ(r)drdϑ.(x\star \theta)(u) = \int_0^R \int_0^{2\pi} x(u,r,\vartheta) \theta(r) \mathrm{d}r \mathrm{d}\vartheta.

Spectral filters discussed in Sections 4.4–4.6 fall under this category: they are based on the Laplacian operator, which is isotropic. Such an approach, however, discards important directional information, and might fail to extract edge-like features.

Fixed gauge. An alternative, to which we have already alluded in Section 4.4, is to fix some gauge. Monti et al. (2017) used the principal curvature directions: while this choice is not intrinsic and may ambiguous at flat points (where curvature vanishes) or uniform curvature (such as on a perfect sphere), the authors showed that it is reasonable for dealing with deformable human body shapes, which are approximately piecewise-rigid. Later works, e.g. Melzi et al. (2019), showed reliable intrinsic construction of gauges on meshes, computed as (intrinsic) gradients of intrinsic functions. While such tangent fields might have singularities (i.e., vanish at some points), the overall procedure is very robust to noise and remeshing.

Angular pooling. Another approach, referred to as angular max pooling, was used by Masci et al. (2015). In this case, the filter θ(r,ϑ)\theta(r,\vartheta) is anisotropic, but its matching with the function is performed over all the possible rotations, which are then aggregated:

(x⋆θ)(u)=max⁡ϑ0∈[0,2π)  ∫0R∫02πx(u,r,ϑ)θ(r,ϑ+ϑ0)drdϑ.(x\star \theta)(u) = \max_{\vartheta_0 \in [0,2\pi) } \,\, \int_0^R \int_0^{2\pi} x(u,r,\vartheta) \theta(r,\vartheta+\vartheta_0) \mathrm{d}r \mathrm{d}\vartheta.

Conceptually, this can be visualised as correlating geodesic patches with a rotating filter and collecting the strongest responses.

On meshes, the continuous integrals can be discretised using a construction referred to as patch operators (Masci et al., 2015). In a geodesic patch around node uu, the neighbour nodes Nu\mathcal{N}_u, represented in the local polar coordinates as (ruv,ϑuv)(r_{uv}, \vartheta_{uv}), are weighted by a set of weighting functions w1(r,ϑ),⋯ ,wK(r,ϑ)w_1(r,\vartheta), \cdots, w_K(r,\vartheta) (shown in Figure 18 and acting as ‘soft pixels’) and aggregated,

(x⋆θ)u=∑k=1Kwk∑v∈Nu(ruv,ϑuv)xv θk∑k=1Kwk∑v∈Nu(ruv,ϑuv)θk(x\star \theta)_u = \frac{ \sum_{k=1}^K w_{k} \sum_{v\in \mathcal{N}_u} (r_{uv},\vartheta_{uv}) x_v \, \theta_k } { \sum_{k=1}^K w_{k} \sum_{v\in \mathcal{N}_u} (r_{uv},\vartheta_{uv}) \theta_k }

(here θ1,⋯ ,θK\theta_1,\cdots, \theta_K are the learnable coefficients of the filter). Multi-channel features are treated channel-wise, with a family of appropriate filters. Masci et al. (2015); Boscaini et al. (2016a) used pre-defined weighting functions ww, while Monti et al. (2017) further allowed them to be learnable.

Typically multi-hop neighbours are used.

gdl-fig-18-patch-operators.png

Figure 18: Left-to-right: examples of patch operators used in Geodesic CNN (Masci et al., 2015), Anisotropic CNN (Boscaini et al., 2016b) and MoNet (Monti et al., 2017), with the level sets of the weighting functions wk(r,ϑ)w_k(r,\vartheta) shown in red.

Gauge-equivariant filters. Both isotropic filters and angular max pooling lead to features that are invariant to gauge transformations; they transform according to the trivial representation ρ(g)=1\rho({\mathfrak{g}}) = 1 (where g∈SO(2){\mathfrak{g}} \in \mathrm{SO}(2) is a rotation of the local coordinate frame). This point of view suggests another approach, proposed by Cohen et al. (2019); de Haan et al. (2020) and discussed in Section 4.5, where the features computed by the network are associated with an arbitrary representation ρ\rho of the structure group G{\mathfrak{G}} (e.g. SO(2)\mathrm{SO(2)} or O(2)\mathrm{O(2)} of rotations or rotations+reflections of the coordinate frame, respectively). Tangent vectors transform according to the standard representation ρ(g)=g\rho({\mathfrak{g}}) = {\mathfrak{g}}. As another example, the feature vector obtained by matching nn rotated copies of the same filter transforms by cyclic shifts under rotations of the gauge; this is known as the regular representation of the cyclic group CnC_n.

As discussed in Section 4.5, when dealing with such geometric features (associated to a non-trivial representation), we must first parallel transport them to the same vector space before applying the filter. On a mesh, this can be implemented via the following message passing mechanism described by de Haan et al. (2020). Let xu∈Rd\mathbf{x}_u \in \mathbb{R}^d be a dd-dimensional input feature at mesh node uu. This feature is expressed relative to an (arbitrary) choice of gauge at uu, and is assumed to transform according to a representation ρin\rho_{\textup{in}} of G=SO⁡(2){\mathfrak{G}} = \operatorname{SO}(2) under rotations of the gauge. Similarly, the output features hu\mathbf{h}_u of the mesh convolution are d′d' dimensional and should transform according to ρout\rho_{\textup{out}} (which can be chosen at will by the network designer).

By analogy to Graph Neural Networks, we can implement the gauge-equivariant convolution (25) on meshes by sending messages from the neighbours Nu\mathcal{N}_u of uu (and from uu itself) to uu:

hu=Θself  xu+∑v∈NuΘneigh(ϑuv)ρ(gv→u)xv,(37)\mathbf{h}_u = \boldsymbol{\Theta}_{\textup{self}} \; \mathbf{x}_u + \sum_{v \in \mathcal{N}_u} \boldsymbol{\Theta}_{\textup{neigh}}(\vartheta_{uv}) \rho({\mathfrak{g}}_{v \rightarrow u}) \mathbf{x}_v, \tag{37}

where Θself,Θneigh(ϑuv)∈Rd′×d\boldsymbol{\Theta}_{\textup{self}}, \boldsymbol{\Theta}_{\textup{neigh}}(\vartheta_{uv}) \in \mathbb{R}^{d' \times d} are learned filter matrices. The structure group element gv→u∈SO⁡(2){\mathfrak{g}}_{v \rightarrow u} \in \operatorname{SO}(2) denotes the effect of parallel transport from vv to uu, expressed relative to the gauges at uu and vv, and can be precomputed for each mesh. Its action is encoded by a transporter matrix ρ(gv→u)∈Rd×d\rho({\mathfrak{g}}_{v\rightarrow u})\in\mathbb{R}^{d\times d}. The matrix Θneigh(ϑuv)\boldsymbol{\Theta}_{\textup{neigh}}(\vartheta_{uv}) depends on the angle ϑuv\vartheta_{uv} of the neighbour vv to the reference direction (e.g. first axis of the frame) at uu, so this kernel is anisotropic: different neighbours are treated differently.

Note that dd is the feature dimension and is not necessarily equal to 2, the dimension of the mesh.

As explained in Section 4.5, for h(u)\mathbf{h}(u) to be a well-defined geometric quantity, it should transform as h(u)↦ρout(g−1(u))h(u)\mathbf{h}(u) \mapsto \rho_{\textup{out}}({\mathfrak{g}}^{-1}(u)) \mathbf{h}(u) under gauge transformations. This will be the case when Θselfρin(ϑ)=ρout(ϑ)Θself\boldsymbol{\Theta}_{\textup{self}} \rho_{\textup{in}}(\vartheta) = \rho_{\textup{out}}(\vartheta) \boldsymbol{\Theta}_{\textup{self}} for all ϑ∈SO⁡(2)\vartheta \in \operatorname{SO}(2), and Θneigh(ϑuv−ϑ)ρin(ϑ)=ρout(ϑ)Θneigh(ϑuv)\boldsymbol{\Theta}_{\textup{neigh}}(\vartheta_{uv} - \vartheta) \rho_{\textup{in}}(\vartheta) = \rho_{\textup{out}}(\vartheta) \boldsymbol{\Theta}_{\textup{neigh}}(\vartheta_{uv}). Since these constraints are linear, the space of matrices Θself\boldsymbol{\Theta}_{\textup{self}} and matrix-valued functions Θneigh\boldsymbol{\Theta}_{\textup{neigh}} satisfying these constraints is a linear subspace, and so we can parameterise them as a linear combination of basis kernels with learnable coefficients: Θself=∑iαiΘselfi\boldsymbol{\Theta}_{\textup{self}} = \sum_i \alpha_i \boldsymbol{\Theta}_{\textup{self}}^i and Θneigh=∑iβiΘneighi\boldsymbol{\Theta}_{\textup{neigh}} = \sum_i \beta_i \boldsymbol{\Theta}_{\textup{neigh}}^i.

Here we abuse the notation, identifying 2D rotations with angles ϑ\vartheta.

Our discussion has thus far always assumed the inputs to be solely spatial across a given domain. However, in many common use cases, the inputs can also be considered sequential (e.g. video, text or speech). In this case, we assume that the input consists of arbitrarily many steps, wherein at each step tt we are provided with an input signal, which we represent as X(t)∈X(Ω(t))\mathbf{X}^{(t)} \in \mathcal{X}(\Omega^{(t)}).

Whether the domain is considered static or dynamic concerns time scales: e.g., a road network does change over time (as new roads are built and old ones are demolished), but significantly slower compared to the flow of traffic. Similarly, in social networks, changes in engagement (e.g. Twitter users re-tweeting a tweet) happen at a much higher frequency than changes in the follow graph.

While in general the domain can evolve in time together with the signals on it, it is typically assumed that the domain is kept fixed across all the tt, i.e. Ω(t)=Ω\Omega^{(t)} = \Omega. Here, we will exclusively focus on this case, but note that exceptions are common. Social networks are an example where one often has to account for the domain changing through time, as new links are regularly created as well as erased. The domain in this setting is often referred to as a dynamic graph (Xu et al., 2020a; Rossi et al., 2020).

Often, the individual X(t)\mathbf{X}^{(t)} inputs will exhibit useful symmetries and hence may be nontrivially treated by any of our previously discussed architectures. Some common examples include: videos (Ω\Omega is a fixed grid, and signals are a sequence of frames); fMRI scans (Ω\Omega is a fixed mesh representing the geometry of the brain cortex, where different regions are activated at different times as a response to presented stimuli); and traffic flow networks (Ω\Omega is a fixed graph representing the road network, on which e.g. the average traffic speed is recorded at various nodes).

Let us assume an encoder function f(X(t))f(\mathbf{X}^{(t)}) providing latent representations at the level of granularity appropriate for the problem and respectful of the symmetries of the input domain. As an example, consider processing video frames: that is, at each timestep, we are given a grid-structured input represented as an n×dn\times d matrix X(t)\mathbf{X}^{(t)}, where nn is the number of pixels (fixed in time) and dd is the number of input channels (e.g. d=3d=3 for RGB frames). Further, we are interested in analysis at the level of entire frames, in which case it is appropriate to implement ff as a translation invariant CNN, outputting a kk-dimensional representation z(t)=f(X(t))\mathbf{z}^{(t)} = f(\mathbf{X}^{(t)}) of the frame at time-step tt.

We do not lose generality in our example; equivalent analysis can be done e.g. for node-level outputs on a spatiotemporal graph; the only difference is in the choice of encoder ff (which will then be a permutation equivariant GNN).

We are now left with the task of appropriately summarising a sequence of vectors z(t)\mathbf{z}^{(t)} across all the steps. A canonical way to dynamically aggregate this information in a way that respects the temporal progression of inputs and also easily allows for online arrival of novel data-points, is using a Recurrent Neural Network (RNN). What we will show here is that RNNs are an interesting geometric architecture to study in their own right, since they implement a rather unusual type of symmetry over the inputs z(t)\mathbf{z}^{(t)}.

Note that the z(t)\mathbf{z}^{(t)} vectors can be seen as points on a temporal grid: hence, processing them with a CNN is also viable in some cases. Transformers are also increasingly popular models for processing generic sequential inputs.

SimpleRNNs.

Figure 19: Illustration of processing video input with RNNs. Each input video frame X(t)\mathbf{X}^{(t)} is processed using a shared function ff—e.g. a translation invariant CNN—into a flat representation z(t)\mathbf{z}^{(t)}. Then the RNN update function RR is iterated across these vectors, iteratively updating a summary vector h(t)\mathbf{h}^{(t)} which summarises all the inputs up to and including z(t)\mathbf{z}^{(t)}. The computation is seeded with an initial summary vector h(0)\mathbf{h}^{(0)}, which may be either pre-determined or learnable. (Figure not in the corpus: normal_rnn.pdf.)

At each step, the recurrent neural network computes an mm-dimensional summary vector h(t)\mathbf{h}^{(t)} of all the input steps up to and including tt. This (partial) summary is computed conditional on the current step’s features and the previous step’s summary, through a shared update function, R:Rk×Rm→RmR : \mathbb{R}^k \times \mathbb{R}^m \rightarrow \mathbb{R}^m, as follows (see Figure 19 for a summary):

h(t)=R(z(t),h(t−1))(38)\mathbf{h}^{(t)} = R(\mathbf{z}^{(t)}, \mathbf{h}^{(t-1)}) \tag{38}

and, as both z(t)\mathbf{z}^{(t)} and h(t−1)\mathbf{h}^{(t-1)} are flat vector representations, RR may be most easily expressed as a single fully-connected neural network layer (often known as SimpleRNN; see Elman (1990); Jordan (1997)):

In spite of their name, SimpleRNNs are remarkably expressive. For example, it was shown by Siegelmann and Sontag (1995) that such models are Turing-complete, meaning that they can likely represent any computation we may ever be able to execute on computers.

h(t)=σ(Wz(t)+Uh(t−1)+b)(39)\mathbf{h}^{(t)} = \sigma(\mathbf{W}\mathbf{z}^{(t)} + \mathbf{U}\mathbf{h}^{(t-1)} + \mathbf{b}) \tag{39}

where W∈Rk×m\mathbf{W}\in\mathbb{R}^{k\times m}, U∈Rm×m\mathbf{U}\in\mathbb{R}^{m\times m} and b∈Rm\mathbf{b}\in\mathbb{R}^m are learnable parameters, and σ\sigma is an activation function. While this introduces loops in the network’s computational graph, in practice the network is unrolled for an appropriate number of steps, allowing for backpropagation through time (Robinson and Fallside, 1987; Werbos, 1988; Mozer, 1989) to be applied.

The summary vectors may then be appropriately leveraged for the downstream task—if a prediction is required at every step of the sequence, then a shared predictor may be applied to each h(t)\mathbf{h}^{(t)} individually. For classifying entire sequences, typically the final summary, h(T)\mathbf{h}^{(T)}, is passed to a classifier. Here, TT is the length of the sequence.

Specially, the initial summary vector is usually either set to the zero-vector, i.e. h(0)=0\mathbf{h}^{(0)}=\mathbf{0}, or it is made learnable. Analysing the manner in which the initial summary vector is set also allows us to deduce an interesting form of translation equivariance exhibited by RNNs.

Translation equivariance in RNNs. Since we interpret the individual steps tt as discrete time-steps, the input vectors z(t)\mathbf{z}^{(t)} can be seen as living on a one-dimensional grid of time-steps. While it might be attractive to attempt extending our translation equivariance analysis from CNNs here, it cannot be done in a trivial manner.

Note that this construction is extendable to grids in higher dimensions, allowing us to, e.g., process signals living on images in a scanline fashion. Such a construction powered a popular series of models, such as the PixelRNN from van den Oord et al. (2016b).

To see why, let us assume that we have produced a new sequence z′(t)=z(t+1)\mathbf{z}'^{(t)} = \mathbf{z}^{(t+1)} by performing a left-shift of our sequence by one step. It might be tempting to attempt showing h′(t)=h(t+1)\mathbf{h}'^{(t)} = \mathbf{h}^{(t+1)}, as one expects with translation equivariance; however, this will not generally hold. Consider t=1t = 1; directly applying and expanding the update function, we recover the following:

h′(1)=R(z′(1),h(0))=R(z(2),h(0))(40)\mathbf{h}'^{(1)} = R(\mathbf{z}'^{(1)}, \mathbf{h}^{(0)}) = R(\mathbf{z}^{(2)}, \mathbf{h}^{(0)}) \tag{40} h(2)=R(z(2),h(1))=R(z(2),R(z(1),h(0)))(41)\mathbf{h}^{(2)} = R(\mathbf{z}^{(2)}, \mathbf{h}^{(1)}) = R(\mathbf{z}^{(2)}, R(\mathbf{z}^{(1)}, \mathbf{h}^{(0)})) \tag{41}

Hence, unless we can guarantee that h(0)=R(z(1),h(0))\mathbf{h}^{(0)} = R(\mathbf{z}^{(1)}, \mathbf{h}^{(0)}), we will not recover translation equivariance. Similar analysis can then be done for steps t>1t > 1.

Fortunately, with a slight refactoring of how we represent z\mathbf{z}, and for a suitable choice of RR, it is possible to satisfy the equality above, and hence demonstrate a setting in which RNNs are equivariant to shifts. Our problem was largely one of boundary conditions: the equality above includes z(1)\mathbf{z}^{(1)}, which our left-shift operation destroyed. To abstract this problem away, we will observe how an RNN processes an appropriately left-padded sequence, zˉ(t)\bar{\mathbf{z}}^{(t)}, defined as follows:

zˉ(t)={0t≤t′z(t−t′)t>t′\bar{\mathbf{z}}^{(t)} = \begin{cases} \mathbf{0} & t \leq t'\\ \mathbf{z}^{(t - t')} & t > t' \end{cases}

Such a sequence now allows for left-shifting by up to t′t' steps without destroying any of the original input elements. Further, note we do not need to handle right-shifting separately; indeed, equivariance to right shifts naturally follows from the RNN equations.

Note that equivalent analyses will arise if we use a different padding vector than 0\mathbf{0}.

We can now again analyse the operation of the RNN over a left-shifted verson of zˉ(t)\bar{\mathbf{z}}^{(t)}, which we denote by zˉ′(t)=zˉ(t+1)\bar{\mathbf{z}}'^{(t)} = \bar{\mathbf{z}}^{(t+1)}, as we did in Equations 43–44:

h′(1)=R(zˉ′(1),h(0))=R(zˉ(2),h(0))h(2)=R(zˉ(2),h(1))=R(zˉ(2),R(zˉ(1),h(0)))=R(zˉ(2),R(0,h(0)))\begin{aligned}\mathbf{h}'^{(1)} &= R(\bar{\mathbf{z}}'^{(1)}, \mathbf{h}^{(0)}) = R(\bar{\mathbf{z}}^{(2)}, \mathbf{h}^{(0)})\\ \mathbf{h}^{(2)} &= R(\bar{\mathbf{z}}^{(2)}, \mathbf{h}^{(1)}) = R(\bar{\mathbf{z}}^{(2)}, R(\bar{\mathbf{z}}^{(1)}, \mathbf{h}^{(0)})) = R(\bar{\mathbf{z}}^{(2)}, R(\mathbf{0}, \mathbf{h}^{(0)}))\end{aligned}

where the substitution zˉ(1)=0\bar{\mathbf{z}}^{(1)} = \mathbf{0} holds as long as t′≥1t' \geq 1, i.e. as long as any padding is applied. Now, we can guarantee equivariance to left-shifting by one step (h′(t)=h(t+1)\mathbf{h}'^{(t)} = \mathbf{h}^{(t+1)}) as long as h(0)=R(0,h(0))\mathbf{h}^{(0)} = R(\mathbf{0}, \mathbf{h}^{(0)}).

In a very similar vein, we can derive equivariance to left-shifting by ss steps as long as t′≥st' \geq s.

Said differently, h(0)\mathbf{h}^{(0)} must be chosen to be a fixed point of a function γ(h)=R(0,h)\gamma(\mathbf{h}) = R(\mathbf{0}, \mathbf{h}). If the update function RR is conveniently chosen, then not only can we guarantee existence of such fixed points, but we can even directly obtain them by iterating the application of RR until convergence; e.g., as follows:

h0=0hk+1=γ(hk),(42)\mathbf{h}_0 = \mathbf{0} \qquad \mathbf{h}_{k+1} = \gamma(\mathbf{h}_{k}), \tag{42}

where the index kk refers to the iteration of RR in our computation, as opposed to the the index (t)(t) denoting the time step of the RNN. If we choose RR such that γ\gamma is a contraction mapping, such an iteration will indeed converge to a unique fixed point. Accordingly, we can then iterate Equation (45) until hk+1=hk\mathbf{h}_{k+1} = \mathbf{h}_k, and we can set h(0)=hk\mathbf{h}^{(0)} = \mathbf{h}_k. Note that this computation is equivalent to left-padding the sequence with “sufficiently many” zero-vectors.

Contractions are functions γ:X→X\gamma: \mathcal{X}\rightarrow \mathcal{X} such that, under some norm ∥⋅∥\|\cdot\| on X\mathcal{X}, applying γ\gamma contracts the distances between points: for all x,y∈X\mathbf{x},\mathbf{y}\in\mathcal{X}, and some q∈[0,1)q\in [0,1), it holds that ∥γ(x)−γ(y)∥≤q∥x−y∥\|\gamma(\mathbf{x}) - \gamma(\mathbf{y})\| \leq q\|\mathbf{x} - \mathbf{y}\|. Iterating such a function then necessarily converges to a unique fixed point, as a direct consequence of Banach’s Fixed Point Theorem (Banach, 1922).

Depth in RNNs. It is also easy to stack multiple RNNs—simply use the h(t)\mathbf{h}^{(t)} vectors as an input sequence for a second RNN. This kind of construction is occasionally called a “deep RNN”, which is potentially misleading. Effectively, due to the repeated application of the recurrent operation, even a single RNN “layer” has depth equal to the number of input steps.

This often introduces uniquely challenging learning dynamics when optimising RNNs, as each training example induces many gradient updates to the shared parameters of the update network. Here we will focus on perhaps the most prominent such issue—that of vanishing and exploding gradients (Bengio et al., 1994)—which is especially problematic in RNNs, given their depth and parameter sharing. Further, it has single-handedly spurred some of the most influential research on RNNs. For a more detailed overview, we refer the reader to Pascanu et al. (2013), who have studied the training dynamics of RNNs in great detail, and exposed these challenges from a variety of perspectives: analytical, geometrical, and the lens of dynamical systems.

To illustrate vanishing gradients, consider a SimpleRNN with a sigmoidal activation function σ\sigma, whose derivative magnitude ∣σ′∣|\sigma'| is always between 00 and 11. Multiplying many such values results in gradients that quickly tend to zero, implying that early steps in the input sequence may not be able to have influence in updating the network parameters at all.

(Figure not in the corpus: sigmoid.pdf.) \ Examples of such an activation include the logistic function, σ(x)=11+exp⁡(−x)\sigma(x) = \frac{1}{1+\exp(-x)}, and the hyperbolic tangent, σ(x)=tanh⁡x\sigma(x)=\tanh x. They are called sigmoidal due to the distinct S-shape of their plots.

For example, consider the next‐word prediction task (common in e.g. predictive keyboards), and the input text “Petar is Serbian. He was born on … [long paragraph] … Petar currently lives in _____”. Here, predicting the next word as “Serbia” may only be reasonably concluded by considering the very start of the paragraph—but gradients have likely vanished by the time they reach this input step, making learning from such examples very challenging.

Deep feedforward neural networks have also suffered from the vanishing gradient problem, until the invention of the ReLU activation (which has gradients equal to exactly zero or one—thus fixing the vanishing gradient problem). However, in RNNs, using ReLUs may easily lead to exploding gradients, as the output space of the update function is now unbounded, and gradient descent will update the cell once for every input step, quickly building up the scale of the updates. Historically, the vanishing gradient phenomenon was recognised early on as a significant obstacle in the use of recurrent networks. Coping with this problem motivated the development of more sophisticated RNN layers, which we describe next.

Figure 20: The dataflow of the long short-term memory (LSTM), with its components and memory cell (MM) clearly highlighted. Based on the current input z(t)\mathbf{z}^{(t)}, previous summary h(t−1)\mathbf{h}^{(t-1)} and previous cell state c(t−1)\mathbf{c}^{(t-1)}, the LSTM predicts the updated cell state c(t)\mathbf{c}^{(t)} and summary h(t)\mathbf{h}^{(t)}. (Figure not in the corpus: lstm.pdf.)

A key invention that significantly reduced the effects of vanishing gradients in RNNs is that of gating mechanisms, which allow the network to selectively overwrite information in a data-driven way. Prominent examples of these gated RNNs include the Long Short-Term Memory (LSTM; Hochreiter and Schmidhuber (1997)) and the Gated Recurrent Unit (GRU; Cho et al. (2014)). Here we will primarily discuss the LSTM—specifically, the variant presented by Graves (2013)—in order to illustrate the operations of such models. Concepts from LSTMs easily carry over to other gated RNNs.

Throughout this section, it will likely be useful to refer to Figure 20, which illustrates all of the LSTM operations that we will discuss in text.

The LSTM augments the recurrent computation by introducing a memory cell, which stores cell state vectors, c(t)∈Rm\mathbf{c}^{(t)}\in\mathbb{R}^m, that are preserved between computational steps. The LSTM computes summary vectors, h(t)\mathbf{h}^{(t)}, directly based on c(t)\mathbf{c}^{(t)}, and c(t)\mathbf{c}^{(t)} is, in turn, computed using z(t)\mathbf{z}^{(t)}, h(t−1)\mathbf{h}^{(t-1)} and c(t−1)\mathbf{c}^{(t-1)}. Critically, the cell is not completely overwritten based on z(t)\mathbf{z}^{(t)} and h(t−1)\mathbf{h}^{(t-1)}, which would expose the network to the same issues as the SimpleRNN. Instead, a certain quantity of the previous cell state may be retained—and the proportion by which this occurs is explicitly learned from data.

Just like in SimpleRNN, we compute features by using a single fully-connected neural network layer over the current input step and previous summary:

Note that we have set the activation function to tanh⁡\tanh here; as LSTMs are designed to ameliorate the vanishing gradient problem, it is now appropriate to use a sigmoidal activation.

c~(t)=tanh⁡(Wcz(t)+Uch(t−1)+bc)(43)\widetilde{\mathbf{c}}^{(t)} = \tanh(\mathbf{W}_c\mathbf{z}^{(t)} + \mathbf{U}_c\mathbf{h}^{(t-1)} + \mathbf{b}_c) \tag{43}

But, as mentioned, we do not allow all of this vector to enter the cell—hence why we call it the vector of candidate features, and denote it as c~(t)\widetilde{\mathbf{c}}^{(t)}. Instead, the LSTM directly learns gating vectors, which are real-valued vectors in the range [0,1][0, 1], and decide how much of the signal should be allowed to enter, exit, and overwrite the memory cell.

Three such gates are computed, all based on z(t)\mathbf{z}^{(t)} and h(t−1)\mathbf{h}^{(t-1)}: the input gate i(t)\mathbf{i}^{(t)}, which computes the proportion of the candidate vector allowed to enter the cell; the forget gate f(t)\mathbf{f}^{(t)}, which computes the proportion of the previous cell state to be retained, and the output gate o(t)\mathbf{o}^{(t)}, which computes the proportion of the new cell state to be used for the final summary vector. Typically all of these gates are also derived using a single fully connected layer, albeit with the logistic sigmoid activation logistic(x)=11+exp⁡(−x)\mathrm{logistic}(x) = \frac{1}{1+\exp(-x)}, in order to guarantee that the outputs are in the [0,1][0, 1] range:

Note that the three gates are themselves vectors, i.e. i(t),f(t),o(t)∈[0,1]m\mathbf{i}^{(t)}, \mathbf{f}^{(t)}, \mathbf{o}^{(t)}\in [0,1]^m. This allows them to control how much each of the mm dimensions is allowed through the gate.

i(t)=logistic(Wiz(t)+Uih(t−1)+bi)(44)\mathbf{i}^{(t)} = \mathrm{logistic}(\mathbf{W}_\mathrm{i}\mathbf{z}^{(t)} + \mathbf{U}_\mathrm{i}\mathbf{h}^{(t-1)} + \mathbf{b}_\mathrm{i}) \tag{44} f(t)=logistic(Wfz(t)+Ufh(t−1)+bf)(45)\mathbf{f}^{(t)} = \mathrm{logistic}(\mathbf{W}_\mathrm{f}\mathbf{z}^{(t)} + \mathbf{U}_\mathrm{f}\mathbf{h}^{(t-1)} + \mathbf{b}_\mathrm{f}) \tag{45} o(t)=logistic(Woz(t)+Uoh(t−1)+bo)(46)\mathbf{o}^{(t)} = \mathrm{logistic}(\mathbf{W}_\mathrm{o}\mathbf{z}^{(t)} + \mathbf{U}_\mathrm{o}\mathbf{h}^{(t-1)} + \mathbf{b}_\mathrm{o}) \tag{46}

Finally, these gates are appropriately applied to decode the new cell state, c(t)\mathbf{c}^{(t)}, which is then modulated by the output gate to produce the summary vector h(t)\mathbf{h}^{(t)}, as follows:

c(t)=i(t)⊙c~(t)+f(t)⊙c(t−1)(47)\mathbf{c}^{(t)} = \mathbf{i}^{(t)}\odot\widetilde{\mathbf{c}}^{(t)} + \mathbf{f}^{(t)}\odot\mathbf{c}^{(t-1)} \tag{47} h(t)=o(t)⊙tanh⁡(c(t))(48)\mathbf{h}^{(t)} = \mathbf{o}^{(t)}\odot\tanh(\mathbf{c}^{(t)}) \tag{48}

where ⊙\odot is element-wise vector multiplication. Applied together, Equations (46)–(51) completely specify the update rule for the LSTM, which now takes into account the cell vector c(t)\mathbf{c}^{(t)} as well:

(h(t),c(t))=R(z(t),(h(t−1),c(t−1)))(\mathbf{h}^{(t)}, \mathbf{c}^{(t)}) = R(\mathbf{z}^{(t)}, (\mathbf{h}^{(t-1)}, \mathbf{c}^{(t-1)}))

Note that, as the values of f(t)\mathbf{f}^{(t)} are derived from z(t)\mathbf{z}^{(t)} and h(t−1)\mathbf{h}^{(t-1)}—and therefore directly learnable from data—the LSTM effectively learns how to appropriately forget past experiences. Indeed, the values of f(t)\mathbf{f}^{(t)} directly appear in the backpropagation update for all the LSTM parameters (W∗,U∗,b∗\mathbf{W}_*, \mathbf{U}_*, \mathbf{b}_*), allowing the network to explicitly control, in a data-driven way, the degree of vanishing for the gradients across the time steps.

This is still compatible with the RNN update blueprint from Equation (41); simply consider the summary vector to be the concatenation of h(t)\mathbf{h}^{(t)} and c(t)\mathbf{c}^{(t)}; sometimes denoted by h(t)∥c(t)\mathbf{h}^{(t)}\|\mathbf{c}^{(t)}.

Besides tackling the vanishing gradient issue head-on, it turns out that gated RNNs also unlock a very useful form of invariance to time-warping transformations, which remains out of reach of SimpleRNNs.

Time warping invariance of gated RNNs. We will start by illustrating, in a continuous-time setting, what does it mean to warp time, and what is required of a recurrent model in order to achieve invariance to such transformations. Our exposition will largely follow the work of Tallec and Ollivier (2018), that initially described this phenomenon—and indeed, they were among the first to actually study RNNs from the lens of invariances.

We focus on the continuous setting as it will be easier to reason about manipulations of time there.

Let us assume a continuous time-domain signal z(t)z(t), on which we would like to apply an RNN. To align the RNN’s discrete-time computation of summary vectors h(t)\mathbf{h}^{(t)} with an analogue in the continuous domain, h(t)h(t), we will observe its linear Taylor expansion:

We will use h(t)h(t) to denote a continuous signal at time tt, and h(t)\mathbf{h}^{(t)} to denote a discrete signal at time-step tt.

h(t+δ)≈h(t)+δdh(t)dt(49)h(t + \delta) \approx h(t) + \delta\frac{\mathrm{d}h(t)}{\mathrm{d}t} \tag{49}

and, setting δ=1\delta = 1, we recover a relationship between h(t)h(t) and h(t+1)h(t+1), which is exactly what the RNN update function RR (Equation 41) computes. Namely, the RNN update function satisfies the following differential equation:

dh(t)dt=h(t+1)−h(t)=R(z(t+1),h(t))−h(t)(50)\frac{\mathrm{d}h(t)}{\mathrm{d}t} = h(t+1) - h(t) = R(z(t+1), h(t)) - h(t) \tag{50}

We would like the RNN to be resilient to the way in which the signal is sampled (e.g. by changing the time unit of measurement), in order to account for any imperfections or irregularities therein. Formally, we denote a time warping operation τ:R+→R+\tau : \mathbb{R}^+\rightarrow\mathbb{R}^+, as any monotonically increasing differentiable mapping between times. The notation τ\tau is chosen because time warping represents an automorphism of time.

gdl-fig-time-warping-waveforms.png

\ Such warping operations can be simple, such as time rescaling; e.g. τ(t)=0.7t\tau(t) = 0.7t (displayed above), which, in a discrete setting, would amount to new inputs being received every ∼1.43\sim 1.43 steps. However, it also admits a wide spectrum of variably-changing sampling rates, e.g. sampling may freely accelerate or decelerate throughout the time domain.

Further, we state that a class of models is invariant to time warping if, for any model of the class and any such τ\tau, there exists another (possibly the same) model from the class that processes the warped data in the same way as the original model did in the non-warped case.

This is a potentially very useful property. If we have an RNN class capable of modelling short-term dependencies well, and we can also show that this class is invariant to time warping, then we know it is possible to train such a model in a way that will usefully capture long-term dependencies as well (as they would correspond to a time dilation warping of a signal with short-term dependencies). As we will shortly see, it is no coincidence that gated RNN models such as the LSTM were proposed to model long-range dependencies. Achieving time warping invariance is tightly coupled with presence of gating mechanisms, such as the input/forget/output gates of LSTMs.

When time gets warped by τ\tau, the signal observed by the RNN at time tt is z(τ(t))z(\tau(t)) and, to remain invariant to such warpings, it should predict an equivalently-warped summary function h(τ(t))h(\tau(t)). Using Taylor expansion arguments once more, we derive a form of Equation 53 for the warped time, that the RNN update RR should satisfy:

dh(τ(t))dτ(t)=R(z(τ(t+1)),h(τ(t)))−h(τ(t))(51)\frac{\mathrm{d}h(\tau(t))}{\mathrm{d}\tau(t)} = R(z(\tau(t+1)), h(\tau(t))) - h(\tau(t)) \tag{51}

However, the above derivative is computed with respect to the warped time τ(t)\tau(t), and hence does not take into account the original signal. To make our model take into account the warping transformation explicitly, we need to differentiate the warped summary function with respect to tt. Applying the chain rule, this yields the following differential equation:

dh(τ(t))dt=dh(τ(t))dτ(t)dτ(t)dt=dτ(t)dtR(z(τ(t+1)),h(τ(t)))−dτ(t)dth(τ(t))(52)\frac{\mathrm{d}h(\tau(t))}{\mathrm{d}t} = \frac{\mathrm{d}h(\tau(t))}{\mathrm{d}\tau(t)}\frac{\mathrm{d}\tau(t)}{\mathrm{d}t} = \frac{\mathrm{d}\tau(t)}{\mathrm{d}t}R(z(\tau(t+1)), h(\tau(t))) - \frac{\mathrm{d}\tau(t)}{\mathrm{d}t}h(\tau(t)) \tag{52}

and, for our (continuous-time) RNN to remain invariant to any time warping τ(t)\tau(t), it needs to be able to explicitly represent the derivative dτ(t)dt\frac{\mathrm{d}\tau(t)}{\mathrm{d}t}, which is not assumed known upfront! We need to introduce a learnable function Γ\Gamma which approximates this derivative. For example, Γ\Gamma could be a neural network taking into account z(t+1)z(t+1) and h(t)h(t) and predicting scalar outputs.

Now, remark that, from the point of view of a discrete RNN model under time warping, its input z(t)\mathbf{z}^{(t)} will correspond to z(τ(t))z(\tau(t)), and its summary h(t)\mathbf{h}^{(t)} will correspond to h(τ(t))h(\tau(t)). To obtain the required relationship of h(t)\mathbf{h}^{(t)} to h(t+1)\mathbf{h}^{(t+1)} in order to remain invariant to time warping, we will use a one-step Taylor expansion of h(τ(t))h(\tau(t)):

h(τ(t+δ))≈h(τ(t))+δdh(τ(t))dth(\tau(t + \delta)) \approx h(\tau(t)) + \delta\frac{\mathrm{d}h(\tau(t))}{\mathrm{d}t}

and, once again, setting δ=1\delta=1 and substituting Equation 55, then discretising:

h(t+1)=h(t)+dτ(t)dtR(z(t+1),h(t))−dτ(t)dth(t)=dτ(t)dtR(z(t+1),h(t))+(1−dτ(t)dt)h(t)\begin{aligned}\mathbf{h}^{(t+1)} &= \mathbf{h}^{(t)} + \frac{\mathrm{d}\tau(t)}{\mathrm{d}t}R(\mathbf{z}^{(t+1)}, \mathbf{h}^{(t)}) - \frac{\mathrm{d}\tau(t)}{\mathrm{d}t}\mathbf{h}^{(t)}\\ &= \frac{\mathrm{d}\tau(t)}{\mathrm{d}t}R(\mathbf{z}^{(t+1)}, \mathbf{h}^{(t)}) + \left(1 - \frac{\mathrm{d}\tau(t)}{\mathrm{d}t}\right)\mathbf{h}^{(t)}\end{aligned}

Finally, we swap dτ(t)dt\frac{\mathrm{d}\tau(t)}{\mathrm{d}t} with the aforementioned learnable function, Γ\Gamma. This gives us the required form for our time warping-invariant RNN:

h(t+1)=Γ(z(t+1),h(t))R(z(t+1),h(t))+(1−Γ(z(t+1),h(t)))h(t)(53)\mathbf{h}^{(t+1)} = \Gamma(\mathbf{z}^{(t+1)}, \mathbf{h}^{(t)})R(\mathbf{z}^{(t+1)}, \mathbf{h}^{(t)}) + (1 - \Gamma(\mathbf{z}^{(t+1)}, \mathbf{h}^{(t)}))\mathbf{h}^{(t)} \tag{53}

We may quickly deduce that SimpleRNNs (Equation 42) are not time warping invariant, given that they do not feature the second term in Equation 56. Instead, they fully overwrite h(t)\mathbf{h}^{(t)} with R(z(t+1),h(t))R(\mathbf{z}^{(t+1)}, \mathbf{h}^{(t)}), which corresponds to assuming no time warping at all; dτ(t)dt=1\frac{\mathrm{d}\tau(t)}{\mathrm{d}t} = 1, i.e. τ(t)=t\tau(t) = t.

Further, our link between continuous-time RNNs and the discrete RNN based on RR rested on the accuracy of the Taylor approximation, which holds only if the time-warping derivative is not too large, i.e., dτ(t)dt≲1\frac{\mathrm{d}\tau(t)}{\mathrm{d}t}\lesssim 1. The intuitive explanation of this is: if our time warping operation ever contracts time in a way that makes time increments (t→t+1t \rightarrow t + 1) large enough that intermediate data changes are not sampled, the model can never hope to process time-warped inputs in the same way as original ones—it simply would not have access to the same information. Conversely, time dilations of any form (which, in discrete terms, correspond to interspersing the input time-series with zeroes) are perfectly allowed within our framework.

Combined with our requirement of monotonically increasing τ\tau (dτ(t)dt>0\frac{\mathrm{d}\tau(t)}{\mathrm{d}t} > 0), we can bound the output space of Γ\Gamma as 0<Γ(z(t+1),h(t))<10 < \Gamma(\mathbf{z}^{(t+1)}, \mathbf{h}^{(t)}) < 1, which motivates the use of the logistic sigmoid activation for Γ\Gamma, e.g.:

Γ(z(t+1),h(t))=logistic(WΓz(t+1)+UΓh(t)+bΓ)\Gamma(\mathbf{z}^{(t+1)}, \mathbf{h}^{(t)}) = \mathrm{logistic}({\bf W}_\Gamma\mathbf{z}^{(t+1)} + {\bf U}_\Gamma\mathbf{h}^{(t)} + \mathbf{b}_\Gamma)

exactly matching the LSTM gating equations (e.g. Equation 47). The main difference is that LSTMs compute gating vectors, whereas Equation 56 implies Γ\Gamma should output a scalar. Vectorised gates (Hochreiter, 1991) allow to fit a different warping derivative in every dimension of h(t)\mathbf{h}^{(t)}, allowing for reasoning over multiple time horizons simultaneously.

It is worth taking a pause here to summarise what we have done. By requiring that our RNN class is invariant to (non-destructive) time warping, we have derived the necessary form that it must have (Equation 56), and showed that it exactly corresponds to the class of gated RNNs. The gates’ primary role under this perspective is to accurately fit the derivative dτ(t)dt\frac{\mathrm{d}\tau(t)}{\mathrm{d}t} of the warping transformation.

The notion of class invariance is somewhat distinct from the invariances we studied previously. Namely, once we train a gated RNN on a time-warped input with τ1(t)\tau_1(t), we typically cannot zero-shot transfer it to a signal warped by a different τ2(t)\tau_2(t). Rather, class invariance only guarantees that gated RNNs are powerful enough to fit both of these signals in the same manner, but potentially with vastly different model parameters. That being said, the realisation that effective gating mechanisms are tightly related to fitting the warping derivative can yield useful prescriptions for gated RNN optimisation, as we now briefly demonstrate.

One case where zero-shot transfer is possible is when the second time warping is assumed to be a time rescaling of the first one (τ2(t)=ατ1(t)\tau_2(t) = \alpha\tau_1(t)). Transferring a gated RNN pre-trained on τ1\tau_1 to a signal warped by τ2\tau_2 merely requires rescaling the gates: Γ2(z(t+1),h(t))=αΓ1(z(t+1),h(t))\Gamma_2(\mathbf{z}^{(t+1)}, \mathbf{h}^{(t)}) = \alpha \Gamma_1(\mathbf{z}^{(t+1)}, \mathbf{h}^{(t)}). RR can retain its parameters (R1=R2R_1 = R_2).

For example, we can often assume that the range of the dependencies we are interested in tracking within our signal will be in the range [Tl,Th][T_l, T_h] time-steps.

By analysing the analytic solutions to Equation 55, it can be shown that the characteristic forgetting time of h(t)\mathbf{h}^{(t)} by our gated RNN is proportional to 1Γ(z(t+1),h(t))\frac{1}{\Gamma(\mathbf{z}^{(t+1)}, \mathbf{h}^{(t)})}. Hence, we would like our gating values to lie between [1Th,1Tm]\left[\frac{1}{T_h}, \frac{1}{T_m}\right] in order to effectively remember information within the assumed range.

Further, if we assume that z(t)\mathbf{z}^{(t)} and h(t)\mathbf{h}^{(t)} are roughly zero-centered—which is a common by-product of applying transformations such as layer normalisation (Ba et al., 2016)—we can assume that E[Γ(z(t+1),h(t))]≈logistic(bΓ)\mathbb{E}[\Gamma(\mathbf{z}^{(t+1)}, \mathbf{h}^{(t)})] \approx \mathrm{logistic}(\mathbf{b}_\Gamma). Controlling the bias vector of the gating mechanism is hence a very powerful way of controlling the effective gate value.

This insight was already spotted by Gers and Schmidhuber (2000); Jozefowicz et al. (2015), who empirically recommended initialising the forget-gate bias of LSTMs to a constant positive vector, such as 1\mathbf{1}.

Combining the two observations, we conclude that an appropriate range of gating values can be obtained by initialising bΓ∼−log⁡(U(Tl,Th)−1)\mathbf{b}_\Gamma\sim-\log(\mathcal{U}(T_l, T_h) - 1), where U\mathcal{U} is the uniform real distribution. Such a recommendation was dubbed chrono initialisation by Tallec and Ollivier (2018), and has been empirically shown to improve the long-range dependency modelling of gated RNNs.

Sequence-to-sequence learning with RNNs. One prominent historical example of using RNN-backed computation are sequence-to-sequence translation tasks, such as machine translation of natural languages. The pioneering seq2seq work by Sutskever et al. (2014) achieved this by passing the summary vector, h(T)\mathbf{h}^{(T)} as an initial input for a decoder RNN, with outputs of RNN blocks being given as inputs for the next step.

Figure 21: One typical example of a seq2seq architecture with an RNN encoder RencR_\mathrm{enc} and RNN decoder RdecR_\mathrm{dec}. The decoder is seeded with the final summary vector h(T)\mathbf{h}^{(T)} coming out of the encoder, and then proceeds in an autoregressive fashion: at each step, the predicted output from the previous step is fed back as input to RdecR_\mathrm{dec}. The bottleneck problem is also illustrated with the red lines: the summary vector h(T)\mathbf{h}^{(T)} is pressured to store all relevant information for translating the input sequence, which becomes increasingly challenging as the input length grows. (Figure not in the corpus: bottle_rnn.pdf.)

This placed substantial representational pressure on the summary vector, h(T)\mathbf{h}^{(T)}. Within the context of deep learning, h(T)\mathbf{h}^{(T)} is sometimes referred to as a bottleneck. Its fixed capacity must be sufficient for representing the content of the entire input sequence, in a manner that is conducive to generating a corresponding sequence, while also supporting input sequences of substantially different lengths (Figure 21).

gdl-fig-bottleneck-effect.png

The bottleneck effect has recently received substantial attention in the graph representation learning community (Alon and Yahav, 2020), as well as neural algorithmic reasoning (Cappart et al., 2021).

In reality, different steps of the output may wish to focus (attend) on different parts of the input, and all such choices are difficult to represent via a bottleneck vector. Following from this observation, the popular recurrent attention model was proposed by Bahdanau et al. (2014). At every step of processing, a query vector is generated by an RNN; this query vector then interacts with the representation of every time-step h(t)\mathbf{h}^{(t)}, primarily by computing a weighted sum over them. This model pioneered neural content-based attention and predates the success of the Transformer model.

Lastly, while attending offers a soft way to dynamically focus on parts of the input content, substantial work also learnt more explicit ways to direct attention to the input. A powerful algorithmically grounded way of doing so is the pointer network of Vinyals et al. (2015), which proposes a simple modification of recurrent attention to allow for pointing over elements of variable-sized inputs. These findings have then been generalised to the set2set architecture (Vinyals et al., 2016), which generalises seq2seq models to unordered sets, supported by pointer network-backed LSTMs.