[SciPy-user] fmin_l_bfgs_b problem

bulatov at cs.orst.edu bulatov at cs.orst.edu
Tue Aug 10 03:59:57 CDT 2004


> On Mon, Aug 09, 2004 at 02:39:59AM -0700, bulatov at cs.orst.edu wrote:
> > Was anyone able to use fmin_l_bfgs_b optimizer successfully?
> 
> Well, I wrote the wrapper, so I hope so :-)
> 
> > When I run it with the same parameters as the fmin_bfgs example in the
tutorial,
> > I get the error:
> > 
> > xopt = fmin_l_bfgs_b(log_likelihood, x0, fprime=log_likelihood_der)
> > File "C:\Python23\Lib\site-packages\scipy\optimize\lbfgsb.py", line 174, in
fm
> > in_l_bfgs_bisave, dsave)
> > error: failed in converting 7th argument `g' of _lbfgsb.setulb to C/Fortran
> > array
> 
> > Are you sure log_likelihood_der returns an array (of the same length as
x0)?

I found the problem :) Log_likelihood_der returned Numarray array instead of
Numeric array. That happened because I couldn't find "zeros" function in SciPy,
so I used numarray.zeros to initialize array. When I changed numarray.zeros to
Numeric.zeros, problem was fixed.

For the future...how do I debug these kinds of problems? I looked in lbfgs.pyf,
but couldn't quite understand why Numeric arrays were required

Yaroslav



More information about the SciPy-user mailing list