Bruce12138
Machine Learning
Software Enterprise
Graph Theory
Algorithm II
Machine Learning
Software Enterprise
Graph Theory
Algorithm II
  • Machine Learning

    • Introduction
    • Regression
    • Linear Regression 线性回归
    • Loss functions 损失函数

Linear Regression 线性回归

线性回归是最简单的回归模型,涉及到几乎所有机器学习的基础概念。

线性回归可以写成

yn≈f(xn)=w0+w1xn1+⋯+wDxnD=w0+xn⊤(w1⋮wD)=x~n⊤w~,\begin{align*} y_n &\approx f(\mathbf{x}_n) \\ &= w_0 + w_1 x_{n1} + \cdots + w_D x_{nD} \\ &= w_0 + \mathbf{x}_n^{\top} \begin{pmatrix} w_1 \\ \vdots \\ w_D \end{pmatrix} \\ &= \tilde{\mathbf{x}}_n^{\top}\tilde{\mathbf{w}}, \end{align*} yn​​≈f(xn​)=w0​+w1​xn1​+⋯+wD​xnD​=w0​+xn⊤​​w1​⋮wD​​​=x~n⊤​w~,​

我们在输入向量和权重上面加了一个波浪线以表示它们包括了偏置项。

Note that we add a tilde over the input vector, and also the weights, to indicate they now contain the additional offset term (a.k.a. bias term).

其中,输入向量 x~n=(1,xn1,xn2,⋯ ,xnD)⊤\tilde{\mathbf{x}}_n=(1,x_{n1},x_{n2},\cdots,x_{nD})^{\top}x~n​=(1,xn1​,xn2​,⋯,xnD​)⊤ 权重 w~=(w0,w1,⋯ ,wD)⊤\tilde{\mathbf{w}}=(w_0,w_1,\cdots,w_D)^{\top}w~=(w0​,w1​,⋯,wD​)⊤。

Use an 'offset' term? 是否要包含偏置项?

  • 数量:

    当不包含偏置项时,只需要学习 DDD 个参数。而包含偏置项以后需要学习 D+1D+1D+1 个参数。但这只是线性回归模型的特例,例如在神经网络中,第一层可能就有几百上千个参数。

  • 灵活性:

    无偏置项时,模型强制要求拟合的超平面经过原点,这会降低模型的表达能力。有偏置项的模型你和更灵活。

Learning / Estimation / Fitting 学习/估计/拟合

给定数据,找出权重 w~\tilde{\mathbf{w}}w~ 的过程就叫做学习/估计参数,或者叫拟合模型。Given data, we would like to find w~=[w0,w1,⋯ ,wD]\tilde{\mathbf{w}}=[w_0,w_1,\cdots,w_D]w~=[w0​,w1​,⋯,wD​]. This is called learning or estimating the parameters or fitting the model.

Matrix multiplication 矩阵乘法

这是线性代数 (Linear Algebra) 的基础知识。

  1. 一个大小为 M×N1M\times N_1M×N1​ 的矩阵和一个大小为 N2×DN_2\times DN2​×D 的矩阵能做乘法,iff N1=N2N_1=N_2N1​=N2​ 。
  2. 一个大小为 M×NM\times NM×N 的矩阵和一个大小为 N×DN\times DN×D 的矩阵相乘得到一个大小为 M×DM\times DM×D 的矩阵。

Overparameterization 过参数化

Overparameterization 是指参数数量 DDD 大于数据样本数量 NNN 的情况。对于很多模型(比如线性回归),这会导致问题欠定 (under-determined)。我们就说模型对于这个任务来说是 过参数化 (over-parameterized) 的。

使用正则化 (regularization) 是避免这种识别问题的方法之一。如果忽略这种识别问题,过参数化有时候也可能带来好处,比如在训练动态方面。

Using regularization is a way to avoid the identification issue described. If we ignore the identification issue, overparameterization can also have advantages, such as on the trining dynamics.

Last Updated: 9/17/25, 5:55 PM
Contributors: Zhixiang Dai
Prev
Regression
Next
Loss functions 损失函数