Parameter block becoming constant after first interation

482 views
Skip to first unread message

Arindam Saha

unread,
Dec 18, 2017, 6:44:04 AM12/18/17
to Ceres Solver
Hi,

I am very new to ceres and trying to write an optimization for depth estimation using photometric matching. My parameter block is the coefficient of a normal of plane in 3D. The plane is projecting to 2D images and estimating the photometric error based on the variance. The code is attached. I am getting error of parameter block is getting constant from second iteration. below is the error msg. The source is attached. Require help on this.

WARNING: Logging before InitGoogleLogging() is written to STDERR
W1218 17:12:47.548861 30271 residual_block.cc:131] 

Error in evaluating the ResidualBlock.

There are two possible reasons. Either the CostFunction did not evaluate and fill all    
residual and jacobians that were requested or there was a non-finite value (nan/infinite)
generated during the or jacobian computation. 

Residual Block size: 1 parameter blocks x 2 residuals

For each parameter block, the value of the parameters are printed in the first column   
and the value of the jacobian under the corresponding residual. If a ParameterBlock was 
held constant then the corresponding jacobian is printed as 'Not Computed'. If an entry 
of the Jacobian/residual array was requested but was not written to by user code, it is 
indicated by 'Uninitialized'. This is an error. Residuals or Jacobian values evaluating 
to Inf or NaN is also an error.  

Residuals:       0.00815062 Uninitialized 

Parameter Block 0, size: 3

 -4.1256e-07 | Not Computed  Not Computed  
  0.00018514 | Not Computed  Not Computed  
 3.32432e-07 | Not Computed  Not Computed  


W1218 17:12:47.549628 30271 trust_region_minimizer.cc:729] Step failed to evaluate. Treating it as a step with infinite cost
   1  1.797693e+308   -1.80e+308    0.00e+00   1.85e-04  -inf  5.00e+03        0    1.61e+00    2.97e+00

Alex Stewart

unread,
Dec 18, 2017, 7:20:13 AM12/18/17
to ceres-...@googlegroups.com
The problem is that your cost function is not setting the value of the residual when called by Ceres, that is what the 'Uninitialized' qualifier means in this line of the output:

Residuals:       0.00815062 Uninitialized 

as explained in this line of the output:

"If an entry of the Jacobian/residual array was requested but was not written to by user code, it is indicated by 'Uninitialized'. This is an error."

So, in your CostFunction you are missing a line like this:

residuals[0] = xxx;

as per the examples.  The fact that the parameters for this residual are held constant isn't relevant.

-A


--
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/97fc0f89-1e6a-48d0-a10c-0ad828f970fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Arindam Saha

unread,
Dec 18, 2017, 7:33:51 AM12/18/17
to ceres-...@googlegroups.com
I do have that kind of line in my function. I would suggest you to have a look into my attached source code.

Another stuff, the very first iteration run successfully, the error comes from the second iteration.. the output is given below. The parameter values are changes a lot in the very first iteration. My parameter initialization are 2.85642e-06, -4.95992e-09 and 1.65106e-06 which changed to -4.1256e-07, 0.00018514, 3.32432e-07 after first iteration.



iter      cost      cost_change  |gradient|   |step|    tr_ratio  tr_radius  ls_iter  iter_time  total_time
   0  9.405683e-06    0.00e+00    4.76e+00   0.00e+00   0.00e+00  1.00e+04        0    1.36e+00    1.36e+00

WARNING: Logging before InitGoogleLogging() is written to STDERR
W1218 17:12:47.548861 30271 residual_block.cc:131] 

Error in evaluating the ResidualBlock.

There are two possible reasons. Either the CostFunction did not evaluate and fill all    
residual and jacobians that were requested or there was a non-finite value (nan/infinite)
generated during the or jacobian computation. 

Residual Block size: 1 parameter blocks x 2 residuals

For each parameter block, the value of the parameters are printed in the first column   
and the value of the jacobian under the corresponding residual. If a ParameterBlock was 
held constant then the corresponding jacobian is printed as 'Not Computed'. If an entry 
of the Jacobian/residual array was requested but was not written to by user code, it is 
indicated by 'Uninitialized'. This is an error. Residuals or Jacobian values evaluating 
to Inf or NaN is also an error.  

Residuals:       0.00815062 Uninitialized 

Parameter Block 0, size: 3

 -4.1256e-07 | Not Computed  Not Computed  
  0.00018514 | Not Computed  Not Computed  
 3.32432e-07 | Not Computed  Not Computed  


W1218 17:12:47.549628 30271 trust_region_minimizer.cc:729] Step failed to evaluate. Treating it as a step with infinite cost
   1  1.797693e+308   -1.80e+308    0.00e+00   1.85e-04  -inf  5.00e+03        0    1.61e+00    2.97e+00
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/EuFgpuQ-cho/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/CADGyVzjcOek2fWoQq15JpRDbn1JkUKhkoJdFraVqSXMj1-pG%2Bg%40mail.gmail.com.

Sameer Agarwal

unread,
Dec 18, 2017, 8:22:04 PM12/18/17
to ceres-...@googlegroups.com
Arindam,
There is no code attached to your email.


On Mon, Dec 18, 2017 at 6:03 PM Arindam Saha <arind...@gmail.com> wrote:
I do have that kind of line in my function. I would suggest you to have a look into my attached source code.

Another stuff, the very first iteration run successfully, the error comes from the second iteration.. the output is given below. The parameter values are changes a lot in the very first iteration. My parameter initialization are 2.85642e-06, -4.95992e-09 and 1.65106e-06 which changed to -4.1256e-07, 0.00018514, 3.32432e-07 after first iteration.

The error is clear, somewhere in your jacobian evaluation you are not assigning the jacobian for a particular parameter block.

Sameer

 
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/EuFgpuQ-cho/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/CAG4OdVTceHxFDx2%2BRDLCrR5FhpmFu60GwpkcdV9qTOiQOA47qQ%40mail.gmail.com.

Arindam Saha

unread,
Dec 18, 2017, 11:34:51 PM12/18/17
to ceres-...@googlegroups.com
Sorry.. now it is attached..

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/EuFgpuQ-cho/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/EuFgpuQ-cho/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/CABqdRUDLacOmkd2pgMbpTzOOYX4bnjpjosPUD_KLFa2id9soCA%40mail.gmail.com.
Opti.txt

Sameer Agarwal

unread,
Dec 19, 2017, 2:53:56 AM12/19/17
to ceres-...@googlegroups.com
Arindam,

Your cost functor is huge. It is not clear to me why you are iterating over all the image pixels and images inside a single cost function. Why are you not creating a single small costfunction per term in your objective function and adding it to your problem object?

Also its odd that you are computing a scalar cost inside the cost function.

secondly, your costfunction factor declares that the CostFunction depends on one parameter block of size 3, and a residual of size 2, but you only ever assign residuals[0], and do not assign residuals[1]. 

The error that you are getting is related to that, it is expecting that you will initialize both residuals, but is not getting that.

Residuals:       0.00815062 Uninitialized 

is the key line.

Sameer


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/EuFgpuQ-cho/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/EuFgpuQ-cho/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/CAG4OdVS%3DU59EwKr59r%2BzD8OA5JdbnEVf0XVVvbKMZCVVuzHNqQ%40mail.gmail.com.

Arindam Saha

unread,
Dec 19, 2017, 5:53:12 AM12/19/17
to ceres-...@googlegroups.com
Dear Sameer,

Thanks for pointing out the error. This solve my problem.

As you rightly suggested I would modify the cost function as per your suggestion.

Arindam

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/EuFgpuQ-cho/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/EuFgpuQ-cho/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ceres-solver+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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/EuFgpuQ-cho/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/CABqdRUCWgXSLkcnH3QXLHE7VciHtzg%3DjjHHta1pfM-wC626vyA%40mail.gmail.com.

Keir Mierle

unread,
Dec 21, 2017, 12:59:09 AM12/21/17
to ceres-...@googlegroups.com
Hi Arindam,

The big long error reported by Ceres you posted is intended to clearly explain the problem, but you are not the first user who didn't know how to proceed given the error message. This suggests the error message is not good enough. Can you help us enhance the error message? What thought process did you go through when reading the error? How could it be improved for you so you would have understood the issue without needing to mail the list?

We try and make the error reporting in Ceres quite in depth, so this is something we take seriously.

Thanks and happy optimizing,
Keir

Arindam Saha

unread,
Dec 26, 2017, 2:50:54 AM12/26/17
to ceres-...@googlegroups.com
I think if the error message says that the residual is of size 2 and only one is initialized, then it would be easy to understand.

Reply all
Reply to author
Forward
0 new messages