1
2
3
4
5 import quadratic
6 import numpy
7
9 """
10 Defines a cost function with a quadratic cost but the Levenberg-Marquardt approximation of the hessian
11 """
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