Anil K. Shrestha
Published on

Note on book Deep Learning Chapter 2 - Linear Algebra

Note: This is my notes while reading Deep Learning by Ian Goodfellow

2.1 Scalars, Vectors, Matrices and Tensors

Scalars: A scalar is just a single number. s ∈ R could be the slope of the line.

Vectors: A vector is an array of numbers arranged in order. We write a vector x\vec x as:

x\vec x = [x1x2x3...xn]\begin{bmatrix} x_1 \\ x_2 \\ x_3 \\ ... \\ x_n \end{bmatrix}

Matrices: A matrix is a 2-D array of numbers, so each element is identified by two indices instead of just one.

Ai,j=[A1,1...A1,j...Ai,1...Ai,j]A_{i,j} = \begin{bmatrix} A_{1,1} & ... & A_{1,j} \\ ... \\ A_{i,1} & ... & A_{i,j}\end{bmatrix}

Tensors: A tensor is an array of numbers arranged on a regular grid with a variable number of axes. We identify the element of A at coordinates (i,j,k)(i,j,k) by writing Ai,j,kA_{i,j,k}.

Transpose

Transpose of a matrix AA is the mirror image across it's diagonal.

Ai,jT=Aj,iA_{i,j}^T = A_{j,i}

Example: A=[A1,1A1,2A2,1A2,2A3,1A3,2]    AT=[A1,1A2,1A3,1A1,2A2,2A3,2]A = \begin{bmatrix}A_{1,1} & A_{1,2} \\ A_{2,1} & A_{2,2} \\ A_{3,1} & A_{3,2} \end{bmatrix} \implies A^T = \begin{bmatrix}A_{1,1} & A_{2,1} & A_{3,1} \\ A_{1,2} & A_{2,2} & A_{3,2} \end{bmatrix}

Vector as a matrix with only one column:

A=[x1x2...xn]A = \begin{bmatrix}x_1 \\ x_2 \\ ... \\ x_n \end{bmatrix}

then,

AT=[x1x2...xn]A^T = \begin{bmatrix}x_1 & x_2 & ... & x_n \end{bmatrix}

2.2 Multiplying Matrices and Vectors

The matrix product of matrices AA and BB is a third matrix CC.

Ci,j=kAi,kBk,jC_{i,j} = \sum_k A_{i,k}B_{k,j}

Properties:

  • A(B+C)=AB+ACA(B + C) = AB + AC
  • A(BC)=(AB)CA(BC) = (AB)C
  • ABBAAB \not= BA
  • (AB)T=BTAT(AB)^T = B^TA^T
  • xTy=(xTy)T=yTxx^Ty = (x^Ty)^T = y^Tx

2.3 Identity and Inverse Matrices

An identity matrix is a matrix that does not change any vector when we multiply that vector by that matrix.

xϵRn,Inx=x\forall x \epsilon R^n, I_n\vec{x} = \vec{x}

The matrix inverse of AA is denoted as A1A^{-1}, and it is defined as the matrix such that

A1A=IA^{-1}A = I

So of A1A^{-1} exists,

Ax=bAx = b

A1Ax=A1bA^{-1}Ax = A^{-1}b

Ix=A1bIx = A^{-1}b

x=A1bx = A^{-1}b