-
Notifications
You must be signed in to change notification settings - Fork 41
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
quasi_Newton has issue with negative memory size. #340
Comments
Hi, I extracted the following code using LinearAlgebra, Manifolds, ManifoldDiff, Manopt, Random
m, n = 2, 8
H = randn(ComplexF64, m , n)
HtH = H'*H
P = randn(ComplexF64, n, m)
f(M, P) = real(logdet(I(m) + P' * HtH * P))
euclidean_∇f(M, P) = 2HtH*P / (I(m) + P' * HtH * P)
manif = Manifolds.ArraySphere(n, m, field = ℂ)
∇f(M, P) = ManifoldDiff.riemannian_gradient(M, P, euclidean_∇f(get_embedding(M), embed(M, P)))
# Works fine for a positive memory size, does not otherwise
#s = m*m
s = -1
res = @time Manopt.quasi_Newton(manif, f, ∇f, P, memory_size = s, stopping_criterion = StopAfterIteration(2000) | StopWhenGradientNormLess(1e-6)) and can confirm, that this crashes if the memory is set to -1 but does not otherwise. For a nonnegative If you set Manopt.jl/src/plans/quasi_newton_plan.jl Line 405 in da84054
does exactly that, it transforms the tangent vector into coordinates, steps into the matrix multiplication (or solving a linear system in other cases) and then reconstructs the vector. Now the main problem is that on the manifold you want to work with, no one has yet implemented the So this is a problem for Manifolds.jl. I am a bit surprised, since I would have thought that this function would be the fit and also be dispatched to, so it might also be a bug in that functions dispatch indeed. Please open an issue over there. edit: Ah, I see why the linked function does not hit, that one is currently only implemented for the real (abstract) spheres. Yours is complex. On complex spheres one has the small challenge every now and then whether to take a complex basis with real coefficients (twice as many basis vectors, but nice real coefficients) or real basis with complex coefficients (less basis vectors but also complex coefficients). |
If you have the formula for real coordinate basis of tangent spaces to the complex sphere, I can add it to Manifolds.jl. That shouldn't be too hard to derive, you can probably just start from the function written by Ronny and split |
Yes, probably adapting that and getting to a complex-basis-with-real-coefficients vector for complex abstract spheres would be the way to go. For now I just do not have a good idea how to compute that. |
BTW, I'd suggest trying L-BFGS with limited memory on Manopt 0.4.46 (will be released very soon), with Hager-Zhang linesearch from LineSearches.jl. After fixes it has similar performance to Optim.jl on a couple of test problems. |
Note that the L here means |
I started a first sketch, but I have to still figure out the details, mainly in allocation (along the way=) of the actual coefficient vector. If you have a nicer formula, feel free to contribute. And – thanks – this was a nice thing to ponder about during my hike today, and also just about 30 minutes to heck this sketch. |
Yes, it does work quite well. I just raised the issue because, based on the documentation, I wasn't expecting a crash. Thanks to everyone for addressing so quickly and thoughtfully! |
Well, usually one should not expect things to crash ;) But we did start a section with each solver called “Technical Details” that lists which functions one should implement for a manifold for this solver to work. Concerning the open PR on doing the basis you are missing – there are a few minor technical difficulties still, so it might take a while until that is covered, we are but only a very small team working on these packages involved here (originally 3, currently more realistically 2). |
I will close this for now. My idea to compute an ONB for your case was not successful, so to be honest I just have no clue how to provide a good ONB in your case for the manifold you have. I checked the docs and under Technical Derails (as mentioned in my last post) the If you feel the docs could be improved, feel free to comment on this issue and reopening it. |
The attached notebook fails when I set memory_size to -1. I am running Julia 1.9.4 with the following package versions:
IJulia v1.24.2
ManifoldDiff v0.3.10
Manifolds v0.9.11
Manopt v0.4.45
Zygote v0.6.68
I had to save the notebook as a .txt file so Github would allow me to attach.
QuasiNewtonQuestion.txt
The text was updated successfully, but these errors were encountered: