0

I'm trying to minimize multivariate function with SciPy optimization minimize function. The code I'm using to call the function:

res = minimize(self.score_gradient, self.initialized_theta, (x,y),'newton-cg', jac = True, tol = 1e-6, options = {'maxiter':100 ,'disp':True })

score_gradient calculates the score and the jacobian/gradient. The jacobian/gradient was checked numerically. The score printed in command line after calculation, and I see the following in command line:

3.3275625564
3.34459750933
3.32755781796
3.34459750933
3.32755307725
3.34459750933
3.32754833425
3.34459750933
3.32754358897
3.34459750933
3.32753884139
3.34459750933
3.3275340915
3.34459750933
3.32752933931
3.34459750933

As you can see there is one calculation giving the same result and other minimizing the score as expected. But the function stuck in this calculation for more than half a day, while in MATLAB this calculation takes no more than couple of hours. I know that MATLAB was probably using different optimization algorithm. Somebody saw this behavior and can point what I am doing wrong?

Dmitry Shvedov
  • 3,169
  • 4
  • 39
  • 51
  • 1
    Using ``jac=True``, your function ``score_gradient`` needs to return the jacobian too; so with only the command and the "result", it's really quite difficult to tell you what's going wrong among all those things, unless someone experienced the exact same problem... Adding a minimal working example with your function and initialization would help us help you... – Silmathoron Jun 13 '16 at 19:48
  • As i said in the post `score_gradient` calculates the jacobian, and i checked it numerically. I think this behavior caused only by `newton-cg` algorithm because i have not see same behavior with `cg` algorithm – Anton Losev Jun 18 '16 at 12:02
  • I'm currently having a similar problem to yours. Did you find out what was the problem? – David Lasry Jul 07 '20 at 15:59
  • Sorry can not really remember or find the project – Anton Losev Jul 30 '20 at 19:16

0 Answers0