简要声明
- 课程学习相关网址
- 由于课程学习内容为英文,文本会采用英文进行内容记录,采用中文进行简要解释。
- 本学习笔记单纯是为了能对学到的内容有更深入的理解,如果有错误的地方,恳请包容和指正。
- 非常感谢Andrew Ng吴恩达教授的无私奉献!!!
文章目录
专有名词
Matrix | 矩阵 | Vector | 向量 |
---|---|---|---|
index | 下标 | Matrix Addition | 矩阵加法 |
Scalar Multiplication | 标量乘法 | commutative | 乘法交换律 |
Associative | 乘法结合律 | Identity Matrix | 单位矩阵 |
Matrix inverse | 矩阵的逆 | Matrix Transpose | 矩阵转置 |
Matrices and vectors
Matrix
- Matrix: Rectangular array of numbers →矩阵:由数字组成的矩形阵列
- Dimension of matrix: number of rows x number of columns →矩阵的维数:矩阵的行数乘以列数
A = [ 1402 191 1371 821 949 1437 147 1448 ] ( R 4 × 2 ) A=\begin{bmatrix} 1402 & 191 \\ 1371 & 821 \\ 949 & 1437 \\ 147 & 1448 \end{bmatrix} \quad (\mathbf{R}^{4 \times 2} ) A= 1402137194914719182114371448 (R4×2)
- Matrix Elements (entries of matrix) →矩阵元素/矩阵的项→矩阵的第i行第j列对应的那个元素
A i j = " i , j e n t r y " i n t h e i t h r o w , j t h c o l u m n A_{ij}="i,j\ entry"\ in\ the\ i^{th}\ row,\ j^{th}\ column Aij="i,j entry" in the ith row, jth column
Vector
- Vector: An n x 1 matrix →一个n×1的矩阵
y = [ 460 232 315 178 ] ( R 4 ) y=\begin{bmatrix} 460 \\ 232 \\ 315 \\ 178 \end{bmatrix} \quad (\mathbf{R}^{4} ) y= 460232315178 (R4)
- Vector Element →向量y的第i个元素
y i = i t h e l e m e n t y_i=i^{th} \ element yi=ith element
- Vector index向量下标: 1‐indexed vs 0‐indexed
- 除非特别指定,默认使用1-indexed下标向量
y ( 1 − i n d e x ) = [ y 1 y 2 y 3 y 4 ] y ( 0 − i n d e x ) = [ y 0 y 1 y 2 y 3 ] y_{(1-index)}=\begin{bmatrix} y_1 \\ y_2 \\ y_3 \\ y_4 \end{bmatrix} \qquad y_{(0-index)}=\begin{bmatrix} y_0 \\ y_1 \\ y_2 \\ y_3 \end{bmatrix} y(1−index)= y1y2y3y4 y(0−index)= y0y1y2y3
- 通常使用大写字母表示矩阵,使用小写字母表示数字、标量、向量
Addition and scalar multiplication
Matrix Addition 矩阵加法
- 只有相同维度的两个矩阵才能相加
Scalar Multiplication 标量乘法
- scalar标量指的是实数
- 将矩阵中的所有元素乘以或除以实数→得到相同维度的矩阵
Combination of Operands
- 先乘除后加减
Matrix‐vector multiplication
- 矩阵m×n乘以向量n×1得到向量m×1
- 让矩阵A的第i行元素分别乘以向量x中的元素并且相加起来
- 构造一个矩阵(第一列都是1,第二列是数据x),构造一个向量(参数),矩阵和向量相乘得到预测结果向量
prediction = dataMatrix * paeameters
- 在计算机中矩阵运算不仅可以简化代码,还可以提高计算效率
Matrix-matrix multiplication
- 矩阵m×n乘以矩阵n×o得到矩阵m×o
- 让矩阵A的第i行元素分别乘以矩阵B的第j列元素并且相加起来得到矩阵C的第i行第i列元素
- 构造一个矩阵(第一列都是1,第二列是数据x),构造一个矩阵(每一列是一个假设函数的参数),矩阵和矩阵相乘得到不同假设函数的预测结果矩阵
Matrix multiplication properties
Not commutative 矩阵乘法没有乘法交换律
Associative 矩阵乘法有乘法结合律
Identity Matrix 单位矩阵
- 不同的单位矩阵有不同的维度,单位矩阵对角线上都是1,其他位置都是0
- 对于任何矩阵A,A乘以单位矩阵等于I乘以A等于A(矩阵A与单位矩阵I维度匹配)
Inverse and transpose
Matrix inverse 矩阵的逆
- If A is an m x m matrix, and if it has an inverse →如果A是m×m的矩阵(方阵)而且可逆
A A − 1 = A − 1 A = I AA^{-1}=A^{-1}A=I AA−1=A−1A=I
- Matrices that don’t have an inverse are “singular” or “degenerate” →没有逆矩阵的矩阵称为奇异矩阵或退化矩阵
Matrix Transpose 矩阵的转置运算
- 假设A是一个m×n矩阵,并设矩阵B等于A的转置,那么B是一个n×m的矩阵,矩阵B的第i行第j列元素等于矩阵A的第j行第i列元素
吴恩达教授语录
- “Certainly all the top ten most popular programming languages will have great linear algebra libraries.”
- “There are very goo free libraries that you can use to do this matrix-matrix multiplication very efficiently.”