facebookresearch / theseus

A library for differentiable nonlinear optimization
MIT License
1.74k stars 124 forks source link

Bug Report in implicit mode and truncated mode, but no problem in unroll mode #578

Closed xphsean12 closed 1 year ago

xphsean12 commented 1 year ago

❓ Questions and Help

As the title described, I encountered a situation where the unroll mode works well while the implicit and truncated mode does not. The bug is reported as below. I have read the comparison of different mode in your paper. In the case where I give a good initialization, the implicit mode still does not work. And Hint for me? Many thanks! By the way, I am still using 0.1.4. If the version matters, please tell me. image

luisenp commented 1 year ago

Sometimes this happens because we turn damping off in the final step of implicit differentiation; however, I'm not sure why you are having errors with truncated.

Do you have a simple repro (a few lines of code) that you can share?

xphsean12 commented 1 year ago

Sometimes this happens because we turn damping off in the final step of implicit differentiation; however, I'm not sure why you are having errors with truncated.

Do you have a simple repro (a few lines of code) that you can share?

Thanks for your reply. Currently, I am working on my examination, so I will be busy for a while. I will update the problem ASPA. Since I have constructed a complicated factor graph, I will try to simplify the graph to see whether I can make it compact to share with you.

luisenp commented 1 year ago

Hi @xphsean12. We have added a fallback for this type of error in #579. Can you check if this works for your use case?

xphsean12 commented 1 year ago

I will try later. By the way, I use LM as the Optimizer (Since I saw the issue is for Gauss-Newton method)

xphsean12 commented 1 year ago

Hi @xphsean12. We have added a fallback for this type of error in #579. Can you check if this works for your use case?

Latest update: Currently, I am using 0.2.0. After adding some lines in #579, it works for LM method, implicit mode and unroll mode. However, Gauss-Newton does not works well (implicit and unroll). The error is as below: image image

luisenp commented 1 year ago

I don't think this is a bug, but probably a consequence of your optimization problem being ill-conditioned. We don't add any damping or regularization when using Gauss-Newton.