[SciPy-User] optimize.fmin_cg terminates when w - grad*1e-10 yields lower obj & grad

josef.pktd@gmai... josef.pktd@gmai...
Mon Oct 5 12:40:01 CDT 2009


On Mon, Oct 5, 2009 at 12:56 PM, Jason Rennie <jrennie@gmail.com> wrote:
> The low-down:
>
> "Warning: Desired error not necessarily achieved due to precision loss"
> I'm passing objective (obj) and gradient (grad)
> I checked that obj and grad are correct using my python equivalent
> of http://people.csail.mit.edu/jrennie/matlab/checkgrad2.m
> I have the same problem whether I use norm=2 or no norm argument
> Termination objective and 2-norm of grad are 2.484517e+06, 2.644732e+07
> Subtracting grad*1e-10 to parameter vector yields 2.417658e+06, 2.413900e+07
> obj and 2-norm of grad, respectively
>
> I did an implementation of CG in matlab/octave a few years ago and realize
> that the problem could be as simple as me needing to set a different epsilon
> value or some such.  Any suggestions?  Nothing jumped out at me when I gave
> a careful read to the argument list and glanced over the code, but I could
> easily be missing something.  My current call:
> wopt = scipy.optimize.fmin_cg(f = ser.obj, fprime = ser.grad, x0 = w0, norm
> = 2, callback = cb)

Does lowering gtol help?  e.g. gtol=1e-10
I would keep using norm=inf  to force more iterations.

Josef



> OTOH, is it possible that fmin_cg needs additional tuning?  I don't have
> much understanding of how solid the fmin_cg code is.  Has it seen tons of
> use/testing, or is it relatively fresh code?
> FYI, I'm using 0.7.0---the version that comes with the current Ubuntu.  My
> parameter vector is length 12; I have ~50 data points.  I've seen CG work
> quite nicely on data of a million dimensions...
> Thanks,
> Jason
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>


More information about the SciPy-User mailing list