Lie Algebra on SO3 Groups in Python

Lie Algebra on SO3 Groups in Python

Curious about manifolds and the SO(3) Lie group??

Your next step is to explore its associated Lie algebra, which lies in the tangent space. This algebra is a linear space with the same dimension as the Lie group, closed under a bilinear alternating operation known as the Lie bracket. The Lie algebra of SO(3), denoted as so3, consists of all 3x3 skew-symmetric matrices.

Lie algebra on SO3
Implementation
       Setup
       Projector operator
       Lie bracket
References        

What you will learn:?How to compute SO3 rotation matrices from tangent vector and extract Lie algebra from points on SO3 manifolds.


Notes:?

  • This post is a follow up on a previous post on SO3 Lie groups?[ref?1] and leverage articles related to differential geometry and geometry learning [ref?2,?3,?4?and?5]
  • Environments:?Python 3.11, ?Matplotlib 3.9, Geomstats 2.8.0
  • Source code is available at ?Github.com/patnicolas/geometriclearning/Lie
  • To enhance the readability of the algorithm implementations, we have omitted non-essential code elements like error checking, comments, exceptions, validation of class and method arguments, scoping qualifiers, and import statement.
  • The implementation relies on Geomstats, an open-source, object-oriented library following Scikit-Learn’s API conventions to gain hands-on experience with Geometric Learning. It is described in article Introduction to Geomstats for Geometric Learning
  • Please subscribe to Hands-on Geometric Deep Learning for in-depth topics on Geometric learning, reviews and exercises.


Disclaimer?:?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 experimenting with the Lie Algebra on 3-dimension Special Orthogonal manifolds using the?#Geomstats?Python library [ref?6].


Lie algebra on?SO3

As a reminder ....

A?smooth 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.?

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.

Fig. 1 Manifold with tangent space and exponential/logarithm maps

A Lie algebra is a vector space g and a bilinear operator known as Lie bracket or?Lie commutator defined as:

with the properties

  1. Anticommutative:? ??[X,Y] = -[Y, X]
  2. Jacobi Identity:?????? [[X,Y], Z] + [[Y,Z],X] + [[Z,X],Y] = 0

?

Examples

Let's consider the n-dimension General Linear Group on complex numbers?GL(n, C) of n x n invertible matrices. The Lie algebra is defined as

The?Special Orthogonal Group?in 3 dimensions,?SO(3)?is the group of all rotation matrices in 3 spatial dimensions.

The Lie bracket for the SO3 group is defined as the matrix commutator of two vectors?X, Y on base point P. [X,Y] = X.Y-Y.X with the basis elements:

Table 1. SO3 Lie group and associated algebra


Implementation

Setup

Geomstats?is a free, open-source Python library designed for conducting machine learning on data situated on nonlinear manifolds, an area known as Geometric Learning. This library offers object-oriented, thoroughly unit-tested features for fundamental manifolds, operations, and learning algorithms, compatible with various execution environments, including?NumPy,?PyTorch, and?TensorFlow?(Overview Geomstats library).

We leverage the class?LieSO3Group?defined in the previous article (?Operations on SO3 Lie Groups in Python - Implementation).

The Lie algebra for the Special Orthogonal Group SO3 for a given tangent vector and base point is implemented through the logarithmic map in the method?lie_algebra?using the?SpecialOrthogonal.log?method in Geomstats.


Fig. 2 Visualization of SO3 Lie point and Algebra


The algebra matrix is computed from a given fundamental rotation generator along Y-axis at identity in the SO3 manifold.

As expected the Lie algebra of the Lie group point is identical to the original tangent vector.

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]]        


Projector operator

The Lie group projection operator approach is an iterative scheme usually applied to continuous-time optimal control problems on Lie groups. It is mentioned here for reference.

We use the same tangent vector and base point on SO3 manifold to compute the projected matrix.

Projected point with identity:
[[ 2.00000000e+00  0.00000000e+00  0.00000000e+00]
 [-5.16112858e-17  1.63116493e+00 -7.78920352e-01]
 [-1.03222572e-16  7.78920352e-01  1.63116493e+00]]

Projected point reference
[[ 0.  0.  0.]
 [ 0.  0. -1.]
 [ 0.  1.  0.]]:

[[ 1.2515165   0.40011923  0.88372822]
 [ 0.43685048  1.72667917 -0.53434116]
 [-0.85660137  0.51784353  1.00875279]]        


Lie Bracket

Finally, we compute the bracket for this element,?self.algebra_element?with another element,?element.

Let first try to compute the bracket of a SO3 rotation (skew matrix) with itself.

Algebra element:
[[ 0.  0.  0.]
 [ 0.  0. -1.]
 [ 0.  1.  0.]]

SO3 element
[[ 1.     0.     0.   ]
 [ 0.     0.92  -0.997]
 [ 0.     0.997  0.92 ]]

Bracket [x,x]:
[[0. 0. 0.]
 [0. 0. 0.]
 [0. 0. 0.]]        

Now Let's compute the Lie bracket of two tangent vectors, one for SO3 rotation along X axis and the other along Y axis.

[[ 1.          0.          0.        ]
 [ 0.          0.91966619 -0.99727038]
 [ 0.          0.99727038  0.91966619]]

Bracket:
[[ 0. -1.  0.]
 [ 1.  0.  0.]
 [ 0.  0.  0.]]        

The Lie bracket of a rotation along X axis and a rotation along Y axis is a rotation along the Z axis; [lx, ly] = lz

Fig 3. Visualization of 3D rotation along X and Y axes


Fig. 4 Visualization of Lie bracket on SO3 manifold



Thanks for reading. For comprehensive topics on geometric learning, including detailed analysis, reviews and exercises, subscribe to Hands-on Geometric Deep Learning


References

[1]?Operations on SO3 Lie groups

[2]?Foundation of Geometric Learning

[3]?Differentiable Manifolds for Geometric Learning

[4]?Intrinsic Representation in Geometric Learning

[5]?Riemann Metric and Connection

[6]?Introduction to Geometric Learning in Python with Geomstats

[7]?Lie algebra - Quantum Tinkering - Omar A. Ashour



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.

#LieGroup #SO3 #LieAlgebra #Manifold #GeometricLearning #Geomstats


Gilles Tonnelier, Ph.D

Dir. Scientifique IA @ Quarks || Consultant IA | Conférencier

4 个月

thank you for your qualitative post! Concerning those groups I have 2 questions: - is there an interest to try to identify such geometry in realistic datasets? - maybe could you share an industrial use case application ?

要查看或添加评论,请登录

Patrick Nicolas的更多文章

  • Riemannian Manifolds for Geometric Learning

    Riemannian Manifolds for Geometric Learning

    Intrigued by the idea of applying differential geometry to machine learning but feel daunted? Beyond theoretical…

  • Einstein Summation in Geometric Deep Learning

    Einstein Summation in Geometric Deep Learning

    The einsum function in NumPy and PyTorch, which implements Einstein summation notation, provides a powerful and…

  • Visualization of Graph Neural Networks

    Visualization of Graph Neural Networks

    Have you ever found it challenging to represent a graph from a very large dataset while building a graph neural network…

  • Modeling Graph Neural Networks with PyTorch

    Modeling Graph Neural Networks with PyTorch

    Have you ever wondered how to get started with Graph Neural Networks (GNNs)? Torch Geometric (PyG) provides a…

  • Approximating PCA on Manifolds

    Approximating PCA on Manifolds

    Have you ever wondered how to perform Principal Component Analysis on manifolds? An approximate solution relies on the…

  • Reviews of Papers on Geometric Learning - 2024

    Reviews of Papers on Geometric Learning - 2024

    2024 introduced a fascinating collection of papers on geometric deep learning. Here are reviews of a selection of them.

    1 条评论
  • Fréchet Centroid on Manifolds in Python

    Fréchet Centroid on Manifolds in Python

    The Fréchet centroid (or intrinsic centroid) is a generalization of the concept of a mean to data points that lie on a…

  • Einstein Summation in Numpy

    Einstein Summation in Numpy

    Many research papers use Einstein summation notation to describe mathematical concepts. Wouldn't it be great to have a…

  • Deep Learning on Mac Laptop

    Deep Learning on Mac Laptop

    The latest high-performance Mac laptops are well-suited for experimentation. However, have you been frustrated by your…

    1 条评论
  • Impact of Linear Activation on Convolution Networks

    Impact of Linear Activation on Convolution Networks

    Have you ever wondered how choosing an activation function can influence the performance of a convolutional neural…

社区洞察

其他会员也浏览了