李丹沛 Vancouver Introduction to Artificial Intelligence - AI100
- Student:李丹沛 UBC Introduction to Artificial Intelligence - AI100
- Tutor:Stanley
Lecture 5 - Deep Learning
来源:lecture-05_slides.pdf · AI 100: 2026 W1 · 17 页。问题顺序沿用 PDF;页码对应原幻灯片。
Guess Who? What properties help us recognize a cat or a dog?
PDF p. 3
- Appearance 外观
- Properties 特征
- Cat / Dog
What description is allowed?
可以:"brown and fuzzy with a red round circle in its mouth"。不可以:"this guy looks like he’d love to play fetch and eat a bone"。活动入口:PDF 中 http://tiny.cc/AI100,代码 8STR。
Why are manually identified features a problem?
PDF p. 4
- Complex signals 复杂信号
- Hand-made features 人工特征
- Cost / Expertise
What is Representation Learning?
PDF p. 5
- Raw inputs 原始输入
- Learned features 学到的特征
- Artificial neural networks 人工神经网络
What does a neuron take in and produce?
PDF p. 6
- Neuron 神经元
- Inputs 输入
- Intermediate values 中间值
- Output / Label 输出 / 标签
In a 3×3 image, which pixels matter most for upper vs lower edge?
PDF p. 7-8
- Nine pixels 九个像素
- Upper / Lower edge 上缘 / 下缘
- x₁–x₉
- Input importance 输入重要性
What are weights, and what does training learn?
PDF p. 8
- Weights 权重
- Parameters 参数
- Input importance 输入重要性
How does a neuron combine its inputs?
PDF p. 8
- Multiplication 乘法
- Weighted sum 加权求和
- Nonlinear activation 非线性激活
- Sigmoid / ReLU
- Convolutional nets / Transformers
What are input, hidden and output layers?
PDF p. 9
- Input layer 输入层
- Hidden layers 隐藏层
- Output layer 输出层
- Pixels / Predictions
What makes a network deep, and what is the trade-off of adding layers?
PDF p. 10
- Deep neural network 深度神经网络
- Deep learning 深度学习
- Complex relationships 复杂关系
- Overfitting 过拟合
- Structure 网络结构
How do we train a neural network?
PDF p. 11
- Random weights 随机权重
- Predictions 预测
- Actual labels 真实标签
- Weight updates 权重更新
- Backpropagation
Backpropagation Demo
PDF 中的演示。术语说明:p.11 原文把 backpropagation 写作 "also called gradient descent";此处保留本页训练流程与原文用语,不把两术语改写成严格同义定义。
Why do large neural networks need so much data and compute?
PDF p. 12
- Parameters 参数
- Training data 训练数据
- Training time 训练时间
- Compute 算力
- GPUs
Why is a deep network hard to interpret, and when might a simpler model be preferable?
PDF p. 13
- Model interpretability 模型可解释性
- Transparency 透明性
- Linear separators 线性分隔器
- Decision trees 决策树
How do training-data distributions affect accuracy and deployment choices?
PDF p. 14
- Skin colour distribution 肤色分布
- Label distribution 标签分布
- Test-set accuracy 测试准确率
- Group performance 群体表现
- Deployment 部署
What changes when we move the skin colour distribution slider?
记录肤色分布变化前后各组的准确率,观察哪些样例出错。
What changes when we move the label distribution sliders?
比较标签比例变化前后的准确率;将标签不平衡与群体代表性不平衡分开观察。
Which dataset gives the best test-set model?
比较活动中的测试集结果,找出测试集上表现最好的数据集。不能在运行前假造答案。
Which dataset gives about the same performance for both groups?
比较两组表现,找出差距较小的数据集,并与上一问的整体测试表现比较。
Which model should be deployed?
根据观察到的测试表现及两组表现解释选择;保留 PDF 的开放讨论,不预设唯一标准答案。
How do label imbalance and group imbalance lead to bias and fairness issues?
PDF p. 15
- Unbalanced labels 标签不平衡
- Group representation 群体代表性
- Average performance 平均表现
- Outliers 少数 / 离群样例
- Bias 偏差
- Fairness 公平性
Does this happen only with people?
不是。训练集中 border collies 比 chihuahuas 更多时,模型可能更擅长前者。涉及人口群体时,就成为公平性问题,例如训练面孔多为浅肤色、深肤色样例太少。
What does Joy Buolamwini’s experience suggest about the training data?
PDF p. 14
- Joy Buolamwini
- Facial recognition 面部识别
- Skin colour / Gender 肤色 / 性别
- Real-life biases 现实偏差
What would you guess about the dataset, and why?
依据她的经历,讨论训练集的肤色分布、性别分布可能怎样;再讨论数据集为什么变成这样、有哪些现实偏差参与其中。这些是推测与讨论问题,PDF 没有给出可断言的具体比例。PDF 的研究链接
What can Google Teachable Machine reveal about generalization and learned features?
PDF p. 16
- Happy / Sad 开心 / 难过
- Webcam images 摄像头图像
- Unseen expression 未见表情
- Partner distribution 人员分布
- Background object 背景物体
How is an expression outside both classes predicted?
做一个两类训练数据里都没有的表情,例如 shocked face。观察预测,并尝试解释。
What changes when we train on one partner vs both partners?
只用一位伙伴的图像训练,再用两人测试;与两人的图像都参与训练的模型比较,记录观察。
Can an unrelated background object change predictions?
训练时让某类图像带有无关物体,例如 smiling with water bottle、frowning without。测试时添加或拿走物体,比较准确率。
What does Deep Learning gain, and what does it cost?
PDF p. 17
- Learned features 学到的特征
- Weights 权重
- Hidden layers 隐藏层
- Backpropagation
- Bias 偏差
- Transparency / Data / Compute
Concept Check: What does training change? (p.8, p.10–11)
Answer:输入的权重(参数)。本讲义中的网络结构通常在训练前确定。
Concept Check: Does deep mean hand-made features? (p.5, p.17)
Answer:不是。这里用原始输入,让网络自己学有用特征;deep 指很多层。
Concept Check: Why can a high average score hide a fairness problem? (p.14–15)
Answer:平均表现不能保证每组表现相近;代表性不足的群体可能表现更差。
PDF notice: Quiz 1(原讲义通知,非当前安排)
PDF p.2。原文:Sept 28(Monday)10 am 至 Oct 2(Friday)evening;预约网址 https://us.prairietest.com/。另提到可预约时段少,授课团队正处理。这里只保留历史通知,不把它当作当前考试安排。
Terms / 专业术语
来源:Lecture 5 PDF 核心专业词汇;中文解释以本讲义为准,不追求术语全集。
- Feature · 特征用于识别或分类的输入属性;传统做法需要人工选出、填写这些属性,神经网络则从原始输入中学习有用特征。(PDF p.4–5、17)
- Representation Learning · 表征学习直接使用原始输入,让机器学习有用的特征,而不是先由人手工设计特征。(PDF p.5)
- Raw Input · 原始输入未经人工特征设计而直接交给模型的数据,例如图像的像素。(PDF p.5、9)
- Artificial Neural Network · 人工神经网络受生物学启发、由多层神经元组成的网络;神经元加权输入产生输出,网络学习有用特征。(PDF p.5、9、17)
- Neuron · 神经元接收多个输入并产生一个输出;输入可为原始数据或其他神经元的输出,输出可为中间值或最终预测。(PDF p.6–8)
- Weight · 权重每个输入对应的数值,用来表示该输入对神经元输出的影响;训练要确定、调整这些权重。(PDF p.8、11、17)
- Parameter · 参数网络需要确定的数值;本讲义中各连接的权重就是网络参数,更多神经元和连接意味着更多参数。(PDF p.10、12、17)
- Weighted Sum · 加权求和将每个输入乘以对应权重,再把这些结果相加;随后应用非线性激活函数。(PDF p.8)
- Activation Function · 激活函数作用于加权和的非线性函数;本讲义展示 sigmoid 与 ReLU。(PDF p.8)
- Sigmoid · Sigmoid 函数讲义展示的非线性激活函数,曲线呈 S 形,公式为 σ(z) = 1 / (1 + e^(−z))。(PDF p.8)
- ReLU · 修正线性单元讲义展示的激活函数,公式为 R(z) = max(0, z):输入为负时取 0,为正时保留该值。(PDF p.8)
- Input Layer · 输入层接收每个样例的输入,例如训练图像的像素。(PDF p.9)
- Hidden Layer · 隐藏层位于输入层与输出层之间的神经元层;堆叠隐藏层可捕捉更复杂的模式。(PDF p.9–10、17)
- Output Layer · 输出层产生预测的网络层,例如预测图像为猫或狗。(PDF p.9)
- Deep Neural Network / Deep Learning · 深度神经网络 / 深度学习包含很多层的神经网络及其整体方法;更多层能表达更复杂关系,但需要更多数据并增加计算和透明性代价。(PDF p.10、12–13、17)
- Label / Class · 标签 / 类别样例的实际类别,例如猫或狗、开心或难过;训练时把预测与实际标签比较。(PDF p.9、11、16)
- Prediction · 预测模型根据输入给出的输出或类别判断;训练时与实际标签比较以改进权重。(PDF p.9、11)
- Training Set / Training Data · 训练集 / 训练数据用于训练模型的样例;数据的数量、标签及群体分布会影响模型学到什么和它的表现。(PDF p.11–12、14–15)
- Test Set · 测试集活动中用来比较已训练模型表现的数据集,并与不同训练集产生的结果对照。(PDF p.14)
- Backpropagation · 反向传播本讲义的训练流程:随机权重开始,预测训练样例,比较预测与实际标签,小幅调整权重,反复进行直到足够准确或不再改进。(PDF p.11、17)
- Overfitting · 过拟合本讲义指出:增加隐藏层和神经元后,需要更多数据来避免的模型学习问题;L5 未进一步展开其定义。(PDF p.10)
- GPU · 图形处理器用于执行反向传播、加快大型网络训练的计算设备;讲义将 2009–2012 年采用 GPU 列为重要突破。(PDF p.12)
- Model Interpretability / Transparency · 模型可解释性 / 透明性理解并说明模型为什么给出某个预测的能力;网络越深,神经元与最终预测越难解释,需要透明性时可能选较简单模型。(PDF p.13、17)
- Training Data Distribution · 训练数据分布训练数据中标签及不同群体样例的分布;该分布塑造模型,并影响各组准确率和部署讨论。(PDF p.14–15)
- Label Imbalance / Group Imbalance · 标签不平衡 / 群体不平衡标签极不均衡可能导致整体表现差;群体代表性不均衡会使模型在不同群体上的表现不均衡。(PDF p.15)
- Bias · 偏差模型会受到训练集分布影响;追求平均表现时,少数样例不易主导结果,所见较少的群体可能表现更差。这里不只指对人的歧视。(PDF p.15、17)
- Fairness · 公平性当群体表现不均衡涉及人口群体时,成为公平性问题;例如深肤色训练面孔太少,模型对这一群体学习不足。(PDF p.15)
Lecture 4 - Machine Learning
MiniMax Search
Spam Emails detect & filter
What are predefined rules?
- explicit rule-based programming 如果有free, reward,就判定为spam email
- search
How would you program it using explicit rules or search? 如果要用明确规则(Explicit Rules)来过滤垃圾邮件,最直接的做法是?
- A. 制定关键词黑名单(如出现 'Free', 'Winner', '转账' 即标记为垃圾邮件)✅
- B. 状态空间搜索(将所有词汇可能组合画成一棵搜索树进行搜索)
What would be pros and cons of your proposed approach? 手写明确规则(Explicit Rules)最大的局限与痛点(Cons)是什么?
- A. 容易“误杀”正常邮件(False Positives,例如学校通知包含“免费午餐/Free lunch”被拦截)
- B. 极易被变异绕过(发件人改写为 'Fr33' 或将文字做成图片,规则立刻失效)
- C. 规则无穷无尽无法穷举,后期人工维护成本极高
- D. 以上皆是(核心痛点)✅ ➔ 为什么需要 Machine Learning(从数据中自动归纳规则)
- C. 收集大量邮件让程序自动寻找特征模式(这是 Machine Learning,非 Explicit Rules)
What is pattern in a dataset?
如果观察了 1000 个西瓜,发现“拍打声音沉闷”且“瓜蒂弯曲”的西瓜,绝大多数切开后都非常甜。这里的特征与甜度之间稳定重现的对应关系,属于什么?
- A. 纯粹的偶然巧合
- B. 数据集中的规律(Pattern)
- C. 程序员手写的死规则
- D. 无关的噪声干扰
在大量样本中稳定反复出现的特征与结果对应关系,就是 Pattern。正确选项为 B。
银行分析了海量信用卡交易数据,发现“异地远距离 + 凌晨大额消费”往往对应着盗刷行为。在机器学习中,识别出这种 Pattern 的核心目的是什么?
- A. 仅仅为了背诵和记录已经发生过的历史交易
- B. 当未来出现一笔从未见过的新交易时,能够准确预测它是否属于欺诈 - 输出output 是什么?(到底预测什么),Steve(Model 模型) yes, no, no, no , yes , nnoooooo
- C. 证明所有持卡人都存在违约风险
- D. 彻底替代人工客服的一切工作
识别 Pattern 的价值不是为了记忆历史数据,而是为了对未知的新样本进行有效预测(泛化Generalization能力)。正确选项为 B。
1. 它是“多维特征与结果的内在关联(Relationship: X → Y,)”:数据本身只是一堆冰冷的数字和文字(工时、距离、金额)。但当某些特征的取值,总是倾向于导致某种特定的结果时,它们之间就形成了一条“暗线”。这条暗线就是 Pattern。
2. 它是“客观重复(Repetition)”,不是一次性偶然:必须在多条样本(Multiple Examples)中反复重现。只发生过一次的事情叫偶然事件;反复出现的结构才叫 Pattern。
3. 识别 Pattern 的终极目的:为了“预测未来(Predict New Data)”:机器学习之所以费劲心机去识别 Pattern,并不是为了把看过的旧数据倒背如流,而是为了当明天出现一个从未见过的新样本时,依然能用这个 Pattern 猜对它的标签 Labels(这正是 Slide 8 强调的 Generalization 泛化)。
Pattern vs Noise
| 维度 | 规律 (Pattern) | 噪声 / 巧合 (Noise) |
|---|---|---|
| 出现频率 | 在大量样本中稳定、反复同步出现 | 仅在个别甚至单一样本中偶然巧合 |
| 与标签的关系 | 与输出标签有本质的因果或强相关性 | 与输出标签毫无实际逻辑关联 |
| 未来泛化力 | 放在全新的未知数据上依然有效 | 只在眼前这批数据奏效,新数据上直接打脸 (Overfits) (Generalizes) Garbage in Garbage out. 垃圾进,垃圾出。 |
| 具体示例 | 异地距离 > 1000km 且金额 > 额度 80% ➔ 欺诈 | 今天发生欺诈的持卡人刚好都穿红衣服 ➔ 巧合 |
What does machine learning do?
Who learns, and why not explicit programming?
- Lecture 2 Explicit Programming & Lecture 3 Search
- Inability to exhaust all If-Else rules · 人类无法穷举所有 If-Else 规则
- Complex and dynamic rules · 规律过于复杂、动态多变
- Paradigm shift: offload finding rules to machines · 转变范式:把总结规则的工作交给机器
- Computer / Machine · 计算机(机器)自己学
- Spam emails, fraud detection, facial recognition · 垃圾邮件、信用卡欺诈、人脸识别
Where does it learn from?
- Dataset · 样本数据集 —— 50 条emails (5 spam) - JameS & Lucas
- Input features · 输入特征 (Features)
- Historical labels / Ground truth · 历史真实结果 (Labels)
- Data as fuel · 数据是养料
- Mining underlying patterns from known facts · 从历史已知事实中挖掘潜在规律
What is the purpose of learning?
- Generalization · 泛化(而非倒背如流历史数据)
- Unseen new examples · 从未见过的全新样本
- Predicting output labels with learned rules · 依靠学到的模型/规则自动预测输出标签
- Classification · 分类
How does it learn?
- To be discussed later
Credit Card Fraud Detection
What is the dataset?
What are the features & labels?
What is the plan?
- ask a computer to find a rule that explains examples with known labels
- use this rule to predict labels for new examples: “classification”
What are our inputs and outputs?
our inputs are features and our outputs are labels
What is your findings?
- How would you combine them together into a rule?
- Are all of the features useful?
- How would you decide?
What is generalization?
What is a Model?
What are Classification Models?
What is Linear Model?
What is non-Linear Model?
What is Decision Boundary?
- defined by parameters
- slop & intercept
Which one is better? And why?
What is Overfitting?
What is Underfiting?
What is DT
What is the task?
- You are an instructor evaluating a group project – are any students’ contributions worth investigating further?
- What are the features?
- hours lagged: hours logged on the project
- peer rating: peer rating score received
- What are the labels?
- blue: consistent
- 工时少 且 评分低(左下角)
- 工时多 且 评分高(右上角)
- red: mismatched
- 工时少 但 评分高(左上角:可能是划水蹭分/人缘分虚高)
- 工时多 但 评分低(右下角:可能干得多但质量不行或被搭档排挤)
- whether the instructor considers the student’s self assessment to be: – consistent (blue) – (red)
- blue: consistent
Why is a linear model is inappropriate model?
- 数据分布
- 任何单根直线(Linear Decision Boundary)都绝对不可能将两类点完美分开。因此必须引入能够产生复杂边界的非线性模型(Non-linear Model)
What is DT
- 什么是节点
- 节点是谁设置的
- 节点设置的原则是什么
- Decision Tree的本质是什么
- 每一步寻找能最好区分标签的问题(划分特征与阈值)
- 模型的参数是什么
- “提问”就是树的模型参数(Questions are Parameters)
- 哪张图是 training dataset, 哪张图是 testing dataset
What are the differences between Parametric Models and Non-parametric Models
- 单根直线
- 横平竖直的方格子(Axis-aligned boxes)
- 自然流线
Lecture 3 - Search and Planning
The Story So Far
↓
↓
We Can Use Search to Make an Agent
Known current state + Known action outcome → Search can plan directly
- 假设智能体(Agent)对其环境有完全的理解。
- 当它采取某项行动时,能够准确预知将会发生什么。
- 无需进行观察(No need to make observations!),因为没有新信息产生。
Vancouver → Antarctica: From Real Problem to Search Problem
Case: Plan a trip from Vancouver to Antarctica without using a travel guide or map software.
Trees
- 树状图(Tree diagram)展示了状态(states)和转换(transitions)
- 状态(states)用圆圈表示
- 转换(transitions)用箭头表示
Possible Search Outputs
What can Search return?
Search can return a solution, an optimal solution, a proof of impossibility, or a policy.
Sudoku: From Game Rules to Search Problem
What is Sudoku?
How do we model Sudoku as a Search Problem?
Sudoku shows that a rule-based puzzle can be transformed into the same Search Problem structure used for trip planning.
Search Algorithms
Concept Check
1. What is the frontier?
A. All terminal states
B. States currently being considered
C. The final solution
Answer: B — States currently being considered.
The frontier is the set/list of states that have been discovered and are waiting to be expanded.
2. What does it mean to expand a state?
A. Delete the state
B. Apply available actions and generate reachable next states
C. Assign utility to the state
Answer: B — Apply available actions and generate reachable next states.
Expanding a state means replacing it with the states reachable from it through one action.
3. When can an any-solution search stop?
A. When it finds a terminal state
B. After expanding every state
C. Only after proving optimality
Answer: A — When it finds a terminal state.
For an any-solution search, finding a terminal state is enough.
4. What mainly distinguishes different search algorithms?
A. How they define the environment
B. Which frontier state they choose to expand next
C. Whether they use terminal states
Answer: B — Which frontier state they choose to expand next.
The main difference is the strategy used to select the next state from the frontier.
Search Algorithm = manage the frontier + decide which state to expand next.
Two basic strategies: DFS and BFS.
Depth- and Breadth-First Search
Activity: DFS and BFS
Use the same tree to predict the search order.
1. If DFS starts at A and explores left first, what order will it visit the nodes?
Answer:
A → B → D → E → C → F → G2. If BFS starts at A, what order will it visit the nodes?
Answer:
A → B → C → D → E → F → G3. Why can DFS and BFS reach different terminal states first?
Answer: Because they expand the frontier in different orders.
Same tree, different expansion order → potentially different first terminal state.
Search Algorithms
DFS/BFS mainly decide search order; more advanced algorithms try to avoid unnecessary search.
Tic-Tac-Toe as a Search Problem
What is Tic-Tac-Toe?
Two players take turns placing X and O; the goal is to get three in a row.
How do we model Tic-Tac-Toe as a Search Problem?
Tic-Tac-Tree
Current board state → possible moves → possible next statesNew challenge: another player is also choosing actions, so the search must account for the opponent’s moves.
Minimax Search
How should an agent search when another player is making decisions too?
Utility is X’s score: X tries to maximize it; O tries to minimize it.
Minimax Search: Playing Perfect Tic-Tac-Toe
Why work bottom-up?
- Terminal states already have known utilities because the game is over.
- Earlier states do not have an obvious utility yet.
- Their utility is determined by what the current player would choose next.
Bottom-up rule
Terminal utilities → O chooses the lowest → X chooses the highest → continue upward → choose the move that produced the valueIn other words: Minimax uses the opponent’s best possible response to decide what your best move should be.
Wrap-Up
Search trades computation for programming effort.
Tips
- 不要期待标准答案
- 不要拒绝/恐惧未
- 底层和本质(课程特点)
- 深度理解比记忆重要
Lecture 1
Most modern AI systems
Why is it happening
Machine Learning, CPU, GPU, Clock Speed (主频), Neurons
- 主频瓶颈,“拼频率”转向“拼并行与规模”,GPU 晶体管数量 呈现爆发式增长
- 模拟 1 个神经元可能需要多个晶体管,现代硬件的计算规模正在迅速跨越低等生物的大脑级别,逐步逼近乃至具备模拟人类大脑等高等生物复杂度的硬件基础设施能力
The Narrow View of AI
Agent
探讨 Agent(智能体)的定义边界:
- 测试案例评估:给出 5 个具体实例,依据 Agent 的定义(即“能感知环境并采取行动以达成偏好/目标”)来判断它们是否算作 Agent:
- Analog thermostat(模拟温控器):感知温度并开关加热/制冷。
- Surveillance satellite(监控卫星):监测地球/空间并进行轨道或拍摄控制。
- Fitness tracker(运动手环):监测生理数据与运动。
- Self-driving car(自动驾驶汽车):感知路况并执行转向、加减速。
- Bumblebee(大黄蜂):感知自然环境并寻找花粉、飞行。
- 边界思考挑战:要求寻找那些“勉强算作 Agent(barely agents)”或“刚好不算 Agent(barely not agents)”的临界案例,以此加深对 Agent “感知-行动-目标”闭环机制的理解。
Lecture 2 - Explicit Programming
Programming 101
History
- 人工智能(AI)的历史比想象中更悠久:早在 20 世纪 50 年代(如 Dartmouth 会议时期),人们就尝试通过编写显式指令(Explicit Instructions)来构建计算机智能体。
- 人类能处理“模糊性”(Ambiguity):人类拥有常识,可以根据经验和上下文对不明确的指令做出合理推断,因此不同的人执行同一份指令可能会有微小差异。
- 计算机只能“字面执行”(Precision & Determinism):
- 精确性:计算机完全按字面命令执行,没有常识。你必须明确覆盖计算机可能遇到的所有可能情况(就像前面 Tic-tac-toe 井字棋游戏暴露出的问题一样)。
- 确定性:只要输入相同且指令不变,计算机每次执行的结果都会完全一致。
Snap!
5 个核心基础概念
通过拼搭积木块绘制各种图形,循序渐进地讲解编程的 5 个核心基础概念:
- 顺序指令(Sequential Instructions):按照由上到下的顺序依次执行画线、转角等指令(如绘制正方形、星号)。
- 循环/迭代(Iteration):使用
repeat或forever块重复执行特定代码,简化重复绘图动作。 - 变量(Variables):创建用来存储和动态修改数值的“容器”(如定义
len来控制边长,画出渐大的螺旋线)。 - 条件判断(Conditionals):使用
if-else或repeat until让程序根据条件做出不同反应(如碰撞边缘时改变颜色或反弹)。 - 用户输入(User Input):通过
ask块获取用户输入(如询问边数或正方形数量),使程序能根据输入动态运行。
- 为什么是这些(而不是别动)?
- 好处是什么,坏处是什么?
- 和Python的关系是什么?
通过简单的画图练习,让学生掌握计算机编程的基本控制流,并在最后对比 Python 代码,帮助学生理解积木逻辑与真正文本编程语言(如 Python)是一一对应的。