Package PyDSTool :: Package Toolbox :: Package optimizers :: Package helpers :: Module levenberg_marquardt
[hide private]
[frames] | no frames]

Source Code for Module PyDSTool.Toolbox.optimizers.helpers.levenberg_marquardt

 1   
 2  # Matthieu Brucher 
 3  # Last Change : 2007-08-23 10:12 
 4   
 5  import quadratic 
 6  import numpy 
 7   
8 -class LMQuadratic(quadratic.Quadratic):
9 """ 10 Defines a cost function with a quadratic cost but the Levenberg-Marquardt approximation of the hessian 11 """
12 - def hessian(self, params):
13 """ 14 Compute sthe hessian of the fit function 15 """ 16 inter = 2 * self.f.gradient(self.x, params)[..., numpy.newaxis] * self.f.gradient(self.x, params)[..., numpy.newaxis, :] 17 shape = inter.shape[-2], inter.shape[-1] 18 inter.shape = (-1, inter.shape[-2] * inter.shape[-1]) 19 temp = numpy.sum(inter, axis = 0) 20 temp.shape = shape 21 return temp
22