JuliaManifolds / Manifolds.jl

Manifolds.jl provides a library of manifolds aiming for an easy-to-use and fast implementation.
https://juliamanifolds.github.io/Manifolds.jl
MIT License
368 stars 52 forks source link

An alternative algorithm for the logarithm map of Stiefel manifold. #546

Closed dnguyend closed 1 year ago

dnguyend commented 1 year ago

Hello, Per Professor Bergmann's suggestion, I have implemented the first cut of a method to compute the Log function on the Stiefel manifold with the Submersion metric proposed in my paper [1].

I forked a version of Manifolds.jl to a repository and added the implementation. Examples and some test results are in a notebook.

I also implemented the function expm_frechet in Julia, I understand it is not available in the LinearAlgebra package. I follow the open-source code in scipy.linear_alg. At some point, I would like to make it part of LinearAlgebra.

Thank you all for creating a very nice, professional framework to study manifolds. I will be very happy if I could contribute to the effort. I am new to this, I try my best to follow the contributing guidelines but I am sure there will be mistakes - please feel free to send feedback. I am happy to make changes to conform with your high standard.

Du [1] Nguyen, D. Closed-form Geodesics and Optimization for Riemannian Logarithms of Stiefel and Flag Manifolds. J Optim Theory Appl 194, 142–166 (2022). https://doi.org/10.1007/s10957-022-02012-3

sethaxen commented 1 year ago

Thanks! I haven't looked through the algorithm in the paper yet, but I really appreciate you benchmarking the performance vs our implementation of the shooting method. Sounds like we should consider this method as a new default for the logarithm. A few notes:

dnguyend commented 1 year ago

Thanks, Seth for your thoughtful response.

dnguyend commented 1 year ago

And thanks for the tip about ChainRules - will look it up!

kellertuer commented 1 year ago

Hi, thanks for the nice comparison. You implementation seems to be quite fast.

My main concern would (as well) be the dependency on Optim, since this is quite a large dependency.

dnguyend commented 1 year ago

Thank you! I didn't see this until now. In the python version, I implemented a customized LBFGS. I can also port it to Julia. It will take another weekend. Du

On Mon, Oct 24, 2022 at 8:38 AM Ronny Bergmann @.***> wrote:

Hi, thanks for the nice comparison. You implementation seems to be quite fast.

My main concern would (as well) be the dependency on Optim, since this is quite a large dependency.

— Reply to this email directly, view it on GitHub https://github.com/JuliaManifolds/Manifolds.jl/issues/546#issuecomment-1288972118, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEOOGFOQBJR5P3H74HQYKZ3WEZ7LLANCNFSM6AAAAAARMPIAWM . You are receiving this because you authored the thread.Message ID: @.***>

-- Thanks, Du

dnguyend commented 1 year ago

I managed to remove the dependency on Optim, using a customized version of LBFGS. The result is saved in my forked version of Manifolds.jl, with an updated workbook containing tests and explanation. I also moved the old workbook and test data out to a different repository to keep Manifolds.jl clean.

The new version is slightly slower and less robust than the version with Optim. This may be because the line search I use out of convenience is not as good as the More'-Thuente search. It converges less well than if we use Optim on the Rosenbrock function. I hope this is good enough for now. The shooting method does perform well for large distances and large manifolds, I think a hybrid version, using the Frechet derivative-based gradient method to bring the cost down to 1e-3, then using the shooting method for the remaining iterations probably will take advantage of both approaches. Potentially we can try this on other manifolds with closed-form geodesics.

Hope you all have a nice weekend!

kellertuer commented 1 year ago

Thanks for the update. I will have to take a look at the new version, but this week I am a little busy (more busy than usual) with teaching.

dnguyend commented 1 year ago

No rush at all!

kellertuer commented 1 year ago

Sorry for the further delay, here a semester is coming to its end and that brings quite a bit of administration with it. I think overall my main problem is, that the algorithm is quite long and complicated, to I fear it will take me a few days to check it, which I find difficult to find time for. Can you maybe open a PR and write tests for it (and maybe an example)?

dnguyend commented 1 year ago

Sure! I totally understand the time constraints, and it is quite a bit of code. The workbook has some tests but I will write tests in the format of the package. Please take your time.

If we include expm_frechet at some point, there are other interesting things we can do - for example we can get Jacobi fields of Stiefel manifolds under these metrics for almost free. With the Riemannian curvature in this article https://www.heldermann.de/JLT/JLT32/JLT322/jlt32027.htm we can have the Jacobi field equation numerically checked, presumably that's another topic.

On Fri, Nov 25, 2022 at 7:02 AM Ronny Bergmann @.***> wrote:

Sorry for the further delay, here a semester is coming to its end and that brings quite a bit of administration with it. I think overall my main problem is, that the algorithm is quite long and complicated, to I fear it will take me a few days to check it, which I find difficult to find time for. Can you maybe open a PR and write tests for it (and maybe an example)?

— Reply to this email directly, view it on GitHub https://github.com/JuliaManifolds/Manifolds.jl/issues/546#issuecomment-1327390709, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEOOGFKRZ7SNXEZRFX4UYN3WKCTD3ANCNFSM6AAAAAARMPIAWM . You are receiving this because you authored the thread.Message ID: @.***>

-- Thanks, Du

kellertuer commented 1 year ago

I think that would be a next topic, yes; also I do not have access to that journal.

dnguyend commented 1 year ago

I got some complains from reviewdog. I reran JuliaFormatter, but can I set up reviewdog locally so I can test before resubmitting the PR ? Appreciate very much if you can give me some pointers! If there is any other thing I should fix - please let me know.

About the paper the final version, shared privately, has much more than the arxiv version https://arxiv.org/abs/2105.01834.