SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Isay Katsman*
isay.katsman@yale.edu
Eric M. Chen*, Sidhanth Holalkere*
{emc348, sh844}@cornell.edu
Anna Asch
aca89@cornell.edu
Aaron Lou
aaronlou@stanford.edu
Ser-Nam  $\mathbf{Lim}^{\dagger}$
sernam@ucf.edu
Recent methods in geometric deep learning have introduced various neural networks to operate over data that lie on Riemannian manifolds. Such networks are often necessary to learn well over graphs with a hierarchical structure or to learn over manifold-valued data encountered in the natural sciences. These networks are often inspired by and directly generalize standard Euclidean neural networks. However, extending Euclidean networks is difficult and has only been done for a select few manifolds. In this work, we examine the residual neural network (ResNet) and show how to extend this construction to general Riemannian manifolds in a geometrically principled manner. Originally introduced to help solve the vanishing gradient problem, ResNets have become ubiquitous in machine learning due to their beneficial learning properties, excellent empirical results, and easy-to-incorporate nature when building varied neural networks. We find that our Riemannian ResNets mirror these desirable properties: when compared to existing manifold neural networks designed to learn over hyperbolic space and the manifold of symmetric positive definite matrices, we outperform both kinds of networks in terms of relevant testing metrics and training dynamics.
In machine learning, it is common to represent data as vectors in Euclidean space (i.e.  $\mathbb{R}^n$ ). The primary reason for such a choice is convenience, as this space has a classical vectorial structure, a closed-form distance formula, and a simple inner-product computation. Moreover, the myriad existing Euclidean neural network constructions enable performant learning.
Despite the ubiquity and success of Euclidean embeddings, recent research [41] has brought attention to the fact that several kinds of complex data require manifold considerations. Such data are various and range from covariance matrices, represented as points on the manifold of symmetric positive definite (SPD) matrices [26], to angular orientations, represented as points on tori, found in the context of robotics [43]. However, generalizing Euclidean neural network tools to manifold structures such as these can be quite difficult in practice. Most prior works design network architectures for a specific manifold [11, 17], thereby inefficiently necessitating a specific design for each new manifold.
We address this issue by extending Residual Neural Networks [23] to Riemannian manifolds in a way that naturally captures the underlying geometry. We construct our network by parameterizing vector fields and leveraging geodesic structure (provided by the Riemannian exp map) to "add" the learned
* indicates equal contribution.
$\dagger$  Work done while at Meta AI.
vectors to the input points, thereby naturally generalizing a typical Euclidean residual addition. This process is illustrated in Figure 1. Note that this strategy is exceptionally natural, only making use of inherent geodesic geometry, and works generally for all smooth manifolds. We refer to such networks as Riemannian residual neural networks.
Though the above approach is principled, it is underspecified, as constructing an efficient learnable vector field for a given manifold is often nontrivial. To resolve this issue, we present a general way to induce a learnable vector field for a manifold  $\mathcal{M}$  given only a map  $f:\mathcal{M}\to \mathbb{R}^k$ . Ideally, this map should capture intrinsic manifold geometry. For example, in the context of Euclidean space, this map could consist of a series of  $k$  projections onto hyperplanes. There is a natural equivalent of this in hyperbolic space that instead projects to horospheres (horospheres correspond to hyperplanes in Euclidean space). More generally, we propose a feature map that once more relies only on geodesic information, consisting of projection to random (or learned) geodesic balls. This final approach provides a fully geometric way to construct vector fields, and therefore natural residual networks, for any Riemannian manifold.
After introducing our general theory, we give concrete manifestations of vector fields, and therefore
residual neural networks, for hyperbolic space and the manifold of SPD matrices. We compare the performance of our Riemannian residual neural networks to that of existing manifold-specific networks on hyperbolic space and on the manifold of SPD matrices, showing that our networks perform much better in terms of relevant metrics due to their improved adherence to manifold geometry.
Figure 1: An illustration of a manifoldgeneralized residual addition. The traditional Euclidean formula  $p\gets p + v$  is generalized to  $p\gets \exp_p(v)$  , where exp is the Riemannian exponential map.  $\mathcal{M}$  is the manifold and  $T_{p}\mathcal{M}$  is the tangent space at  $p$
1. We introduce a novel and principled generalization of residual neural networks to general Riemannian manifolds. Our construction relies only on knowledge of geodesics, which capture manifold geometry.
2. Theoretically, we show that our methodology better captures manifold geometry than pre-existing manifold-specific neural network constructions. Empirically, we apply our general construction to hyperbolic space and to the manifold of SPD matrices. On various hyperbolic graph datasets (where hyperbolicity is measured by Gromov  $\delta$ -hyperbolicity) our method considerably outperforms existing work on both link prediction and node classification tasks. On various SPD covariance matrix classification datasets, a similar conclusion holds.
3. Our method provides a way to directly vary the geometry of a given neural network without having to construct particular operations on a per-manifold basis. This provides the novel capability to directly compare the effect of geometric representation (in particular, evaluating the difference between a given Riemannian manifold  $(\mathcal{M},g)$  and Euclidean space  $(\mathbb{R}^n,||\cdot ||_2))$  while fixing the network architecture.
Our work is related to but distinctly different from existing neural ordinary differential equation (ODE) [9] literature as well a series of papers that have attempted generalizations of neural networks to specific manifolds such as hyperbolic space [17] and the manifold of SPD matrices [26].
2.1 Residual Networks and Neural ODEs
Residual networks (ResNets) were originally developed to enable training of larger networks, previously prone to vanishing and exploding gradients [23]. Later on, many discovered that by adding a learned residual, ResNets are similar to Euler's method [9, 21, 37, 45, 53]. More specifically, the ResNet represented by  $\mathbf{h}_{t + 1} = \mathbf{h}_t + f(\mathbf{h},\theta_t)$  for  $\mathbf{h}_t\in \mathbb{R}^D$  mimics the dynamics of the ODE defined by  $\frac{d\mathbf{h}(t)}{dt} = f(\mathbf{h}(t),t,\theta)$ . Neural ODEs are defined precisely as ODEs of this form, where
the local dynamics are given by a parameterized neural network. Similar to our work, Falorsi and Forre [15], Katsman et al. [29], Lou et al. [36], Mathieu and Nickel [38] generalize neural ODEs to Riemannian manifolds (further generalizing manifold-specific work such as Bose et al. [3], that does this for hyperbolic space). However, instead of using a manifold's vector fields to solve a neural ODE, we learn an objective by parameterizing the vector fields directly (Figure 2). Neural ODEs and their generalizations to manifolds parameterize a continuous collection of vector fields over time for a single manifold in a dynamic flow-like construction. Our method instead parameterizes a discrete collection of vector fields, entirely untethered from any notion of solving an ODE. This makes our construction a strict generalization of both neural ODEs and their manifold equivalents [15, 29, 36, 38].
2.2 Riemannian Neural Networks
Past literature has attempted generalizations of Euclidean neural networks to a number of manifolds.
Hyperbolic Space Ganea et al. [17] extended basic neural network operations (e.g. activation function, linear layer, recurrent architectures) to conform with the geometry of hyperbolic space through gyrovector constructions [51]. In particular, they use gyrovector constructions [51] to build analogues of activation functions, linear layers, and recurrent architectures. Building on this approach, Chami et al. [8] adapt these constructions to hyperbolic versions of the feature transformation and neighborhood aggregation steps found in message passing neural networks. Additionally, batch normalization for hyperbolic space was introduced in Lou et al. [35]; hyperbolic attention network equivalents were introduced in Gulçehre et al. [20]. Although gyrovector constructions are algebraic and allow for generalization of neural network operations to hyperbolic space and beyond, we note that they do not capture intrinsic geodesic geometry. In particular, we note that the gyrovector-based hyperbolic linear layer introduced in Ganea et al. [17] reduces to a Euclidean matrix multiplication followed by a learned hyperbolic bias addition (see Appendix D.2). Hence all non-Euclidean learning for this case happens through the bias term. In an attempt to resolve this, further work has focused on imbuing these neural networks with more hyperbolic functions [10, 49]. Chen et al. [10] notably constructs a hyperbolic residual layer by projecting an output onto the Lorentzian manifold. However, we emphasize that our construction is more general while being more geometrically principled as we work with fundamental manifold operations like the exponential map rather than relying on the niceties of Lorentz space.
Yu and De Sa [55] make use of randomized hyperbolic Laplacian features to learn in hyperbolic space. We note that the features learned are shallow and are constructed from a specific manifestation of the Laplace-Beltrami operator for hyperbolic space. In contrast, our method is general and enables non-shallow (i.e., multi-layer) feature learning.
SPD Manifold Neural network constructs have been extended to the manifold of symmetric positive definite (SPD) matrices as well. In particular, SPDNet [26] is an example of a widely adopted SPD manifold neural network which introduced SPD-specific layers analogous to Euclidean linear and ReLU layers. Building upon SPDNet, Brooks et al. [5] developed a batch normalization method to be used with SPD data. Additionally, López et al. [34] adapted gyrocalculus constructions used in hyperbolic space to the SPD manifold.
Symmetric Spaces Further work attempts generalization to symmetric spaces. Sonoda et al. [50] design fully-connected networks over noncompact symmetric spaces using particular theory from Helgason-Fourier analysis [25], and Chakraborty et al. [7] attempt to generalize several operations such as convolution to such spaces by adapting and developing a weighted Fréchet mean construction. We note that the Helgason-Fourier construction in Sonoda et al. [50] exploits a fairly particular structure, while the weighted Fréchet mean construction in Chakraborty et al. [7] is specifically introduced for convolution, which is not the focus of our work (we focus on residual connections).
Unlike any of the manifold-specific work described above, our residual network construction can be applied generally to any smooth manifold and is constructed solely from geodesic information.
In this section, we cover the necessary background for our paper; in particular, we introduce the reader to the necessary constructs from Riemannian geometry. For a detailed introduction to Riemannian geometry, we refer the interested reader to textbooks such as Lee [32].
Figure 2: A visualization of a Riemannian residual neural network on a manifold  $\mathcal{M}$ . Our model parameterizes vector fields on a manifold. At each layer in our network, we take a step from a point in the direction of that vector field (brown), which is analogous to the residual step in a ResNet.
3.1 Riemannian Geometry
A topological manifold  $(\mathcal{M},g)$  of dimension  $n$  is a locally Euclidean space, meaning there exist homeomorphic functions (called "charts") whose domains both cover the manifold and map from the manifold into  $\mathbb{R}^n$  (i.e. the manifold "looks like"  $\mathbb{R}^n$  locally). A smooth manifold is a topological manifold for which the charts are not simply homeomorphic, but diffeomorphic, meaning they are smooth bijections mapping into  $\mathbb{R}^n$  and have smooth inverses. We denote  $T_{p}\mathcal{M}$  as the tangent space at a point  $p$  of the manifold  $\mathcal{M}$ . Further still, a Riemannian manifold $^2$ $(\mathcal{M},g)$  is an  $n$ -dimensional smooth manifold with a smooth collection of inner products  $(g_p)_{p\in \mathcal{M}}$  for every tangent space  $T_{p}\mathcal{M}$ . The Riemannian metric  $g$  induces a distance  $d_g:\mathcal{M}\times \mathcal{M}\to \mathbb{R}$  on the manifold.
3.2 Geodesics and the Riemannian Exponential Map
Geodesics A geodesic is a curve of minimal length between two points  $p, q \in \mathcal{M}$ , and can be seen as the generalization of a straight line in Euclidean space. Although a choice of Riemannian metric  $g$  on  $\mathcal{M}$  appears to only define geometry locally on  $\mathcal{M}$ , it induces global distances by integrating the length (of the "speed" vector in the tangent space) of a shortest path between two points:
$$
d (p, q) = \inf  _ {\gamma} \int_ {0} ^ {1} \sqrt {g _ {\gamma (t)} \left(\gamma^ {\prime} (t) , \gamma^ {\prime} (t)\right)} d t \tag {1}
$$
where  $\gamma \in C^{\infty}([0,1],\mathcal{M})$  is such that  $\gamma (0) = p$  and  $\gamma (1) = q$
For  $p \in \mathcal{M}$  and  $v \in T_p\mathcal{M}$ , there exists a unique geodesic  $\gamma_v$  where  $\gamma(0) = p$ ,  $\gamma'(0) = v$  and the domain of  $\gamma$  is as large as possible. We call  $\gamma_v$  the maximal geodesic [32].
Exponential Map The Riemannian exponential map is a way to map  $T_{p}\mathcal{M}$  to a neighborhood around  $p$  using geodesics. The relationship between the tangent space and the exponential map output can be thought of as a local linearization, meaning that we can perform typical Euclidean operations in the tangent space before projecting to the manifold via the exponential map to capture the local on-manifold behavior corresponding to the tangent space operations. For  $p \in \mathcal{M}$  and  $v \in T_{p}\mathcal{M}$ , the exponential map at  $p$  is defined as  $\exp_p(v) = \gamma_v(1)$ .
One can think of exp as a manifold generalization of Euclidean addition, since in the Euclidean case we have  $\exp_p(v) = p + v$ .
${}^{1}$  A homeomorphism is a continuous bijection with continuous inverse.
Note that imposing Riemannian structure does not considerably limit the generality of our method, as any smooth manifold that is Hausdorff and second countable has a Riemannian metric [32].
Figure 3: An overview of our generalized Riemannian Residual Neural Network (RResNet) methodology. We start by mapping  $x^{(0)} \in \mathcal{M}^{(0)}$  to  $\chi^{(1)} \in \mathcal{M}^{(1)}$  using a base point mapping  $h_1$ . Then, using our paramterized vector field  $\ell_i$ , we compute a residual  $v^{(1)} \coloneqq \ell_1(\chi^{(1)})$ . Finally, we project  $v^{(1)}$  back onto the manifold using the Riemannian exp map, leaving us with  $x^{(1)}$ . This procedure can be iterated to produce a multi-layer Riemannian residual neural network that is capable of changing manifold representation on a per layer basis.
3.3 Vector Fields
Let  $T_{p}\mathcal{M}$  be the tangent space to a manifold  $\mathcal{M}$  at a point  $p$ . Like in Euclidean space, a vector field assigns to each point  $p \in \mathcal{M}$  a tangent vector  $X_{p} \in T_{p}\mathcal{M}$ . A smooth vector field assigns a tangent vector  $X_{p} \in T_{p}\mathcal{M}$  to each point  $p \in \mathcal{M}$  such that  $X_{p}$  varies smoothly in  $p$ .
Tangent Bundle The tangent bundle of a smooth manifold  $\mathcal{M}$  is the disjoint union of the tangent spaces  $T_{p}\mathcal{M}$ , for all  $p\in \mathcal{M}$ , denoted by  $T\mathcal{M}:= \bigsqcup_{p\in \mathcal{M}}T_p\mathcal{M} = \bigsqcup_{p\in \mathcal{M}}\{(p,v)\mid v\in T_p\mathcal{M}\}$ .
Pushforward A derivative (also called a pushforward) of a map  $f: \mathcal{M} \to \mathcal{N}$  between two manifolds is denoted by  $D_{p}f: T_{p}\mathcal{M} \to T_{f(p)}\mathcal{N}$ . This is a generalization of the classical Euclidean Jacobian (since  $\mathbb{R}^n$  is a manifold), and provides a way to relate tangent spaces at different points on different manifolds.
Pullback Given  $\phi : \mathcal{M} \to \mathcal{N}$  a smooth map between manifolds and  $f : \mathcal{N} \to \mathbb{R}$  a smooth function, the pullback of  $f$  by  $\phi$  is the smooth function  $\phi^* f$  on  $\mathcal{M}$  defined by  $(\phi^* f)(x) = f(\phi(x))$ . When the map  $\phi$  is implicit, we simply write  $f^*$  to mean the pullback of  $f$  by  $\phi$ .
3.4 Model Spaces in Riemannian Geometry
The three Riemannian model spaces are Euclidean space  $\mathbb{R}^n$ , hyperbolic space  $\mathbb{H}^n$ , and spherical space  $\mathbb{S}^n$ , that encompass all manifolds with constant sectional curvature. Hyperbolic space manifests in several representations like the Poincaré ball, Lorentz space, and the Klein model. We use the Poincaré ball model for our Riemannian ResNet design (see Appendix A for more details on the Poincaré ball model).
3.5 SPD Manifold
Let  $SPD(n)$  be the manifold of  $n \times n$  symmetric positive definite (SPD) matrices. We recall from Gallier and Quaintance [16] that  $SPD(n)$  has a Riemannian exponential map (at the identity) equivalent to the matrix exponential. Two common metrics used for  $SPD(n)$  are the log-Euclidean metric [16], which induces a flat structure on the matrices, and the canonical affine-invariant metric [12, 42], which induces non-constant negative sectional curvature. The latter gives  $SPD(n)$  a considerably less trivial geometry than that exhibited by the Riemannian model spaces [2] (see Appendix A for more details on  $SPD(n)$ ).
In this section, we provide the technical details behind Riemannian residual neural networks.
4.1 General Construction
We define a Riemannian Residual Neural Network (RResNet) on a manifold  $\mathcal{M}$  to be a function  $f:\mathcal{M}\to \mathcal{M}$  defined by
$$
f (x) := x ^ {(m)} \tag {2}
$$
$$
x ^ {(0)} := x \tag {3}
$$
$$
x ^ {(i)} := \exp_ {x ^ {(i - 1)}} \left(\ell_ {i} \left(x ^ {(i - 1)}\right)\right) \tag {4}
$$
for  $x \in \mathcal{M}$ , where  $m$  is the number of layers and  $\ell_i: \mathcal{M} \to T\mathcal{M}$  is a neural network-parameterized vector field over  $\mathcal{M}$ . This residual network construction is visualized for the purpose of intuition in Figure 2. In practice, parameterizing a function from an abstract manifold  $\mathcal{M}$  to its tangent bundle is difficult. However, by the Whitney embedding theorem [33], we can embed  $\mathcal{M} \hookrightarrow \mathbb{R}^D$  smoothly for some dimension  $D \geq \dim \mathcal{M}$ . As such, for a standard neural network  $n_i: \mathbb{R}^D \to \mathbb{R}^D$  we can construct  $\ell_i$  by
$$
\ell_ {i} (x) := \operatorname {p r o j} _ {T _ {x} \mathcal {M}} \left(n _ {i} (x)\right) \tag {5}
$$
where we note that  $T_{x}\mathcal{M} \subset \mathbb{R}^{D}$  is a linear subspace (making the projection operator well defined). Throughout the paper we call this the embedded vector field design<sup>3</sup>. We note that this is the same construction used for defining the vector field flow in Lou et al. [36], Mathieu and Nickel [38], Rozen et al. [44].
We also extend our construction to work in settings where the underlying manifold changes from layer to layer. In particular, for a sequence of manifolds  $\mathcal{M}^{(0)},\mathcal{M}^{(1)},\ldots ,\mathcal{M}^{(m)}$  with (possibly learned) maps  $h_i:\mathcal{M}^{(i - 1)}\to \mathcal{M}^{(i)}$ , our Riemannian ResNet  $f:\mathcal{M}^{(0)}\rightarrow \mathcal{M}^{(m)}$  is given by
$$
f (x) := x ^ {(m)} \tag {6}
$$
$$
x ^ {(0)} := x \tag {7}
$$
$$
x ^ {(i)} := \exp_ {h _ {i} (x ^ {(i - 1)})} (\ell_ {i} (h _ {i} (x ^ {(i - 1)}))) \forall i \in [ m ] \tag {8}
$$
with functions  $\ell_i:\mathcal{M}^{(i)}\to T\mathcal{M}^{(i)}$  given as above. This generalization is visualized in Figure 3. In practice, our  $\mathcal{M}^{(i)}$  will be different dimensional versions of the same geometric space (e.g.  $\mathbb{H}^n$  or  $\mathbb{R}^n$  for varying  $n$ ). If the starting and ending manifolds are the same, the maps  $h_i$  will simply be standard inclusions. When the starting and ending manifolds are different, the  $h_i$  may be standard neural networks for which we project the output, or the  $h_i$  may be specially design learnable maps that respect manifold geometry. As a concrete example, our  $h_i$  for the SPD case map from an SPD matrix of one dimension to another by conjugating with a Stiefel matrix [26]. Furthermore, as shown in Appendix D, our model is equivalent to the standard ResNet when the underlying manifold is  $\mathbb{R}^n$ .
Comparison with Other Constructions We discuss how our construction compares with other methods in Appendix E, but here we briefly note that unlike other methods, our presented approach is fully general and better conforms with manifold geometry.
4.2 Feature Map-Induced Vector Field Design
Most of the difficulty in application of our general vector field construction comes from the design of the learnable vector fields  $\ell_i: \mathcal{M}^{(i)} \to T\mathcal{M}^{(i)}$ . Although we give an embedded vector field design above, it is not very principled geometrically. We would like to considerably restrict these vector fields so that their range is informed by the underlying geometry of  $\mathcal{M}$ . For this, we note that it is possible to induce a vector field  $\xi: \mathcal{M} \to T\mathcal{M}$  for a manifold  $\mathcal{M}$  with any smooth map  $f: \mathcal{M} \to \mathbb{R}^k$ . In practice, this map should capture intrinsic geometric properties of  $\mathcal{M}$  and can be viewed as a feature map, or de facto linearization of  $\mathcal{M}$ . Given an  $x \in \mathcal{M}$ , we need only pass  $x$  through  $f$  to get its feature representation in  $\mathbb{R}^k$ , then note that since:
$$
D _ {p} f: T _ {p} \mathcal {M} \to T _ {f (p)} \mathbb {R} ^ {k},
$$
we have an induced map:
$$
\left(D _ {p} f\right) ^ {*}: \left(T _ {f (p)} \mathbb {R} ^ {k}\right) ^ {*} \rightarrow \left(T _ {p} \mathcal {M}\right) ^ {*},
$$
where  $(D_{p}f)^{*}$  is the pullback of  $D_{p}f$ . Note that  $T_{p}\mathbb{R}^{k}\cong \mathbb{R}^{k}$  and  $(\mathbb{R}^k)^*\cong \mathbb{R}^k$  by the dual space isomorphism. Moreover  $(T_{p}\mathcal{M})^{*}\cong T_{p}\mathcal{M}$  by the tangent-cotangent space isomorphism [33]. Hence, we have the induced map:
$$
\left(D _ {p} f\right) _ {r} ^ {*}: \mathbb {R} ^ {k} \to T _ {p} \mathcal {M},
$$
$^3$ Ideal vector field design is in general nontrivial and the embedded vector field is not a good choice for all manifolds (see Appendix B).
obtained from  $(D_{p}f)^{*}$ , simply by both precomposing and postcomposing the aforementioned isomorphisms, where relevant.  $(\bar{D}_{p}f)_{r}^{*}$  provides a natural way to map from the feature representation to the tangent bundle. Thus, we may view the map  $\ell_f:\mathcal{M}\to T\mathcal{M}$  given by:
$$
\ell_ {f} (x) = \left(D _ {x} f\right) _ {r} ^ {*} (f (x))
$$
as a deterministic vector field induced entirely by  $f$ .
Learnable Feature Map-Induced Vector Fields We can easily make the above vector field construction learnable by introducing a Euclidean neural network  $n_{\theta} : \mathbb{R}^k \to \mathbb{R}^k$  after  $f$  to obtain  $\ell_{f,\theta}(x) = (D_x f)^*(n_{\theta}(f(x)))$ .