Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor invariant metrics #1948

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

luisfpereira
Copy link
Collaborator

This PR builds on top of #1946 and #1947 to refactor invariant metrics. The main idea is to remove inner_product_at_identity and use lie_algebra.metric.inner_product. This implies lie_algebra is equipped with an appropriate metric.

Besides simplifying the code and making it easier to test, this PR opens the door to use nondiagonal metric matrices at identity (will partially solve e.g. #1884). This is already implemented and tested, but algorithms need to be made more robust.

Still need to refactor _InvariantMetricVector, but will be left for another PR.

NB: merging this PR before #1946 and #1947 also merges them.

Copy link

codecov bot commented Feb 5, 2024

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (4bd9677) 91.24% compared to head (f3d8e35) 91.57%.
Report is 5 commits behind head on main.

Files Patch % Lines
geomstats/geometry/lie_group.py 93.94% 2 Missing ⚠️
geomstats/geometry/invariant_metric.py 92.86% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1948      +/-   ##
==========================================
+ Coverage   91.24%   91.57%   +0.33%     
==========================================
  Files         146      151       +5     
  Lines       13515    13706     +191     
==========================================
+ Hits        12331    12550     +219     
+ Misses       1184     1156      -28     
Flag Coverage Δ
autograd 86.66% <94.65%> (?)
numpy 89.28% <89.29%> (+0.05%) ⬆️
pytorch 85.60% <94.65%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@ninamiolane ninamiolane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several functions are missing parameter descirptions in the docstrings. I'll review once they are added because it'll be easier. Thanks!


self.n = n
self.epsilon = epsilon

self.skew = SkewSymmetricMatrices(self.n, equip=False)

def equip_with_metric(self, Metric=None, **metric_kwargs):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docstring and parameter descriptions.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto


return self

def equip_with_metric(self, Metric=None, **metric_kwargs):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing parameter descriptions

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

geomstats/geometry/matrices.py Outdated Show resolved Hide resolved
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@luisfpereira luisfpereira force-pushed the invariant-metrics branch 3 times, most recently from c295954 to a7f8724 Compare February 12, 2024 16:01
Copy link
Collaborator

@ninamiolane ninamiolane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work (again!).

High-level:
See question about equip with biinvariant metric, which might not be correct, because some groups simply don't have any biinvariant metric.
See comment on Euclidean as a lie algebra: we can't call it this way bcs it doesn't have a lie bracket?

Otherwise, minor docstrings picknits, and then good to merge!

)
return self

def _equip_lie_algebra_for_biinvariant_metric(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some Lie groups do not admit any bi-invariant metric. Thus, I'm not sure what this function is really doing?

Only compact group, abelian groups, and their products, admit bi-invariant metrics. For example, SE(n) never admits any bi-invariant metric.


return self

def equip_with_metric(self, Metric=None, **metric_kwargs):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

geomstats/geometry/matrices.py Outdated Show resolved Hide resolved
geomstats/geometry/matrices.py Outdated Show resolved Hide resolved
geomstats/geometry/matrices.py Outdated Show resolved Hide resolved
geomstats/geometry/matrices.py Outdated Show resolved Hide resolved
super().__init__(dim=dim, shape=(dim,), lie_algebra=self, equip=equip)

super().__init__(
dim=dim, shape=(dim,), lie_algebra=Euclidean(dim, equip=False), equip=equip
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from a design perspective, lie_algebra = Euclidean feels a bit weird, because Euclidean doesn't have a lie bracket, thus how could it be a lie algebra?


self.n = n
self.epsilon = epsilon

self.skew = SkewSymmetricMatrices(self.n, equip=False)

def equip_with_metric(self, Metric=None, **metric_kwargs):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants