8000 General elastic metric by Florent-Michel · Pull Request #1078 · geomstats/geomstats · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

General elastic metric #1078

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

Closed

Conversation

Florent-Michel
Copy link
Contributor

No description provided.

@codecov
Copy link
codecov bot commented Jul 28, 2021

Codecov Report

Merging #1078 (291c114) into master (3b75a44) will decrease coverage by 0.42%.
The diff coverage is 89.48%.

❗ Current head 291c114 differs from pull request most recent head 7c47336. Consider uploading reports for the commit 7c47336 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1078      +/-   ##
==========================================
- Coverage   94.50%   94.08%   -0.41%     
==========================================
  Files          89       81       -8     
  Lines        8895     7901     -994     
==========================================
- Hits         8405     7433     -972     
+ Misses        490      468      -22     
Flag Coverage Δ
autograd 93.88% <89.48%> (-0.04%) ⬇️
numpy 91.46% <89.48%> (+0.01%) ⬆️
pytorch ?
tensorflow ?

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

Impacted Files Coverage Δ
geomstats/geometry/discrete_curves.py 93.57% <89.48%> (-1.00%) ⬇️
geomstats/tests.py 69.48% <0.00%> (-21.05%) ⬇️
geomstats/errors.py 88.89% <0.00%> (-11.11%) ⬇️
geomstats/_backend/__init__.py 77.42% <0.00%> (-6.45%) ⬇️
geomstats/learning/geodesic_regression.py 87.67% <0.00%> (-1.94%) ⬇️
geomstats/geometry/special_euclidean.py 90.21% <0.00%> (-0.25%) ⬇️
geomstats/visualization.py 89.61% <0.00%> (-0.15%) ⬇️
geomstats/_backend/pytorch/__init__.py
geomstats/_backend/tensorflow/autodiff.py
geomstats/_backend/tensorflow/__init__.py
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db6c95f...7c47336. Read the comment docs.

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.

Excellent!! The code is very clean, thank you 🎉

There are:

  • 1 deepsource error
  • 1 comment about whether we really need a new ElasticCurve class
  • minor comments here and there
  • errors in pytorch and tf: if you can solve them, that would be amazing! otherwise we can use the decorators.

Ready to merge soon IMO! Congrats!


return norms, args

def polar_to_cartesian(self, norms, args):
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can remove self and make it a @staticmethod (cf remaining DeepSource issue)

@@ -842,3 +842,340 @@ def g_criterion(srv, srv_norms):
nb_iter += 1

return proj


class ElasticMetric(RiemannianMetric):
Copy link
Collaborator

Choose a reason for hiding this comment

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

🎉 Excellent!!


def f_transform(self, curve):
"""Compute the F_transform of a curve.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add the formula using :math: in the docstring here? (see other docstrings in geomstats where this has been done).

Returns
-------
f : array-like, shape=[..., n_sampling_points - 1, ambient_dim]
F_transform of the curve..
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: only one period after curve.

def f_transform_inverse(self, f, starting_point):
"""Compute the inverse F_transform of a transformed curve.

Only works if a/2b <= 1.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add a test in this function, that will raise an error if a/2b>1?


def f_transform_inverse(self, f, starting_point):
"""Compute the inverse F_transform of a transformed curve.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we have an analytic form for the inverse, could you add it in :math: in the docstring too? thank you! 🙌

return distance


class ElasticCurves(Manifold):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need a new class here? How about: adding the elastic metric as an attribute of the existing classes of DiscreteCurves and/or ClosedDiscreteCurves (I don't remember if it would work in the closed curves case?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, I just thought DiscreteCurves was reserved for the srv metric.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I'm not sure of how I should add the elastic metric as an attribute of DiscreteCurves since it only works for planar discrete curves (i.e. ambient_manifold = Euclidean(dim=2).

Copy link
Collaborator

Choose a reason for hiding this comment

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

You could add if dim == 2: self.elastic_metric = ...?

plane curves", arXiv:1803.10894 [math.DG], 29 Mar 2018.
"""

def __init__(self, a, b):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we call the SRVMetric if a = 1 and b = 1? Or at least explain in the docstring how the two metrics relate? @Florent-Michel

Copy link
Contributor Author
@Florent-Michel Florent-Michel Jul 29, 2021

Choose a reason for hiding this comment

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

SRVMetric and ElasticMetric(1, 0.5) are indeed almost the same (up to a factor which depends on the number of sampling points because I made different normalization choices)

Copy link
Collaborator
@alebrigant alebrigant Jul 30, 2021

Choose a reason for hiding this comment

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

I think that for coherence it is important that the results of SRVMetric and ElasticMetric(1, 0.5) are the same. If it's just a normalization choice, can it be easily changed in SRVMetric ? And maybe add a test to check that both results are the same.

@ninamiolane
Copy link
Collaborator

@Florent-Michel any update on this?

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.

3 participants
0