Access to current values of optimized parameters from IterationCallback

413 views
Skip to first unread message

Alexander Velizhev

unread,
Nov 8, 2013, 11:07:32 AM11/8/13
to ceres-...@googlegroups.com
Hi!

I'm implementing bundle adjustment with Ceres. 
Usually I have >500 points on the same image and on every iteration for all these points residuals are computed.

I would like to precompute projection matrices for every image after every iteration and after that use them for fast computation of residuals.
For the same image on the same iteration a projection matrix is the same for all points so I'm expecting to have a speed improvement.

I add an IterationCallback and it works perfectly. However I have problems with access to current values of optimized parameters from the callback.
I tried to use ceres::Problem::GetParameterBlocks()  but it seems the parameters are not updated.

So my question is how to access to current values of optimized parameters from the IterationCallback.

Thanks in advance

Alexander

Joydeep Biswas

unread,
Nov 8, 2013, 11:10:00 AM11/8/13
to ceres-...@googlegroups.com
Hi Alexander,

I think the functionality you are referring to is provided by setting
ceres::Solver::Options::update_state_every_iteration to true.

-Joydeep
> --
> You received this message because you are subscribed to the Google Groups
> "Ceres Solver" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ceres-solver...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ceres-solver/31dc630f-5457-4431-9f3e-57decb03270f%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Alexander Velizhev

unread,
Nov 8, 2013, 11:17:12 AM11/8/13
to ceres-...@googlegroups.com
Hi Joydeep!

I've already tried it but it doesn't help...

Alexander

Sameer Agarwal

unread,
Nov 8, 2013, 11:17:18 AM11/8/13
to ceres-...@googlegroups.com
Joydeep's answer is correct. But I am curious, what is the amount of time you are spending in evaluating the Jacobian and Residual (you can see this from Summary::FullReport) and how much speedup are you expecting to get by doing this? 

What you are proposing is fraught with problems because it breaks assumptions made by things like "inner iterations", where we assume that the we can evaluate a cost function at any point at any time without informing the user.

Sameer



Sameer Agarwal

unread,
Nov 8, 2013, 11:18:55 AM11/8/13
to ceres-...@googlegroups.com
You do not need to call GetParameterBlocks, the array that you passed to the solver containing the parameter block values will get updated.

Also as I said, this breaks various invariants inside the solver. For example, iterationcallback only gets called at the end of the iteration, but we evaluate the objective function twice, once with and once without the jacobian, which is why this is not working.

Sameer



Reply all
Reply to author
Forward
0 new messages