How to weighting to the number of observations in a regularized nonlinear least squares?

538 views
Skip to first unread message

hwdo...@gmail.com

unread,
Feb 6, 2017, 10:11:34 PM2/6/17
to Ceres Solver
I want to solve a PCA based fitting problem and want to regularize the PCA parameters. 
I weighted the two terms for data fitting and parameter regularization. 

 Suppose the number of observations is m,the number of theta is n.  I use w1 and w2 to weight the two terms. the formula is:
     w1/(2m) *sum_i(||f(xi,yi, theta||^2) + w2/n *||theta||^2  

 Where these {(xi,yi)} are observations and theta are shape parameters

The weight w1 and w2 is fixed, so  we should divided by m. 

I chosed  w1 and w2 for m=50 by experiment, when I add more observations (some may be noisy),that is become larger, the result become bad and resulted shape is the mean shape although the theta are not zeros.

What's the problem? 

Another question:

I also used the  bounds constrained non-linear least squares without parameter regularization,it seems works. But it is very very slow compared to matlab's lsqlin.  Why ceres -solver so slow than matlab (matlab is 30X faster than ceres-solver)? 

hwdo...@gmail.com

unread,
Feb 6, 2017, 10:21:28 PM2/6/17
to Ceres Solver
The weight for data fitting is coded as :
         residuals[0] *= shape_weight;
residuals[1] *= shape_weight;
and the weight for regularization is coded as :
     residual[i] = prior_weight * x[i];

Where the  shape_weight = w1/(2m) and prior_weight = w2/n

Sameer Agarwal

unread,
Feb 7, 2017, 12:23:29 AM2/7/17
to Ceres Solver
you need to take the square root of the weights for one.
secondly can you share the execution log and the output of Summary::FullReport() ?

--
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/a960b0e9-5b8a-4278-9bdc-557cc8c36161%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

hwdo...@gmail.com

unread,
Feb 7, 2017, 2:43:02 AM2/7/17
to Ceres Solver
Thank you. What do meannig by "...weights for one"?
Do you mean the code for weights should be:
      shape_weight = sqrt( w1/(2m) ) and prior_weight = sqrt( w2/n)
 or  
      shape_weight = sqrt( w1) /(2m)  and prior_weight = sqrt( w2) /n

Which should I use?
The the execution log is too log in cmd windows, should I log to a file ?
I think I should try  the square root of the weights?

hwdo...@gmail.com

unread,
Feb 7, 2017, 4:32:21 AM2/7/17
to Ceres Solver
I tried both ways but failed too. Do ceres-solver divided the number of observation internally?  
I want w1 and w2 independent of the  the number of observation.

Sameer Agarwal

unread,
Feb 9, 2017, 9:38:42 AM2/9/17
to Ceres Solver
no ceres does not do any sort of division. it takes the problem as you give it.

hwdo...@gmail.com

unread,
Mar 9, 2017, 2:39:22 AM3/9/17
to Ceres Solver
Thank you. It seems it sometimes hard to converges ant the time is very very long.

Sameer Agarwal

unread,
Mar 9, 2017, 2:44:16 AM3/9/17
to Ceres Solver
can you share the output of Summary::FullReport ?

Reply all
Reply to author
Forward
0 new messages