scipy.optimize.fmin_cg: "'Desired error not necessarily achieved due to precision loss.'

醉酒当歌 提交于 2019-12-24 14:28:32

问题


I am using scipy.optimize.fmin_cg to minimize a function. The function takes various data sets and the fmin_cg returns good values for a lot of the data sets, except for the first 3 which fail:

DATASET:  0
Warning: Desired error not necessarily achieved due to precision loss.
         Current function value: 2.988730
         Iterations: 1
         Function evaluations: 32
         Gradient evaluations: 5
[ 500.00011672   -0.63965932]

DATASET:  1
Warning: Desired error not necessarily achieved due to precision loss.
         Current function value: 3.076145
         Iterations: 1
         Function evaluations: 32
         Gradient evaluations: 5
[ 500.00013434   -0.58092425]

DATASET:  2
Warning: Desired error not necessarily achieved due to precision loss.
         Current function value: 3.160507
         Iterations: 1
         Function evaluations: 32
         Gradient evaluations: 5
[ 500.00014962   -0.52933729]

DATASET:  3
Optimization terminated successfully.
         Current function value: 4.000000
         Iterations: 1
         Function evaluations: 8
         Gradient evaluations: 2
[ 500.00729686   23.29306024]

DATASET:  4
Optimization terminated successfully.
         Current function value: 4.000000
         Iterations: 1
         Function evaluations: 8
         Gradient evaluations: 2
[ 500.00915456   30.21053839]

DATASET:  5
Optimization terminated successfully.
         Current function value: 4.000000
         Iterations: 1
         Function evaluations: 8
         Gradient evaluations: 2
[ 500.01103431   37.37704849]

DATASET:  6
Optimization terminated successfully.
         Current function value: 4.000000
         Iterations: 1
         Function evaluations: 8
         Gradient evaluations: 2
[ 500.03064942  118.1983465 ]

DATASET:  7
Optimization terminated successfully.
         Current function value: 4.000000
         Iterations: 1
         Function evaluations: 8
         Gradient evaluations: 2
[ 500.03454471  135.11401129]

DATASET:  8
Optimization terminated successfully.
         Current function value: 4.000000
         Iterations: 1
         Function evaluations: 8
         Gradient evaluations: 2
[ 500.03848004  152.4157083 ]

etc....................

The optimised results begin as x0 = [500, -1] initial guesses, lowering 500 to around 300 results in all successes, but no matter what value is picked the results don't tend to anywhere near what is expected. (there should be a large difference, what I get is minute variations, when ratios of up to 4 should be seen between some of them. However, the second value in the returned array behaves as expected)

来源:https://stackoverflow.com/questions/31474895/scipy-optimize-fmin-cg-desired-error-not-necessarily-achieved-due-to-precisio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!