Taming Symmetry: A Dive into Lie Groups with Python
Lie groups play a crucial role in Geometric Deep Learning by modeling symmetries such as rotation, translation, and scaling. This enables non-linear models to generalize effectively for tasks like object detection and transformations in generative models.
🎯 Introduction
🎨 Theory
Smooth Manifolds
Exponential & Logarithm Maps
Lie Groups
Lie Algebras
Geomstats
⚙️ Hands-on with Python
Environment
Special Orthogonal Group
References
What you will learn: Develop practical expertise in Lie groups and Lie algebras through hands-on exploration of the 3-dimensional Special Orthogonal (SO3) and Special Euclidean (SE3) groups.
✅ The complete article, featuring design principles, detailed implementation, in-depth analysis, and exercises, is available at Taming Symmetries: A Dive into Lie Groups
🎯 Introduction
Identifying symmetries in datasets and models is essential for analyzing complex problems and simplifying deep learning architectures.
I highly recommend that readers unfamiliar with the fundamental concepts of differential geometry and their significance in Geometric Deep Learning explore Introduction to Geometric Deep Learning [ref 1]
Lie groups are mathematical structures that combine the properties of groups and smooth manifolds, meaning they support both algebraic and differentiable operations. Named after the Norwegian mathematician Sophus Lie, these groups play a fundamental role in continuous symmetries, particularly in physics and geometry.
A Lie algebra is the tangent space at the identity element of a Lie group, equipped with a special operation called the Lie bracket, which encodes the infinitesimal structure of the group.
⚠️ A thorough tutorial and explanation of Lie groups, Lie algebras, and geometric priors for deep learning models is beyond the scope of this article. Instead, the following sections concentrate on experiments involving key elements and operations on Lie groups using the Geomstats Python library.
Key Properties:
Applicability to Machine Learning
Lie groups provide a powerful mathematical framework for encoding symmetry, invariance, and geometric structure in machine learning models.
1 Data Augmentation & Invariance
2. Geometric Deep Learning
3 Optimization & Lie Algebra Representations
4. Physics-Inspired AI
🎨 Theory
Smooth Manifolds
📌📌 I highly recommend readers to get acquainted with manifolds to browse through two previous articles
Let’ start with a brief review of the key mathematical concepts behind the Lie groups:
Differential geometry is an extensive and intricate area that exceeds what can be covered in a single article or blog post. There are numerous outstanding publications, papers and tutorials [ref 2, 3, 4] that provide foundational knowledge in differential geometry and tensor calculus, catering to both beginners and experts.
A manifold is a topological space that, around any given point, closely resembles Euclidean space. Specifically, an n-dimensional manifold is a topological space where each point is part of a neighborhood that is homeomorphic to an open subset of n-dimensional Euclidean space. Examples of manifolds include one-dimensional circles, two-dimensional planes and spheres, and the four-dimensional space-time used in general relativity.
A smooth (or differential) manifold is a topological space that locally resembles Euclidean space and allows for smooth (infinitely differentiable) transitions between local coordinate systems. This structure allows for the use of calculus on the manifold.
A Riemannian manifold is a smooth manifold that comes with a metric tensor, providing a way to measure distances and angles.
The tangent space at a point on a manifold is the set of tangent vectors at that point, like a line tangent to a circle or a plane tangent to a surface.
Tangent vectors can act as directional derivatives, where you can apply specific formulas to characterize these derivatives.
A geodesic is the shortest path (arc) between two points in a Riemannian manifold.
Exponential & Logarithm Maps
Given a Riemannian manifold M and a tangent space TM, an exponential map is a map from a subset of a tangent space of a Riemannian manifold. Given a tangent vector v at a point p on a manifold, there is a unique geodesic Gv that satisfy Gv(0)=p and G’v(0)=v. The exponential map is defined as:
For the same Riemannian manifold, given a geodesic Gv starting at point p with a direction v., the logarithm map is defined as:
The exponential and logarithm maps are illustrated below:
Lie Groups
Lie groups play a crucial role in Geometric Deep Learning by modeling symmetriessuch as rotation, translation, and scaling.
In differential geometry, a Lie group is a mathematical structure that combines the properties of both a group and a smooth manifold. It allows for the application of both algebraic and geometric techniques. As a group, it has an operation (like multiplication) that satisfies certain axioms (closure, associativity, identity, and invertibility) [ref 5, 6].
A 'real' Lie group is a set G with two structures: G is a group and G is a (smooth, real) manifold. These structures agree in the following sense multiplication (a.k.a. product or composition) and inversion are smooth maps.
A morphism of Lie groups is a smooth map which also preserves the group operation:
Example of Lie Groups
General Linear Group of invertible matrices
The General Linear Group, denoted as GL(n,R) (or GL(n,C) for complex values) is the set of all invertible n×n matrices with real entries, equipped with matrix multiplication as the group operation. It is a Lie group because it forms a smooth differentiable manifold and supports continuous transformations.
Symmetric Positive Definite Group
The Symmetric Positive Definite (SPD) Group, denoted as SPD(n), is the Lie group of all n×n real symmetric positive definite matrices. It plays a crucial role in statistics, machine learning, optimization, and Riemannian geometry.
Special Orthogonal Group
The Special Orthogonal Groups SO(2) (resp. SO(3)) are the Lie groups that represents rotations in 2-dimensional (resp. 3-dimensional) space. It is widely used in robotics, physics, computer vision, and geometric deep learning to describe rigid body rotations without scaling or reflection.
Special Euclidean Group
The Euclidean group is a subset of the broader affine transformation group. It contains the translational and orthogonal groups as subgroups. The Special Euclidean Group is a subgroup of Euclidean group. Any element of SE(n) can be represented as a combination of a translation and an orthogonal transformation, where the translation B can either precede or follow the orthogonal transformation A.
In robotics and physics, an element of SE(3) is often referred to as a rigid transformation, since it describes a rotation + translation without scaling or deformation.
Lie Algebras
Lie algebra can be viewed as the tangent space to the Lie group at the identity. Lie algebra can be viewed as the tangent space to the Lie group at the identity which linearize the group element near the identity.
For example, the group SO(n) of rotations is the group of orientation-preserving isometries of the Euclidean space. The Lie algebra so(n, R) consisting of real skew symmetric n × n matrices is the corresponding set of infinitesimal rotations.
📌 Visualizing the SO(3) manifold in three dimensions is inherently challenging. In this example, we represent the space of rotations as a solid ball, where the center corresponds to the identity rotation and each point within the ball encodes a rotation using the axis-angle representation.
Theoretically, a Lie algebra is a mathematical structure used to study continuous symmetries, consisting of a vector space equipped with a bilinear operation called the Lie bracket, which satisfies
The Lie bracket deserves a lengthly analysis and will be described in a future article.
📌 The terminology used for Lie groups and Lie algebras can sometimes be confusing, as it differs from traditional differential geometry definitions.
This article adheres to the semi-official Lie group terminology for consistency.
Geomstats
Geomstats is a free, open-source Python library designed for conducting machine learning on data lying on nonlinear manifolds, an area known as Geometric Learning.
The core concept of Geomstats is to incorporate differential geometry principles, such as manifolds and Lie groups, into the development of statistical and machine learning models. This open-source, object-oriented library follows Scikit-Learn’s API conventions for seamless integration [ref 7, 8].
Geomstats serves as a practical tool for gaining hands-on experience with geometric learning fundamentals while also supporting future research in the field.
The Geomstats library is described in detail in the following article Overview of Geomstats for Geometric Learning of this newsletter.
⚙️ Hands-on with Python
This article emphasizes the practical applications of Lie theory. As such, this section explores the commonly used Lie group: SO(3)
Environment
Special Orthogonal Group
The Special Orthogonal Group SO(3) is the Lie group that represents rotations in 3-dimensional space. It is widely used in robotics, physics, computer vision, and geometric deep learning to describe rigid body rotations without scaling or reflection.
📌 The term ‘Special’ refers to the fact that SO(3) is actually a subgroup of Orthogonal matrices with a relaxed condition det(R) +/- 1
The Lie algebra of SO(3) is defined as group of skew-symmetric 3x3 matrices A:
Any skew-symmetric 3x3 matrix in Lie algebra can be defined as a linear combination of the following 3 fundamental generators of rotations about x, y and z axes:
📌 Convention: Elements of Lie Algebra are written with the Fracktur font.
First let’s define a structure, LieElement, to define an element of the SO3 group with the following attributes:
Next we wrap the creation and manipulation of elements of the SO(3) into a class LieSO3Group with two constructors:
We use the constructors of the LieSO3Group class to generate two points on the SO3 manifold, so3_element_1 and so3_element_2. These points are represented as vectors in 3-dimensional Euclidean space for visualization purposes.
The first SO3 element uses the identity as the reference for a fundamental generator of rotations around Y axis: Ly= [[ 1. 0. 0.] [ 0. 0. -1.] [ 0. 0. 0.]]
The second SO3 element uses the same reference for a fundamental generator of rotations around Z axis: Lz= [[ 0. -1. 0.] [ 1. 0. 0.] [ 0. 0. 0.]]
Output for so3_group2
Algebra element:
[[ 0. -1. 0.]
[ 1. 0. 0.]
[ 0. 0. 0.]]
SO3 group element:
[[ 9.19666190e-01 -9.97270378e-01 -3.85335888e-17]
[ 9.97270378e-01 9.19666190e-01 -3.85335888e-17]
[ 0.00000000e+00 0.00000000e+00 1.00000000e+00]]
Let’s visualize the SO3 group element corresponding to the two algebra elements Ly and Lz
It would be insightful to verify the computation of a Lie algebra element from an SO(3) group element using the logarithm map. The validation process involves the following steps:
This 3-step process is illustrated below.
First let’s implement the computation of an algebra element from an existing SO3 group element.
The method utilizes the implementation of the logarithm map, log in the Geomstats library.
Output:
Algebra element:
[[ 0. 0. 1.]
[ 0. 0. 0.]
[-1. 0. 0.]]
SO3 group element:
[[ 9.19666190e-01 0.00000000e+00 9.97270378e-01]
[ 0.00000000e+00 1.00000000e+00 0.00000000e+00]
[-9.97270378e-01 -3.85335888e-17 9.19666190e-01]]
Computed algebra element:
[[ 3.25136469e-17 0.00000000e+00 1.00000000e+00]
[ 0.00000000e+00 0.00000000e+00 0.00000000e+00]
[-1.00000000e+00 -5.55111512e-17 1.62568234e-17]]
As we can see, the computed algebra element is equal (+/- rounding error) to the original rotation Ly.
✅ The evaluation of the Special Euclidean Group SE(3) is available in the full article Taming Symmetries: A Dive into Lie Groups
📘 References
Patrick Nicolas has over 25 years of experience in software and data engineering, architecture design and end-to-end deployment and support with extensive knowledge in machine learning. He has been director of data engineering at Aideo Technologies since 2017 and he is the author of "Scala for Machine Learning", Packt Publishing ISBN 978-1-78712-238-3 and Hands-on Geometric Deep Learning Newsletter on Substack
#GeometricDeepLearning #LieGroup #LieAlgebra #SO3 #SE3
DARINGHOOD Core & Culture Progress | Systembiografin, Dramaturgin, Astrologin, Quantenpraktikerin, Ontologin | LifeScript Consultant, Creative Coach | Mentoring, Training & Supervision.
2moThank you, Patrick Nicolas