吴恩达机器学习笔记(三)--线性代数回顾

吴恩达机器学习笔记(三)–线性代数回顾

学习基于:吴恩达机器学习.

1. Matrix and Vector

  • Matrix is a rectangular array of numbers
  • The dimension of matrix is the number of rows and columns of a matrix
  • Matrix elements are entries of matrix
  • AijA_{ij} refers to the entry in the ithi^{th} row and jthj^{th} column
  • Vector is an n x 1 matrix


    吴恩达机器学习笔记(三)--线性代数回顾

2. Addition and Scalar Multiplication

  • Addition and subtraction are element-wise, so you simply add or subtract each corresponding element:
    [acbd]+[wyxz]=[a+wc+yb+xd+z] \left[ \begin{matrix} a & c \\ b & d \end{matrix} \right] + \left[ \begin{matrix} w & y \\ x & z \end{matrix} \right] = \left[ \begin{matrix} a+w & c+y \\ b+x & d+z \end{matrix} \right]
  • Subtracting Matrices:
    [acbd][wyxz]=[awcybxdz] \left[ \begin{matrix} a & c \\ b & d \end{matrix} \right] - \left[ \begin{matrix} w & y \\ x & z \end{matrix} \right] = \left[ \begin{matrix} a-w & c-y \\ b-x & d-z \end{matrix} \right]

To add or subtract two matrices, their dimensions must be the same.

  • In scalar multiplication, we simply multiply every element by the scalar value:
    [acbd]×λ=[λaλcλbλd] \left[ \begin{matrix} a & c \\ b & d \end{matrix} \right] \times \lambda = \left[ \begin{matrix} \lambda a & \lambda c \\ \lambda b & \lambda d \end{matrix} \right]

3. Matrix-Matrix Multiplication

1) Matrix-Vector Multiplication

We map the column of the vector onto each row of the matrix, multiplying each element and summing the result.
[acbd]×[xy]=[ax+cybx+dy] \left[ \begin{matrix} a & c \\ b & d \end{matrix} \right] \times \left[ \begin{matrix} x \\ y \\ \end{matrix} \right]= \left[ \begin{matrix} ax+cy \\ bx+dy \end{matrix} \right]
An m x n matrix multiplied by an n x 1 vector results in an m x 1 vector.

2) Matrix-Matrix Multiplication

We multiply two matrices by breaking it into several vector multiplications and concatenating the result.
[acbd]×[wyxz]=[aw+cxay+czbw+dxby+dz] \left[ \begin{matrix} a & c \\ b & d \end{matrix} \right] \times \left[ \begin{matrix} w & y \\ x & z \end{matrix} \right]= \left[ \begin{matrix} aw+cx & ay+cz \\ bw+dx & by+dz \end{matrix} \right]

4. Matrix Multiplication Properties

  • Matrices are not commutative:
    • A×\timesB ≠ B×\timesA       (Except B is an unit matrix)
  • Matrices are associative:
    • (A×\timesB)×\timesC=A×\times(B×\timesC)

5. Inverse and Transpose

  • The inverse of a matrix A is denoted A1A^{-1}. Multiplying by the inverse results in the identity matrix.
    • AA1=A1A=IAA^{-1} = A^{-1}A = I
  • The transposition of a matrix is like rotating the matrix 90° in clockwise direction and then reversing it.
    • Bij=AjiB_{ij} = A_{ji}