-
Notifications
You must be signed in to change notification settings - Fork 55
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
Sketch change metric. #423
Conversation
For the documentation - I do not understand why it currently complains
I document the function signature once and export it – as we do for some functions that are first only given in signature. Hm. Maybe I am overlooking something since it is getting late. |
I don't understand it either. Documenter sometimes has weird problems with building PR docs. |
I can get the same error locally, so this is not only on PR ;) |
That's a really weird error... maybe environment in which docs are built doesn't have |
I do not know. Locally it just gets weirder
whatever. I‘ll lave it for now trying to build to docs, I think its GR again. GR sometimes does very strange things. |
I thought a little bit about steps 2 (changing type) and 4 (adaption to local tangent vector representation). Then I think both 2 and 4 should be done in project for the following reason: If I project (with the metric from the embedding) onto a manifold, I would expect I am currently updating the docs to the result from our discussion, but locally I can not build the docs and look why it fails here on PR, since JuliaPlots/Plots.jl#3800 either Plots or GR is just completely broken currently. |
Just when I thought I had understood what we are doing, I think I again do not understand what we are doing. See There the transportation of a tangent vector g_E(X,Y) = tr(XY) = g_p(BX,BY) = tr(p^{-1}BXp^{-1}BY) Here clearly this yields g_E(X,Y) = tr(XY) = g_p(f(X),B) = tr(p^{-1}Xp^{-1}Y) for fixed X (and all Y) what I started here with, too? because then, sure, |
Codecov Report
@@ Coverage Diff @@
## master #423 +/- ##
==========================================
+ Coverage 97.96% 97.99% +0.02%
==========================================
Files 79 79
Lines 6501 6585 +84
==========================================
+ Hits 6369 6453 +84
Misses 132 132
Continue to review full report at Codecov.
|
After a short question to the Manopt forum and some further thinking I found the issue at least for the gradient: Note that this requires one representation of tangent vectors, that is the shift to the Lie algebra can happen before or after, since it is not important at which point we switch the metric (for neither of those functions). What remains is to decide for proper names (one could call the second also |
I think I'm starting to see how it's supposed to work, in particular why you did
I think a name like
My first thought is to require gradients in the correct representation to be passed to
It seems reasonable to put both type conversion and parallel transport in
Great, that's quite helpful 🙂 . |
That sounds like a reasonable name, I will think whether it can have a more general name even, since this might not only be used for gradients.
That is also what I have in mind, that function should only change the metric and not representation
I will check rotation then, but great that we agree, that both conversion and representation shift (to Lie algebra) should happen in the projection. I will look at that and adopt docs/function implementations. |
Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com>
Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com>
…folds/Manifolds.jl into kellertuer/gradient-conversion # Conflicts: # src/manifolds/MetricManifold.jl
I think, since |
After I fixed the last few test coverage lines, I will start a small tutorial over on Manopt (maybe just Rayleigh again) on how to use a little bit of AD in Manopt. |
Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com>
…c fallbacks using the local metric.
…folds/Manifolds.jl into kellertuer/gradient-conversion
While “just shortly adding” a test for the fallback to use the local metric, I am somehow hitting a wall on an ambiguity, where I thin transparency does something and then it does not find the local metric function I implemented. So I will have do take a looooong look into that, where local metric is maybe too transparent or something. For now I do not yet understand why the exact function I implemented (which I thought would be called for the manifold&metric in the test) is not even mentioned in the ambiguous cases... |
Yeah, we definitely don't have |
Hm, I am a little lost on So I do not know how it was supposed to work nor how it is currently actually non-working, since I can not debug the current error (when the debugger throws an error even earlier). Any help appreciated. I think Edit 5: I removed the previous edits, since I do not understand why they went wrong, but I do not know why it is currently working, either. |
…dinates do not work for the test.
After about 2 hours fiddling with a lot of transparency, maybe I think the decorator pattern and bases being optional is something we should maybe redesign / avoid, since I feel like I can also spent a few weeks without sleep just trying to fix all this stuff and it just breaks even the last braincell after 2 hours. |
I think I'd vote for just not using the decorator pattern for metric-related functions. There is just not enough benefit to justify the effort needed to make it work. |
I might have found the way to get the tests running. Note that in the current test manifold I had to
do quite a detailed typing on the basis to resolve the ambiguity. |
It seems that sometimes Format & Documenter Fail because some packages could not be loaded. I just restarted both, since they should work. I also finished code coverage, so this should be good to go. |
Great, I'll take a look at it again soon. |
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.
I think with some documentation polishing this should be ready to go 🙂
Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com>
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.
I think we can merge this when CI passes and finally resolve #17 🎉
Was a way to go, but I am happy we have that now :) |
commit 26ad8a5 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Thu Sep 23 20:17:01 2021 +0200 runs formatter. commit 99bcb23 Merge: b027f4c 2a03fb1 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Thu Sep 23 18:33:25 2021 +0200 Merge branch 'master' into kellertuer/polish-diff-interfaces commit 2a03fb1 Author: Mateusz Baran <mateuszbaran89@gmail.com> Date: Thu Sep 23 18:08:23 2021 +0200 Support for Zygote and ReverseDiff gradients (#427) * Support for Zygote and ReverseDiff gradients * Add Zygote test dependency * bump ambiguity limit because of Zygote * fix tests and Zygote backend * bump Julia to 1.5 * fixing some issues on Julia 1.7-rc1 * more fixing for Julia 1.7 * formatting * reduce tangent vector length in a test since the approximation only works very locally (and they changed the default random number generator) * Update Project.toml Co-authored-by: Ronny Bergmann <git@ronnybergmann.net> * bump atol on Rotations * reduce tangent vector size even further. * adapt one more tolerance Co-authored-by: Ronny Bergmann <git@ronnybergmann.net> commit b027f4c Author: Ronny Bergmann <git@ronnybergmann.net> Date: Thu Sep 23 17:11:19 2021 +0200 fix a few typos. commit dcc471e Author: Ronny Bergmann <git@ronnybergmann.net> Date: Thu Sep 23 13:53:07 2021 +0200 unify naming. commit 3de9a30 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Thu Sep 23 13:33:59 2021 +0200 Reduce dependencies, wort a little bit further on polishing. commit 8702902 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Thu Sep 23 10:45:36 2021 +0200 runs formatter. commit 378bbba Author: Ronny Bergmann <git@ronnybergmann.net> Date: Thu Sep 23 10:45:15 2021 +0200 fix the other jacobian. commit a7d1edb Author: Ronny Bergmann <git@ronnybergmann.net> Date: Thu Sep 23 10:29:37 2021 +0200 renaming and dependencies. commit 02f97d6 Merge: aca6d5c 9fc772a Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 22 19:48:36 2021 +0200 Merge branch 'master' into kellertuer/polish-diff-interfaces # Conflicts: # Project.toml # src/Manifolds.jl commit aca6d5c Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 22 19:46:59 2021 +0200 Add a proper working default. commit 9fc772a Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 22 19:46:01 2021 +0200 Sketch change metric. (#423) * Adds a change_metric and a change_representer * Apply suggestions from code review * bump version. Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com> commit 1462018 Merge: 923a718 4501a27 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 22 19:20:52 2021 +0200 Merge branch 'kellertuer/gradient-conversion' into kellertuer/polish-diff-interfaces # Conflicts: # Project.toml # src/differentiation/riemannian_diff.jl commit 923a718 Merge: d391483 07c905e Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 22 18:20:39 2021 +0200 Merge branch 'mbaran/reverse-diff-zygote' into kellertuer/polish-diff-interfaces commit 07c905e Author: Mateusz Baran <mateuszbaran89@gmail.com> Date: Wed Sep 22 17:27:10 2021 +0200 Update Project.toml Co-authored-by: Ronny Bergmann <git@ronnybergmann.net> commit 4501a27 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 22 17:19:42 2021 +0200 Apply suggestions from code review Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com> commit 3c47350 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 22 08:59:28 2021 +0200 reduce tangent vector length in a test since the approximation only works very locally (and they changed the default random number generator) commit 3b7396d Author: Mateusz Baran <mateuszbaran89@gmail.com> Date: Tue Sep 21 19:19:09 2021 +0200 formatting commit 5d75e6e Author: Mateusz Baran <mateuszbaran89@gmail.com> Date: Tue Sep 21 19:17:28 2021 +0200 more fixing for Julia 1.7 commit c723345 Author: Mateusz Baran <mateuszbaran89@gmail.com> Date: Tue Sep 21 12:31:30 2021 +0200 fixing some issues on Julia 1.7-rc1 commit cf00e22 Author: Mateusz Baran <mateuszbaran89@gmail.com> Date: Tue Sep 21 08:49:40 2021 +0200 bump Julia to 1.5 commit 1ed46db Author: Mateusz Baran <mateuszbaran89@gmail.com> Date: Mon Sep 20 23:02:03 2021 +0200 fix tests and Zygote backend commit 7849fc0 Author: Mateusz Baran <mateuszbaran89@gmail.com> Date: Mon Sep 20 19:45:41 2021 +0200 bump ambiguity limit because of Zygote commit 9163480 Author: Mateusz Baran <mateuszbaran89@gmail.com> Date: Mon Sep 20 14:40:50 2021 +0200 Add Zygote test dependency commit 7ed57da Author: Mateusz Baran <mateuszbaran89@gmail.com> Date: Mon Sep 20 12:48:09 2021 +0200 Support for Zygote and ReverseDiff gradients commit 2f498da Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 18 23:17:32 2021 +0200 add a test that double metric wrapping is avoided; remove unnecessary dispatch. commit e180bc4 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 18 21:58:49 2021 +0200 Simplify default implementation. Extend coverage. Order functions alphabetically. commit 420047d Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 18 20:07:21 2021 +0200 Fix the error message for hyperbolic. commit ed2871c Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 18 19:54:19 2021 +0200 maybe fix the new test by slightly overtyping the basis. commit 49dc500 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Fri Sep 17 18:44:59 2021 +0200 format this interims non-working test. commit a78ace4 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Fri Sep 17 18:40:57 2021 +0200 Maybe. just maybe fixed local metric, but now get vector and get coordinates do not work for the test. commit 97417ae Author: Ronny Bergmann <git@ronnybergmann.net> Date: Thu Sep 16 14:31:49 2021 +0200 Improve docs. commit d34ef6c Merge: 95a3c8b d1dbb7c Author: Ronny Bergmann <git@ronnybergmann.net> Date: Thu Sep 16 11:09:24 2021 +0200 Merge branch 'kellertuer/gradient-conversion' of github.com:JuliaManifolds/Manifolds.jl into kellertuer/gradient-conversion commit 95a3c8b Author: Ronny Bergmann <git@ronnybergmann.net> Date: Thu Sep 16 11:09:16 2021 +0200 adds a test for positive vectors and starts testing the default Metric fallbacks using the local metric. commit d1dbb7c Author: Ronny Bergmann <git@ronnybergmann.net> Date: Thu Sep 16 10:47:57 2021 +0200 Apply suggestions from code review Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com> commit 14fdb06 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 15 22:39:38 2021 +0200 bump version. commit cbcef94 Merge: da98b5f bd2b425 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 15 22:38:45 2021 +0200 Merge branch 'master' into kellertuer/gradient-conversion commit da98b5f Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 15 22:37:18 2021 +0200 append this step to riemannian differentiation. commit c154516 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 15 22:37:01 2021 +0200 finish tests for product and power – extend features to also work on the sphere. commit 844f8c4 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 15 21:42:59 2021 +0200 Fixes a few typos in the docs. commit 5005965 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 15 20:40:11 2021 +0200 Document and test SPDs commit d2cec4d Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 15 20:30:00 2021 +0200 Finish positive Numbers. commit 7737c92 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 15 20:03:49 2021 +0200 Extend ProbabilitySimples to also cover change_metric. commit 6300f80 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 15 20:03:33 2021 +0200 delete change_representer since it should be inherited from ProbabilitySimplex combined with AbstractPowerManifold and EmbeddedManifold. commit 95b8bc6 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 15 19:48:20 2021 +0200 finishes testing for hyperbolic. commit 6f1fb64 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 15 19:47:37 2021 +0200 fix a small bug in Hyperbolic copyto! which returned the wrong value. commit a62e134 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Wed Sep 15 10:31:24 2021 +0200 Documentation and Test for Poincaré Ball conversion. commit d84a3cc Author: Ronny Bergmann <git@ronnybergmann.net> Date: Tue Sep 14 19:52:52 2021 +0200 adds two further small tests. commit ea76128 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Tue Sep 14 19:21:08 2021 +0200 Document and test hyperbolic. commit 257b223 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Tue Sep 14 18:20:55 2021 +0200 Finish documentation and test for Generalised Grassmann. commit 152e9a1 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Tue Sep 14 18:20:34 2021 +0200 fix transparency of nonmutating to parent on a Manifold level. commit 1b79065 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Mon Sep 13 17:49:20 2021 +0200 Fix two typos. commit 2eac3ee Author: Ronny Bergmann <git@ronnybergmann.net> Date: Mon Sep 13 16:30:35 2021 +0200 Change `change_gradient` to `change_represender` and introduce mutating variant commit 5539f4b Author: Ronny Bergmann <git@ronnybergmann.net> Date: Mon Sep 13 12:11:52 2021 +0200 introduce mutating variants and decorator transparency. commit 714862e Merge: 4912e4f 05968dc Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sun Sep 12 20:09:17 2021 +0200 Merge branch 'kellertuer/gradient-conversion' of github.com:JuliaManifolds/Manifolds.jl into kellertuer/gradient-conversion commit 4912e4f Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sun Sep 12 20:09:11 2021 +0200 Adress points from code review. commit 05968dc Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sun Sep 12 20:03:18 2021 +0200 Apply suggestions from code review Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com> commit 9769a1a Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sun Sep 12 18:17:45 2021 +0200 add the generic case for doubly stochastic (includes symmetric, too). commit 42875a6 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sun Sep 12 18:13:42 2021 +0200 implement the remaining conversions. commit fb304c2 Merge: cb2f932 2ee2072 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 11 16:51:29 2021 +0200 Merge branch 'kellertuer/gradient-conversion' of github.com:JuliaManifolds/Manifolds.jl into kellertuer/gradient-conversion commit cb2f932 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 11 16:51:17 2021 +0200 adds a few conversion, where the embedding is not isometric. commit 2ee2072 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 11 13:04:01 2021 +0200 Update src/manifolds/MetricManifold.jl Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com> commit c742ea5 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 11 12:55:35 2021 +0200 Fix two typos. commit a17b4ca Merge: 540f374 056e24c Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 11 12:47:27 2021 +0200 Merge branch 'kellertuer/gradient-conversion' of github.com:JuliaManifolds/Manifolds.jl into kellertuer/gradient-conversion # Conflicts: # src/manifolds/MetricManifold.jl commit 540f374 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 11 12:46:50 2021 +0200 Specify Reisz representer, change adjoint to ^H. commit 056e24c Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 11 12:38:40 2021 +0200 Update src/manifolds/MetricManifold.jl Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com> commit 158bbf2 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 11 12:33:10 2021 +0200 Apply suggestions from code review Co-authored-by: Mateusz Baran <mateuszbaran89@gmail.com> commit 616db5d Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 11 10:39:47 2021 +0200 Fix a few typos in docs. commit c9737b3 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 11 10:21:02 2021 +0200 adds a change_gradient. commit 0857b21 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 11 09:25:54 2021 +0200 fix a few typos. commit a302733 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 11 09:04:07 2021 +0200 rfF. commit 3347930 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Sat Sep 11 09:01:30 2021 +0200 Document insights from yesterday evening and – getting stuck at the next point. commit ae0cdd1 Author: Ronny Bergmann <git@ronnybergmann.net> Date: Fri Sep 10 20:38:56 2021 +0200 Sketch change metric.
This PR is a step towards #17.
the idea here is as follows
change_metric
(currently just its doctoring, which locally failed to build, let‘s see – I seem to miss something maybe for the docs?) should change the metric, i.e. in a basis compute Z = G_1^-1G_2 X (to switch X from G2 to G1).Signatures are
or
And it would convert into the metric of the first given manifold. From the embedding, e.g. Euclidean with
EuclideanMetric()
one would call for exampleIn order to get this into something like the discussed
egrad2rgrad
I would propose a functionconvert_tangent(M, N, p, X)
whereN
is the embedding (ifM
itself is not anEmbeddedManifold
)project(M, p, X)
TMVVector
– but what if the user wants a different representation? How would we distinguish these? Or would this already be done by project? Maybe with an optional parameter indicating the representation type (e.g. which of the three forHyperbolic
)?change_metric
as sketched hereI think we could provide a default
change_tangent
that just performs steps 1 and 3, and this would be overwritten, e.g. FixedRankMatrices would perform 2 (split into T M V before the metric change) and Lie groups would by default perform 1,3, and 4.Similarly, with a different
change_metric
for matrix operations on the tangent space (or actions of matrices, so 1-1 and 2-0 tensors in comparison) someconvert_matrix
would be a similar approach to generaliseehess2rhess
Adendum: So if one has the Euclidean gradient
grad = p -> ...
by some machinery, the Riemannian gradient would – with this sketch bep -> convert_tangent(M, p, grad(p))
(ifM
has an implicit default embedding).Adendum2: Of course
convert_tangent_
is not yet the nicest of names, I think, though it converts a Euclidean (or in the embedding) tangent vector to a Riemannian one. Other ideas are welcome.