Duplicate parameters in AddResidualBlock

917 views
Skip to first unread message

Gael Guennebaud

unread,
Oct 26, 2017, 6:32:23 AM10/26/17
to Ceres Solver
Hi,

is it allowed and OK to pass multiple times the same parameter to a single call to AddResidualBlock? A bit more context:

say I have a cost function that is evaluated for each pixel of an image, and this cost function depends on the respective 3x3 image block. For boundary pixels, I apply the same stencil but with boundary values mirrored. So the idea would be to write a single and simple cost function, and handle boundaries when creating the residuals, e.g., for a corner pixel, I would call:

AddResidualBlock(new my_cost(), 0,
   
&img(0,0), &img(0,0), &img(1,0),
   
&img(0,0), &img(0,0), &img(1,0),
   
&img(0,1), &img(0,1), &img(1,1));

and expect that the jacobian contributions of the duplicated parameters to be properly added (whether using analytic derivative or auto-diff).

Gaël.

BTW, I found the documentation of CostFunction::Evaluate misleading because (1) there is a confusion between parameter_block_sizes_.size() and parameter_block_sizes_[i], and (2) the index i here has not the same meaning that the index i of f_i a few lines above. Or is it just me who's not awake?

Sameer Agarwal

unread,
Oct 26, 2017, 5:32:09 PM10/26/17
to ceres-...@googlegroups.com
Gael,
AddResidualBlock requires that the parameter blocks be unique. The problem you mention is very interesting though.

I will look at the docs for CostFunction::Evaluate to make sure it is correct. Are you referring to the header docs, or the ones the header file (they are different).

Sameer

--
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/42c581fa-187a-4373-95a1-07bfb6605ec7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gael Guennebaud

unread,
Oct 30, 2017, 9:08:08 AM10/30/17
to Ceres Solver


Thank you for your reply. Regarding the doc, I was referring to the online one: http://ceres-solver.org/nnls_modeling.html#costfunction.

Sameer Agarwal

unread,
Jan 10, 2018, 4:53:38 PM1/10/18
to ceres-...@googlegroups.com
Gael,
I have revised the docs. I hope it is clearer now.
Sameer


--
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.
Reply all
Reply to author
Forward
0 new messages