# Patent

## Title
Method for an optimizing predictive model using gradient descent and conjugate residuals

## Abstract

An optimization in machine learning is achieved using Newton's algorithm together with an efficient technique for solving linear equations, such as the method of conjugate residuals. The techniques of the present invention are applicable to learning language models, predicting classes of objects from images and videos, and classifying financial transactions for prevention of fraud. Other uses include determining a function from a sequence of words to a relevant web page for a search engine, or to inverting arbitrary output values of an analyzed system into an internally running simulation.

## Background
CROSS REFERENCE TO RELATED APPLICATIONS
The present application relates to and claims priority of U.S. provisional patent application (“Provisional Application”), Ser. No. 61/757,668, entitled “Method for An Optimizing Predictive Model using Gradient Descent and Conjugate Residuals,” filed on Jan. 28, 2013. The disclosure of the Provisional Application is hereby incorporated by reference in its entirety.


BACKGROUND OF THE INVENTION
1. Field of the Invention
The present invention relates to improving computational and statistical efficiency in a predictive model. In particular, the present invention relates to improving computational efficiency in a predictive model that is optimized using gradient and higher-order derivative-based methods, such as stochastic gradient descent or Newton's steps based optimization techniques.
2. Discussion of the Related Art
In machine learning, a predictive model is a computational model that learns a function (“target function”) from example input and output values. One type of predictive model applies a gradient descent optimization technique over an objective function. Typically, the optimization procedure involves iteratively executing the model, and then differentiating the model (i.e., calculating the first derivative of each model parameter) to adapt the values of the model parameters to minimize or maximize the objective function. The complexity of such a computation task is typically at least proportional to the size of the model. Therefore, it is desirable to have a model that is smaller, and which requires fewer computational operations.
A predictive model may be implemented, for example, in a neural network. A neural network model is usually based on a graph consisting of nodes (referred to as “neurons”), and directed, weighted edges that connect the neurons. The directed graph typically represents the function that is to be computed in the computational model. In a typical implementation, each neuron is assigned a simple computational task (e.g., a linear transformation followed by a squashing function, such as a logistic function) and the loss function (e.g., an additive inverse of the objective function) is computed over the entire neural network model. The parameters of the neural network model are typically determined (“learned”) using a method that minimizes the loss function. Stochastic gradient descent is a method that is often used to achieve the minimization. In stochastic gradient descent, optimization is achieved iteratively by (a) finding analytical gradients for the loss functions and (b) perturbing or moving the test values by a small amount in the opposite direction of the gradient, until the loss function is minimized.
SUMMARY
The present invention provides an optimization method for machine learning, using a gradient descent method (e.g., Newton's algorithm) together with an efficient technique for solving a set of linear equations (e.g., the method of conjugate residuals). The techniques of the present invention are applicable to learning language models, predicting classes of objects from images and videos, and classifying financial transactions for prevention of fraud. Other uses include determining a function from a sequence of words to a relevant web page for a search engine, or to inverting arbitrary output values of an analyzed system into an internally running simulation.
The present invention is better understood upon consideration of the detailed description below.



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 is a block diagram of one implementation of optimizing predictive model 100 for learning a target function, according to one embodiment of the present invention.



DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
In machine learning, the parameters of a program may be optimized to achieve one or more objectives of the program. One optimization method computes the first derivatives of such parameters of the program, which are then used in a gradient descent method. Techniques have been developed to improve performance at the gradient descent step, such as by adding a momentum term (e.g., making the gradient carry over some of its previous values) or making the gradient descent method stochastic. Still, many programs have been difficult to optimize using these methods.
Newton's algorithm, which uses second derivatives, has also been used in many optimization techniques. In a multivariate problem, the Newton's step requires an update of parameter values in the form:

Xi+1=Xi−H−1G 

where the elements of vector Xi are the parameter values at step i, the matrix H−1 is the inverse of the Hessian matrix of all second derivatives of the objective function that is to be minimized with respect to every pair of parameter values, and G is the gradient vector of the objective function. For an arbitrary function to be learned, however, the number of parameter values (i.e., variables) often exceeds a few million. In that example, the Hessian matrix H will have more than a trillion second derivatives. Such a matrix is very difficult to store. However, one observes that matrix H−1 is involved only in a matrix multiplication between it and the gradient vector G. Therefore, when one solves the set of linear equations Hz=G in an efficient way, the solution z is the multiplication result that is achieved without expressly performing the multiplication. This is because, by solving the equation Hz=G, the solution vector obtained is z=H−1 G, which is the required multiplication.

One difficulty that limits the use of this method in optimizing programs (e.g., in the neural networks context) is the fact that techniques for solving the set of equations Hz=G are relatively readily available only when the Hessian matrix H is positive definite, but much less readily available otherwise. In general, as the Hessian matrix is not necessarily positive definite, approximations to the Hessian matrix (e.g., the Gauss-Newton approximation) have been used.
The present inventor recognizes that the method of conjugate residuals can be used to iteratively solve the linear equations Hz=G, without requiring Hessian matrix H to be positive definite, or to use a positive definite approximation {tilde over (H)} of the Hessian matrix H. The method of conjugal residuals is described, for example, in the article, “The Conjugate Residual Method for Constrained Minimization Problems,” by David G. Luenberger, published in Siam J., Numer. Anal., Vol. 7, No. 3, September 1970, pp. 390-98, which is also available at http://www.stanford.edu/dept/MSandE/cgi-bin/people/faculty/luenberger/pdfs/tcrmfcmp.pdf. Under the conjugate residual method, the Hessian matrix H is required only to be symmetric, which is true in many cases of typically used program structures. It also requires being able to multiple the Hessian by arbitrary vectors z. The multiplication Hz is easily carried out by forward differentiation starting with the forward derivatives of the model parameters set at z, and ending at the gradient computation for the original program.
According to one embodiment of the present invention, therefore, an optimization algorithm for machine learning is achieved by combining the method of conjugate residuals—i.e., the method for achieving multiplication by the inverse Hessian matrix efficiently—with Newton's algorithm. The techniques of the present invention are applicable to learning language models, predicting or identifying classes of objects from images and videos, and classifying financial transactions for prevention of fraud. Other applications include determining a function from a sequence of words to a relevant web page for a search engine, or to inverting arbitrary output values of an analyzed system into an internally running simulation.
In one embodiment, to solve the equation Hz=G, the method sets initial values z0, r0=G−Hz0 and p0=r0, and iterates over index k as follows:



  
    
      α
      k
    
    =
    
      
        
          r
          k
          T
        
        ⁢
        
          Hr
          k
        
      
      
        
          
            (
            
              Hp
              k
            
            )
          
          T
        
        ⁢
        
          
        
        ⁢
        
          Hp
          k
        
      
    
  




  
    
      z
      
        k
        +
        1
      
    
    =
    
      
        z
        k
      
      +
      
        
          α
          k
        
        ⁢
        
          p
          k
        
      
    
  




  
    
      r
      
        k
        +
        1
      
    
    =
    
      
        r
        k
      
      -
      
        
          α
          k
        
        ⁢
        
          Hp
          k
        
      
    
  




  
    
      β
      k
    
    =
    
      
        
          r
          
            k
            +
            1
          
          T
        
        ⁢
        
          Hr
          
            k
            +
            1
          
        
      
      
        
          r
          k
          T
        
        ⁢
        
          Hr
          k
        
      
    
  




  
    
      p
      
        k
        +
        1
      
    
    =
    
      
        r
        
          k
          +
          1
        
      
      +
      
        
          β
          k
        
        ⁢
        
          p
          k
        
      
    
  




  
    
      Hp
      
        k
        +
        1
      
    
    =
    
      
        Hr
        
          k
          +
          1
        
      
      -
      
        
          β
          k
        
        ⁢
        
          Hp
          k
        
      
    
  



The iteration terminates when ∥rk∥ is sufficiently close to zero. Alternatively, iteration continues if αk>0, or if −c<βk<c, where c is a positive constant value.
One implementation of the above conjugate residual algorithm is provided by the Lisp code below:












// Run conjugate gradient (residual) to multiply the inverse of the Hessian


// by the gradient. Start with p_0 = the current gradient


(def ‘ad-rg (lambda (model)


(let len (length model)


(let decide (ad-new 1 1)


(let r_l2_best _1000000 (let r_l2 _1000000


(let beta_n _0 (let beta _0 (let alpha_n _0 (let alpha_d _0 (let


alpha _0


(let R (marray) (let P (marray) (let X (marray)


(let AR nil (let AP (marray)


(progn


(repeat i len // Initialize the vectors


 (let rm (aref g_acc i)


 (progn


 (push-back R (matrix-copy rm (ad-same rm)))


 (push-back P (matrix-copy rm (ad-same rm)))


 (push-back X (matrix_setconstant (ad-same rm) _0)))))


(set AR (ad-hessian-times R model _0))


(repeat i len // AP has memory apart from ad


 (push-back AP (matrix-copy (aref AR i) (ad-same (aref AR i)))))


(repeat gen 16 // g_gradient_groups


 // Entering here AR and AP are set


 (progn


 // (print ‘model_l2 (matrix-a-dot model model) eol)


 (set alpha_n (matrix-a-dot R AR))


 (set alpha_d (matrix-a-dot AP AP))


 // (print ‘alpha_n space alpha_n space ‘alpha_d space alpha_d eol)


 (set alpha (/ alpha_n (+ _0.1 alpha_d)))


 // (print ‘alpha space alpha eol)


 // increment R (k+1)


 (repeat i len (matrix-add (aref AP i) (aref R i) (− _0 alpha)))


 (set r_l2 (sqrt (matrix-a-dot R R)))


 // (print ‘R_L2 space r_l2 eol)


 // increment AR (k+1)


 (set AR (ad-hessian-times R model _0))


 (set beta_n (matrix-a-dot R AR))


 (set beta (/ beta_n (+ _0.1 alpha_n)))


 // (print ‘beta space beta eol)


 (if (or (< alpha _0)


  (< r_l2_best r_l2) (< _1 beta) (< beta _−1))


 (matrix_setcell decide 0 0 _0)


 (matrix_setcell decide 0 0 _1))


 (mpi-matrix-rank0-all decide)


 (if (< (matrix_dot decide decide) _0.5) break


 (progn


 (set r_l2_best r_l2)


 // increment X (k+1)


 (repeat i len (matrix-add (aref P i) (aref X i) alpha))


 // increment P (k+1)


 (repeat i len


 (matrix-add-2f (aref R i) (aref P i) _1 beta))


 // increment AP (k+1)


 (repeat i len


 (matrix-add-2f (aref AR i) (aref AP i) _1 beta))


 ))))


X)))))))))))))))))









FIG. 1 is a block diagram of one implementation of optimizing predictive model 100 for learning a target function, according to one embodiment of the present invention. In this description, merely by way of example, the target function is described as a textual search function performed over training data consisting of a corpus of documents. However, as mentioned above, many other suitable applications are possible and within the scope of the present invention. As shown in FIG. 1, optimizing predictive model 100 includes learning program 101, which implements the target function to be learned. Learning program 101 receives input vector 104 from the training data and model parameter values 107 to provide output vector 105. Input vector 104 may include, for example, the textual search query. Output vector 105 is, for example, a “best document” probability distribution computed by learning program 101 based on model parameter values 107 over the documents in the training data. Integrated into learning program 101 is stochastic gradient descent module 102 which carries out evaluations of the loss or error function and the gradient vector 106 for the loss or error function with respect to model parameters values 107. In stochastic gradient descent module 102, the above-described Newton's method is used in conjunction with the method of conjugate residuals to obtain output vector 105 and gradient vector 106, which are then provided to parameter update module 103. Updated parameter values 107 are fed back into configuring learning program 101. Learning program 101 may be implemented in a computational environment that includes a number of parallel processors. In one implementation, each processor may be a graphics processor, to take advantage of computational structures optimized for arithmetic typical in such processors. Control unit 108 (e.g., a host computer system using conventional programming techniques) may configure the computational model for each program to be learned. Learning program 101 may be organized, for example, as a neural network model. The program model implemented in learning program 101 may be variable, taking into account, for example, the structure and values of the input vector and the structure and values of the expected output data. Control flow in the program model may be constructed based on the input vector or intermediate values (“states values”) computed in the program model.
Computational models that are created using similar machine learning techniques find applications in, for example, predicting a possible next word or phrase in a text sequence, such as frequently encountered in a speech recognition application, for example. Another example is a document search application which identifies documents containing text segments from which a given text segment may likely have originated. This application is useful in searching text based on an approximate or incomplete query. The methods of the present invention may be used to build other search engines over text.
The above detailed description is provided to illustrate the specific embodiments of the present invention and is not intended to be limiting. Numerous modifications and variations within the scope of the present invention are possible. The present invention is set forth in the following claims.

## Claims

1. A method for training a program by optimizing a set of program parameter values, comprising optimizing the parameter values using the Newton's algorithm, wherein successive updates of the parameter values are provided by a method of conjugate residuals, which computes each of the successive updates by solving a set of linear equations involving a Hessian matrix and a gradient vector.

2. A method as in claim 1, wherein the method of conjugate residuals terminates when the α parameter in the method of conjugate residuals has a value not greater than 0.

3. A method as in claim 1, wherein the method of conjugate residuals terminates the β parameter in the method of conjugate residuals has an absolute value that is not less than a pre-determined constant value.

4. A system for training a program by optimizing a set of program parameter values, comprising:
a first set of computational elements for modeling the program to be trained, the processors receiving an input vector and providing an output vector;
a second set of computational elements for optimizing the parameter values using an iterative method, wherein successive updates of the parameter values are provided by a method of conjugate residuals, which computes each of the successive updates by solving a set of linear equations involving a Hessian matrix and a gradient vector; and
a control unit for controlling the operations of the first and second sets of computational elements.

5. The system of claim 4, wherein the iterative method comprises Newton's algorithm.

6. A system as in claim 4, wherein the method of conjugate residuals terminates when the α parameter in the method of conjugate residuals has a value not greater than 0.

7. A system as in claim 4, wherein the method of conjugate residuals terminates the β parameter in the method of conjugate residuals has an absolute value that is not less than a pre-determined constant value.