<< Chapter < Page Chapter >> Page >

The normal equations

Gradient descent gives one way of minimizing J . Let's discuss a second way of doing so, this time performing the minimization explicitlyand without resorting to an iterative algorithm. In this method, we will minimize J by explicitly taking its derivatives with respect to the θ j 's, and setting them to zero. To enable us to do this without having to write reamsof algebra and pages full of matrices of derivatives, let's introduce some notation for doing calculus with matrices.

Matrix derivatives

For a function f : R m × n R mapping from m -by- n matrices to the real numbers, we define the derivative of f with respect to A to be:

A f ( A ) = f A 11 f A 1n f A m1 f A mn

Thus, the gradient A f ( A ) is itself an m -by- n matrix, whose ( i , j ) -element is f / A i j . For example, suppose A = A 11 A 12 A 21 A 22 is a 2-by-2 matrix, and the function f : R 2 × 2 R is given by

f ( A ) = 3 2 A 11 + 5 A 12 2 + A 21 A 22 .

Here, A i j denotes the ( i , j ) entry of the matrix A . We then have

A f ( A ) = 3 2 10 A 12 A 22 A 21 .

We also introduce the trace operator, written “ tr .” For an n -by- n (square) matrix A , the trace of A is defined to be the sum of its diagonal entries:

tr A = i = 1 n A i i

If a is a real number (i.e., a 1-by-1 matrix), then tr a = a . (If you haven't seen this “operator notation” before, you shouldthink of the trace of A as tr ( A ) , or as application of the “trace” function to the matrix A . It's more commonly written without the parentheses, however.)

The trace operator has the property that for two matrices A and B such that A B is square, we have that tr A B = tr B A . (Check this yourself!) As corollaries of this, we also have, e.g.,

tr A B C = tr C A B = tr B C A , tr A B C D = tr D A B C = tr C D A B = tr B C D A .

The following properties of the trace operator are also easily verified. Here, A and B are square matrices, and a is a real number:

tr A = tr A T tr ( A + B ) = tr A + tr B tr a A = a tr A

We now state without proof some facts of matrix derivatives (we won't need some of these until later this quarter).  [link] applies only to non-singular square matrices A , where | A | denotes the determinant of A . We have:

A tr A B = B T A T f ( A ) = ( A f ( A ) ) T A tr A B A T C = C A B + C T A B T A | A | = | A | ( A - 1 ) T .

To make our matrix notation more concrete, let us now explain in detail the meaning of the first of these equations. Suppose we have some fixedmatrix B R n × m . We can then define a function f : R m × n R according to f ( A ) = tr A B . Note that this definition makes sense, because if A R m × n , then A B is a square matrix, and we can apply the trace operator to it; thus, f does indeed map from R m × n to R . We can then apply our definition of matrix derivativesto find A f ( A ) , which will itself by an m -by- n matrix. [link] above states that the ( i , j ) entry of this matrix will be given by the ( i , j ) -entry of B T , or equivalently, by B j i .

The proofs of the first three equations in [link] are reasonably simple, and are left asan exercise to the reader. The fourth equation in [link] can be derived using the adjoint representation of the inverse of a matrix. If we define A ' to be the matrix whose ( i , j ) element is ( - 1 ) i + j times the determinant of the square matrix resulting from deleting row i and column j from A , then it can be proved that A - 1 = ( A ' ) T / | A | . (You can check that this is consistent with the standard wayof finding A - 1 when A is a 2-by-2 matrix. If you want to see a proof of this more general result, see an intermediate or advancedlinear algebra text, such as Charles Curtis, 1991, Linear Algebra , Springer.) This shows that A ' = | A | ( A - 1 ) T . Also, the determinant of a matrix can be written | A | = j A i j A i j ' . Since ( A ' ) i j does not depend on A i j (as can be seen from its definition), this implies that ( / A i j ) | A | = A i j ' . Putting all this together shows the result.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Machine learning. OpenStax CNX. Oct 14, 2013 Download for free at http://cnx.org/content/col11500/1.4
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Machine learning' conversation and receive update notifications?

Ask