Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- w_start = np.random.rand(*w_exact.shape)
- %timeit w_found = minimize(obj,w_start,method = 'Nelder-Mead', args=(x_rand,y))
- %timeit w_foundA = minimize(obj,w_start,method = 'BFGS', args=(x_rand,y),jac=obj_gradA)
- %timeit w_foundB = minimize(obj,w_start,method = 'BFGS', args=(x_rand,y),jac=obj_gradA)
- %timeit w_foundC = minimize(obj,w_start,method = 'BFGS', args=(x_rand,y),jac=obj_gradA)
- print ('exact val', w_exact)
- print (w_found.x, w_found.nfev)
- print (w_foundA.x, w_foundA.nfev)
- print (w_foundB.x, w_foundB.nfev)
- print (w_foundC.x, w_foundC.nfev)
- C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\__main__.py:2: RuntimeWarning: overflow encountered in exp
- from ipykernel import kernelapp as app
- 100 loops, best of 3: 9.66 ms per loop
- 10 loops, best of 3: 32.9 ms per loop
- 10 loops, best of 3: 31 ms per loop
- 10 loops, best of 3: 30.5 ms per loop
- exact val [5 3]
- [ 1563.51123254 12680.20486013] 165
- [ 5.24224 3.15977342] 92
- [ 5.24224 3.15977342] 92
- [ 5.24224 3.15977342] 92
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement