コード例 #1
0
 def inner(theta):
     """ Returned closure. """
     y = 0.0
     g = np.zeros_like(theta)
     n = len(theta)
     h = np.zeros((n, n))
     for (traj, choice) in traj_choices:
         elts = LearningElements0(traj, theta, choice)
         elts.computeValue()
         y += elts.logValue
         elts.computeGradientValue()
         g += elts.grad_logValue
         elts.computeHessianValue()
         h += elts.hess_logValue
     return (y, g, h)