Skip residual

227 views
Skip to first unread message

Jon Zubizarreta Gorostidi

unread,
Jul 3, 2018, 12:50:03 PM7/3/18
to Ceres Solver
Hi all,

I have read in another post that it is not possible to skip a residual.
For example, in the case when a 3d point goes out of boundary in a bundle adjustment problem.

¿Is there any solution for this kind of situations? ¿Settings the residual and jacobian to zero maybe?

Thanks in advance,

Jon

Sameer Agarwal

unread,
Jul 3, 2018, 12:50:39 PM7/3/18
to ceres-...@googlegroups.com
use a robust loss function.
thats the right thing to do.


--
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/be3113f8-8cff-4a01-b943-ddd555bb1607%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jon Zubizarreta Gorostidi

unread,
Jul 3, 2018, 12:54:07 PM7/3/18
to ceres-...@googlegroups.com
Thanks Sameer.

However, in the case where a point goes out of image boundary, I am not able to evaluate its residual neither its jacobian.
Thus, using a robust loss function is not possible.

Jon

On 3 July 2018 at 18:50, 'Sameer Agarwal' via Ceres Solver <ceres-...@googlegroups.com> wrote:
use a robust loss function.
thats the right thing to do.


On Tue, Jul 3, 2018 at 9:50 AM Jon Zubizarreta Gorostidi <jzgor...@gmail.com> wrote:
Hi all,

I have read in another post that it is not possible to skip a residual.
For example, in the case when a 3d point goes out of boundary in a bundle adjustment problem.

¿Is there any solution for this kind of situations? ¿Settings the residual and jacobian to zero maybe?

Thanks in advance,

Jon

--
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+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUDbV%3DT3789jGBYLEyvQDZuB3xGU6eDee%3DUL7a3PUtD%2BjA%40mail.gmail.com.

Sameer Agarwal

unread,
Jul 3, 2018, 12:55:11 PM7/3/18
to ceres-...@googlegroups.com
The solution there is to have a very high cost, not zero cost.

On Tue, Jul 3, 2018 at 9:54 AM Jon Zubizarreta Gorostidi <jzgor...@gmail.com> wrote:
Thanks Sameer.

However, in the case where a point goes out of image boundary, I am not able to evaluate its residual neither its jacobian.
Thus, using a robust loss function is not possible.

Jon
On 3 July 2018 at 18:50, 'Sameer Agarwal' via Ceres Solver <ceres-...@googlegroups.com> wrote:
use a robust loss function.
thats the right thing to do.


On Tue, Jul 3, 2018 at 9:50 AM Jon Zubizarreta Gorostidi <jzgor...@gmail.com> wrote:
Hi all,

I have read in another post that it is not possible to skip a residual.
For example, in the case when a 3d point goes out of boundary in a bundle adjustment problem.

¿Is there any solution for this kind of situations? ¿Settings the residual and jacobian to zero maybe?

Thanks in advance,

Jon

--
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.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.

--
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/CAMi868WiAzOfyUbBV1DjGGHjCcBeOAObpambaxq7SAFjFXj9nQ%40mail.gmail.com.

Jon Zubizarreta Gorostidi

unread,
Jul 3, 2018, 12:59:13 PM7/3/18
to Ceres Solver
And what about the jacobian? Which value should it have?

Thanks,

Jon

Sameer Agarwal

unread,
Jul 3, 2018, 1:00:02 PM7/3/18
to ceres-...@googlegroups.com
if you add the cost in a continuous manner, the jacobian will be affected too.
its important to do this so that the gradient indicates the direction of descent.

Jon Zubizarreta Gorostidi

unread,
Jul 3, 2018, 1:08:53 PM7/3/18
to ceres-...@googlegroups.com
Sorry but I do not understand what you mean by "adding the cost in a continuous manner".

I have a cost function with several residual. Each residual has its value and its jacobian.
Some of the residuals go out of boundary, so I have to deal with them.

I understand the idea of putting a high residual and remove their influence using the loss function.

Jon

Jon

To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUA2F%2BN7vG04fqEB3bDnxn5wsJEY1TWS0cmNK315tX9REw%40mail.gmail.com.

Sameer Agarwal

unread,
Jul 3, 2018, 8:25:49 PM7/3/18
to ceres-...@googlegroups.com
in the cost function if any of the residuals goes out of boundary you can do one of two things.

1. return false. this would make the residual essentially infinite cost.
2. you can add a large slope/penalty to all the residuals which is a function of the distance from the boundary.


--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.

--
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.

Jon Zubizarreta Gorostidi

unread,
Jul 4, 2018, 3:48:42 AM7/4/18
to ceres-...@googlegroups.com
Many thanks for your help Sameer.

However, I still do not know which values should jacobians have for out of boundary residuals.
I think I am missing something.

Jon

To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver+unsubscribe@googlegroups.com.

--
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+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUC5UAX5Y0xQNq2JdoSk%3D4cjsaxN%2BiA2QGh-L2iUxEv_5w%40mail.gmail.com.

Sameer Agarwal

unread,
Jul 6, 2018, 9:26:38 AM7/6/18
to ceres-...@googlegroups.com
whatever you setup as your residual, you should have the derivative of that in the jacobian.
they should always be consistent.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.

--
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.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.

--
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.

Jon Zubizarreta Gorostidi

unread,
Jul 6, 2018, 9:39:27 AM7/6/18
to ceres-...@googlegroups.com
The problem is that if the point goes out of boundary, I cannot evaluate the residual neither the jacobian.
Maybe I should set a behaviour for out of boundaries.

Jon

To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver+unsubscribe@googlegroups.com.

--
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+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver+unsubscribe@googlegroups.com.

--
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+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUDWhUrrZNvbOx1jxGM5p2rmOwu9ueP3avHRPB6FL7kZ-g%40mail.gmail.com.

Sameer Agarwal

unread,
Jul 6, 2018, 9:43:34 AM7/6/18
to ceres-...@googlegroups.com
ah okay, so you have an actual discontinuity. I would recommend in that case that you find a way of smoothly transitioning from your boundary maybe starting on epsilon inside to a sharp penalty term.

also if you are unable to evaluate you can just return false from the cost function, and this will ensure that the solver never goes to these regions - its one way to enforce constraints like these.

Sameer


--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.

--
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.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.

--
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.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.

--
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.

Jon Zubizarreta Gorostidi

unread,
Jul 6, 2018, 12:29:49 PM7/6/18
to ceres-...@googlegroups.com
But if I return false it will stop minimizing.
I just want to skip them or try to remove their influence in the optimization.
I will try penalise them.

Thanks for your insightful help. It is really nice to have this support.

Jon

To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver+unsubscribe@googlegroups.com.

--
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+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver+unsubscribe@googlegroups.com.

--
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+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver+unsubscribe@googlegroups.com.

--
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+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/CABqdRUC0%3D3j0Jj2VF5bJWuCPuNp8codFUMDJqF1tbbh2c_mTmA%40mail.gmail.com.

Sameer Agarwal

unread,
Jul 6, 2018, 4:27:56 PM7/6/18
to ceres-...@googlegroups.com
returning false does not terminate the optimization. 
if you start with initial estimates which are always feasible, returning false ensures that you will always stay feasible.
the important thing is to make sure you do it consistently when doing residual and jacobian evaluation, i.e. it should not be the case that for the same parameter values you return true when only the residual is evaluated but false when jacobian is evaluated too.

Sameer


--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.

--
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.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.

--
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.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.

--
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.

--
You received this message because you are subscribed to a topic in the Google Groups "Ceres Solver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ceres-solver/NtlMWYr1gFE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver...@googlegroups.com.

--
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