[SciPy-User] Uninformative type error from scipy.optimize.fmin_ncg
John Salvatier
jsalvati at u.washington.edu
Fri Jan 21 17:42:53 EST 2011
My problem turned out to be a poorly specified gradient function. However, I
do think more informative errors are a good idea.
On Fri, Jan 21, 2011 at 1:07 PM, John Salvatier
<jsalvati at u.washington.edu>wrote:
> Hello, I am getting a very uninformative error from scipy.optimize.fmin_ncg
> (posted below).
>
> Traceback (most recent call last):
> File "C:\Program Files
> (x86)\pythonxy\eclipse\plugins\org.python.pydev.debug_1.5.6.2010033101\pysrc\pydevd.py",
> line 953, in <module>
> debugger.run(setup['file'], None, None)
> File "C:\Program Files
> (x86)\pythonxy\eclipse\plugins\org.python.pydev.debug_1.5.6.2010033101\pysrc\pydevd.py",
> line 780, in run
> execfile(file, globals, locals) #execute the script
> File "C:\Users\jsalvatier\workspace\analysis\src\residuals\run.py", line
> 15, in <module>
> sampler.sample(nChains = 5, ndraw = 500, maxGradient = 100)
> File "C:\Python26\lib\site-packages\multichain_mcmc\amala.py", line 150,
> in sample
> mode = scipy.optimize.fmin_ncg(logp, x0, grad_logp, disp = True)
> File "C:\Python26\lib\site-packages\scipy\optimize\optimize.py", line
> 857, in fmin_ncg
> update = alphak * pk
> TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'
>
> As far as I can tell this originates from scipy.optimize.fmin_ncg calling
> line_search_BFGS which calls line_search_armijo which calls
> scalar_search_armijo which returns None if it "Failed to find a suitable
> step length" . This should probably throw an error, so its clearer what went
> wrong. I can open a ticket if that seems appropriate.
>
> However, I cannot tell why it cannot find a suitable step length. Does
> anyone have insight? Here is the output for the return values of the
> optimizing function and the gradient function during the optimization:
>
>
> x [-0.01995784 -1.31632641] value 24706.0435485
> x [-0.01995784 -1.31632641] gradient [ -14.54505377 -295.74692019]
> x [-0.01995762 -1.316322 ] gradient [ -14.5450301 -295.74691824]
> x [-0.01995784 -1.31632641] gradient [ -14.54505377 -295.74692019]
> x [-0.01997875 -1.31607352] gradient [ -14.54744088 -295.74679776]
> x [-0.01995784 -1.31632641] gradient [ -14.54505377 -295.74692019]
> x [ 1.29734797 649.9702011 ] value 875465.803394
> x [ 0.10164492 58.80504953] value 35218.6454954
> x [ 1.68521821e-02 1.68828406e+01] value 23768.2914038
> x [ 1.68521821e-02 1.68828406e+01] gradient [ -13.37003274
> -294.99827255]
> x [ 1.68523813e-02 1.68828450e+01] gradient [ -13.37001056
> -294.99827441]
> x [ 1.68521821e-02 1.68828406e+01] gradient [ -13.37003274
> -294.99827255]
> x [ -68.71915443 -1499.71802395] value 4760337.66401
> x [ 3.60983859 96.15899543] value 44345.9802857
> Traceback (most recent call last):
> File "C:\Program Files
> (x86)\pythonxy\eclipse\plugins\org.python.pydev.debug_1.5.6.2010033101\pysrc\pydevd.py",
> line 953, in <module>
> debugger.run(setup['file'], None, None)
> File "C:\Program Files
> (x86)\pythonxy\eclipse\plugins\org.python.pydev.debug_1.5.6.2010033101\pysrc\pydevd.py",
> line 780, in run
> execfile(file, globals, locals) #execute the script
> File "C:\Users\jsalvatier\workspace\analysis\src\residuals\run.py", line
> 15, in <module>
> sampler.sample(nChains = 5, ndraw = 500, maxGradient = 100)
> File "C:\Python26\lib\site-packages\multichain_mcmc\amala.py", line 150,
> in sample
> mode = scipy.optimize.fmin_ncg(logp, x0, grad_logp, disp = True)
> File "C:\Python26\lib\site-packages\scipy\optimize\optimize.py", line
> 857, in fmin_ncg
> update = alphak * pk
> TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20110121/eb6a3250/attachment.html>
More information about the SciPy-User
mailing list