Advertisement
jensyao

correct val for BFGS, overflow in N-M, 92 iterations not 14

Feb 9th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. w_start = np.random.rand(*w_exact.shape)
  2. %timeit w_found = minimize(obj,w_start,method = 'Nelder-Mead', args=(x_rand,y))
  3. %timeit w_foundA = minimize(obj,w_start,method = 'BFGS', args=(x_rand,y),jac=obj_gradA)
  4. %timeit w_foundB = minimize(obj,w_start,method = 'BFGS', args=(x_rand,y),jac=obj_gradA)
  5. %timeit w_foundC = minimize(obj,w_start,method = 'BFGS', args=(x_rand,y),jac=obj_gradA)
  6.  
  7. print ('exact val', w_exact)
  8. print (w_found.x, w_found.nfev)
  9. print (w_foundA.x, w_foundA.nfev)
  10. print (w_foundB.x, w_foundB.nfev)
  11. print (w_foundC.x, w_foundC.nfev)
  12. C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\__main__.py:2: RuntimeWarning: overflow encountered in exp
  13.   from ipykernel import kernelapp as app
  14. 100 loops, best of 3: 9.66 ms per loop
  15. 10 loops, best of 3: 32.9 ms per loop
  16. 10 loops, best of 3: 31 ms per loop
  17. 10 loops, best of 3: 30.5 ms per loop
  18. exact val [5 3]
  19. [  1563.51123254  12680.20486013] 165
  20. [ 5.24224     3.15977342] 92
  21. [ 5.24224     3.15977342] 92
  22. [ 5.24224     3.15977342] 92
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement