Skip to content

Instantly share code, notes, and snippets.

@thomasaarholt
Created January 18, 2017 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasaarholt/d9506d0fc25657d3da3aab5aad50a735 to your computer and use it in GitHub Desktop.
Save thomasaarholt/d9506d0fc25657d3da3aab5aad50a735 to your computer and use it in GitHub Desktop.
>>> m.fit(fitter="L-BFGS-B", bounded=True, grad=True)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-118-e2c35f346c6e> in <module>()
50
51 #m.fit(fitter="leastsq", bounded=True, grad=True)
---> 52 m.fit(fitter="L-BFGS-B", bounded=True, grad=True)
53
54
/Users/thomas/Dropbox/0_Git/hyperspy/hyperspy/models/eelsmodel.py in fit(self, fitter, method, grad, bounded, ext_bounding, update_plot, kind, **kwargs)
347 ext_bounding=ext_bounding,
348 update_plot=update_plot,
--> 349 **kwargs)
350 else:
351 raise ValueError('kind must be either \'std\' or \'smart\'.'
/Users/thomas/Dropbox/0_Git/hyperspy/hyperspy/model.py in fit(self, fitter, method, grad, bounded, ext_bounding, update_plot, **kwargs)
1154 self.p0 = minimize(tominimize, self.p0, jac=fprime,
1155 args=args, method=fitter,
-> 1156 bounds=self.free_parameters_boundaries, **kwargs).x
1157
1158 # Global optimizers
/Users/thomas/miniconda3/envs/hs/lib/python3.5/site-packages/scipy/optimize/_minimize.py in minimize(fun, x0, args, method, jac, hess, hessp, bounds, constraints, tol, callback, options)
448 elif meth == 'l-bfgs-b':
449 return _minimize_lbfgsb(fun, x0, args, jac, bounds,
--> 450 callback=callback, **options)
451 elif meth == 'tnc':
452 return _minimize_tnc(fun, x0, args, jac, bounds, callback=callback,
/Users/thomas/miniconda3/envs/hs/lib/python3.5/site-packages/scipy/optimize/lbfgsb.py in _minimize_lbfgsb(fun, x0, args, jac, bounds, disp, maxcor, ftol, gtol, eps, maxfun, maxiter, iprint, callback, maxls, **unknown_options)
326 # until the completion of the current minimization iteration.
327 # Overwrite f and g:
--> 328 f, g = func_and_grad(x)
329 elif task_str.startswith(b'NEW_X'):
330 # new iteration
/Users/thomas/miniconda3/envs/hs/lib/python3.5/site-packages/scipy/optimize/lbfgsb.py in func_and_grad(x)
277 def func_and_grad(x):
278 f = fun(x, *args)
--> 279 g = jac(x, *args)
280 return f, g
281
/Users/thomas/Dropbox/0_Git/hyperspy/hyperspy/models/model1d.py in _gradient_ls(self, param, y, weights)
513 def _gradient_ls(self, param, y, weights=None):
514 gls = (2 * self._errfunc(param, y, weights) *
--> 515 self._jacobian(param, y)).sum(1)
516 return gls
517
/Users/thomas/Dropbox/0_Git/hyperspy/hyperspy/models/model1d.py in _jacobian(self, param, y, weights)
455 np.add(par_grad, np.convolve(
456 par.grad(
--> 457 self.convolution_axis),
458 self.low_loss(self.axes_manager),
459 mode="valid"), par_grad)
TypeError: 'NoneType' object is not callable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment