-
-
Notifications
You must be signed in to change notification settings - Fork 91
Siegel spaces #179
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
Siegel spaces #179
Conversation
β¦d distance, Takagi factorization, Cayley transformation and other utils functions for operating with complex symmetric matrices
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks amazing from the design to implementation. I have minor comments for code sanity and code style and no other concerns this is good. Do not forget to add an entry to CHANGELOG (and README) :)
|
|
||
| name = "Bounded Domain" | ||
|
|
||
| def __init__(self, metric: str = SiegelMetricType.RIEMANNIAN.value, rank: int = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With Enum you can do the following
from enum import Enum
class SiegelMetricType(Enum):
"""Supported metric types for Siegel Spaces"""
RIEMANNIAN = "riem"
FINSLER_ONE = "fone"
FINSLER_INFINITY = "finf"
FINSLER_MINIMUM = "fmin"
WEIGHTED_SUM = "wsum"
and later
<SiegelMetricType.RIEMANNIAN: 'riem'>
or
SiegelMetricType(SiegelMetricType.RIEMANNIAN)
<SiegelMetricType.RIEMANNIAN: 'riem'>
so no need in from_str method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks!
|
|
||
| name = "Bounded Domain" | ||
|
|
||
| def __init__(self, metric: str = SiegelMetricType.RIEMANNIAN.value, rank: int = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def __init__(self, metric: str = SiegelMetricType.RIEMANNIAN.value, rank: int = None): | |
| def __init__(self, metric: str = SiegelMetricType.RIEMANNIAN, rank: int = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| FINSLER_MINIMUM = "fmin" | ||
| WEIGHTED_SUM = "wsum" | ||
|
|
||
| @staticmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed, thanks!
| @classmethod | ||
| def get(cls, type_str: str, rank: int): | ||
| metrics_map = { | ||
| SiegelMetricType.RIEMANNIAN.value: RiemannianMetric, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| SiegelMetricType.RIEMANNIAN.value: RiemannianMetric, | |
| SiegelMetricType.RIEMANNIAN: RiemannianMetric, |
No need in .value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks!
|
|
||
| @classmethod | ||
| def get(cls, type_str: str, rank: int): | ||
| metrics_map = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a static class variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I cannot have the children classes declared in a static class variable in the parent class, I extracted the creation logic in a SiegelMetricFactory
| return seed | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module", params=[torch.complex128, torch.complex64]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add float dtype to the test suit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use the Cayley Transform to move from one model (Upper half or Bounded domain) to the other and vice versa, thus we only define it for complex matrices.
|
As linters say, |
β¦Type instead of a string * Moved creation logic for Siegel metrics from class to * Corrected tests according to these changes * Added entries in CHANGELOG and README * Run black geoopt tests for formatting
|
|
Fixed issues with pydocstyle and lint |
|
Waiting for the tests pass now |
|
Great! It's merged! |
Implementation of two models of the Siegel Space.
Points in these manifolds are complex symmetric matrices.
Reference:
Federico LΓ³pez, Beatrice Pozzetti, Steve Trettel, Michael Strube, Anna Wienhard.
"Symmetric Spaces for Graph Embeddings: A Finsler-Riemannian Approach", 2021.