Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@fedelopez77
Copy link
Contributor

Implementation of two models of the Siegel Space.

  • Upper Half space model: generalizes the upper half plane model of the hyperbolic plane.
  • Bounded domain model: generalizes the Poincare ball model.

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.

Copy link
Member

@ferrine ferrine left a 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):
Copy link
Member

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

Copy link
Contributor Author

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):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def __init__(self, metric: str = SiegelMetricType.RIEMANNIAN.value, rank: int = None):
def __init__(self, metric: str = SiegelMetricType.RIEMANNIAN, rank: int = None):

Copy link
Contributor Author

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
Copy link
Member

Choose a reason for hiding this comment

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

This method is redundant

Copy link
Contributor Author

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,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
SiegelMetricType.RIEMANNIAN.value: RiemannianMetric,
SiegelMetricType.RIEMANNIAN: RiemannianMetric,

No need in .value

Copy link
Contributor Author

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 = {
Copy link
Member

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

Copy link
Contributor Author

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])
Copy link
Member

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?

Copy link
Contributor Author

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.

@ferrine
Copy link
Member

ferrine commented Jun 27, 2021

As linters say, make black in the root of the repo may help)

…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
@fedelopez77
Copy link
Contributor Author

  • Corrected param to init Siegel manifolds: now it is a SiegelMetricType instead of a string
  • Moved creation logic for Siegel metrics from SiegelMetric class to SiegelMetricFactory
  • Corrected tests according to these changes
  • Added entries in CHANGELOG and README
  • Run make black for formatting

@fedelopez77
Copy link
Contributor Author

Fixed issues with pydocstyle and lint

@ferrine
Copy link
Member

ferrine commented Jul 1, 2021

Waiting for the tests pass now

@ferrine ferrine merged commit 06750cc into geoopt:master Jul 1, 2021
@ferrine
Copy link
Member

ferrine commented Jul 1, 2021

Great! It's merged!

@fedelopez77 fedelopez77 deleted the symspace branch July 1, 2021 17:20
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.

2 participants