Machine Learning 2020 Spring - Introduction
1. 简介
\qquad
课程网页:http://speech.ee.ntu.edu.tw/~tlkagk/courses_ML20.html
\qquad
B站:https://www.bilibili.com/video/BV1JE411g7XF
\qquad
2020年课程与以往机器学习课程最大的不同就是增加了许多新的作业。
- 蓝色圈圈作业(数分钟完成)
- 黄色三角作业(数小时完成)
- 红色星星作业(数日完成)
- 有外框的作业就是它有Kaggle
- 箭头表示学习顺序(仅供参考)
2. 机器学习含义
\qquad
机器学习就是让机器自动的找一个函式。
- 语音辨识:找一个函式,输入是一段语音讯号,输出是这段声音讯号辨识的结果。
- 影响辨识:输入是一张图片,输出是这张图片里面有什么样的东西。
- A l p h a G o AlphaGo AlphaGo:输入是棋盘黑子与白子的位置,输出是下一步应该落子的位置。
- 对话系统:输入是对机器说的话,输出是机器的回应。
3. 你想找什么样的函式?
\qquad 你想找什么样的函式,你想要机器帮你找到什么样的函式?随着要找的函式不同,我们有不同的机器学习任务。
3.1 Rregression
-
R
r
e
g
r
e
s
s
i
o
n
:
Rregression:
Rregression:函式的输出是一个数值。第一个作业要做的事情就是让机器预测未来某一时刻的 PM2.5。
3.2 Binary Classification
-
B
i
n
a
r
y
C
l
a
s
s
i
f
i
c
a
t
i
o
n
:
Binary\ \ Classification:
Binary Classification:函式的输出只有两种可能,
y
e
s
yes
yes 或
n
o
no
no。有两个作业都与
B
i
n
a
r
y
C
l
a
s
s
i
f
i
c
a
t
i
o
n
Binary\ \ Classification
Binary Classification 有关。
\qquad 在 RNN 作业里面,输入是一个句子,输出是这个句子是正面还是负面。
3.3 Multi-class Classification
-
M
u
l
t
i
−
c
l
a
s
s
C
l
a
s
s
i
f
i
c
a
t
i
o
n
:
Multi-class\ \ Classification:
Multi−class Classification:找一个函式,他的输出是让机器做一个选择题,从预先定好的
N
N
N个选项中选出一个正确的选项。
\qquad CNN这个作业就是Multi-class Classification,在CNN这个作业里面,我们要让机器看一张图片,然后输出告诉我们这张图片是哪一种类别的食物。
3.4 Generation
-
G
e
n
e
r
a
t
i
o
n
:
Generation:
Generation:很多教科书告诉我们机器学习就是两大类问题,即
R
e
g
r
e
s
s
i
o
n
Regression
Regression(输出一个数值)和
C
l
a
s
s
i
f
i
c
a
t
i
o
n
Classification
Classification(让机器做选择题)。如果你只知道机器学习有
R
e
g
r
e
s
s
i
o
n
Regression
Regression 和
C
l
a
s
s
i
f
i
c
a
t
i
o
n
Classification
Classification,就像你只知道世界只有五大洲一样。但其实,世界不止有五大洲,在五大洲外面还有个黑暗大陆。在
M
a
c
h
i
n
e
L
e
a
r
n
i
n
g
Machine\ Learning
Machine Learning 里面,这个就叫做
G
e
n
e
r
a
t
i
o
n
Generation
Generation(生成),我们要让机器生成比较复杂的东西。产生有结构的复杂东西,输出文句、图片,即让机器学习怎么做创造这件事情。
\qquad 我们有一个作业是翻译,翻译这件事情就是要产生文句,这个就是 G e n e r a t i o n Generation Generation 的一个例子。
\qquad 我们还有一个作业是画图,产生二次元人物图片。
4. 怎么样告诉机器你想找什么样的函式?
\qquad 如果我们已经想清楚要找什么样的函式,下一步就是我们怎么把我们心里的想法传达给机器呢?
4.1 Supervised Learning(监督学习)
\qquad
一种最常见的例子叫做
S
u
p
e
r
v
i
s
e
L
e
a
r
n
i
n
g
Supervise\ Learning
Supervise Learning(监督学习)。
S
u
p
e
r
v
i
s
e
d
L
e
a
r
n
i
n
g
Supervised\ Learning
Supervised Learning 意思是说假设我们心里已经想好了我要找的函式是输入一张图片,输出是这张图片属于什么样的类别。在
S
u
p
e
r
v
i
s
e
L
e
a
r
n
i
n
g
Supervise\ Learning
Supervise Learning 的想法里面,我们怎么告诉机器我们要找的函式长什么样子呢?你需要给机器一些训练资料。你需要给机器什么样的训练资料?你不仅需要收集大量的图片,你还要告诉机器说这些图片正确的输出是什么。将正确的输出告诉机器这件事情叫做对资料做
l
a
b
e
l
label
label。提供给机器有
l
a
b
e
l
label
label 的资料进行学习,这件事情叫做
S
u
p
e
r
v
i
s
e
d
L
e
a
r
n
i
n
g
Supervised\ Learning
Supervised Learning。
\qquad
你提供给机器这些有
l
a
b
e
l
label
label 的资料以后,接下来机器就可以评估一个函式的好坏。即机器会给函式一个
l
o
s
s
loss
loss,用来辨别这个函式的好坏。举例来说:机器找了一个函式
f
1
f_1
f1,那么机器怎么知道你这个函式的好不好呢?它会把训练资料,比如说这些图片,一张一张的丢到函式中,然后这个函式会给我们每一张图片的输出。假设
4
4
4 张图片丢进函式
f
1
f_1
f1 中,它的输出都是
“
D
o
g
”
“Dog”
“Dog”,但是在我们的
4
4
4 张训练图片中只有两张是狗,还有两张是猫,这个
f
u
n
c
t
i
o
n
function
function 只答对了一半问题。那么我们说这个函式的
l
o
s
s
=
50
%
loss = 50\%
loss=50%,
l
o
s
s
loss
loss 要越小越好。
\qquad
假设我们重新设计了一个
f
u
n
c
t
i
o
n
:
f
2
function:f_2
function:f2,它的输出全部正确,那么我们可以说该
f
u
n
c
t
i
o
n
function
function 的
l
o
s
s
=
0
%
loss = 0\%
loss=0%。那么该
f
u
n
c
t
i
o
n
function
function 就是我们心里要找的
f
u
n
c
t
i
o
n
function
function。所以有了这些有
l
a
b
e
l
label
label 的资料,我们就可以告诉机器一个
f
u
n
c
t
i
o
n
function
function 的
l
o
s
s
loss
loss 有多大,下一步就是我们期待机器会自动找出
l
o
s
s
loss
loss 最低的函式。
\qquad
这门课一共有五个作业是与
S
u
p
e
r
v
i
s
e
d
L
e
a
r
n
i
n
g
Supervised\ Learning
Supervised Learning 有关的。在这五个作业里面,机器会通过
l
a
b
e
l
e
d
labeled
labeled 资料和
S
u
p
e
r
v
i
s
e
d
L
e
a
r
n
i
n
g
Supervised\ Learning
Supervised Learning 的方式进行学习。
4.2 Reinforcement Learning(强化学习)
\qquad 大家都知道 A l p h a G o AlphaGo AlphaGo 是用 R e i n f o r c e m e n t L e a r n i n g Reinforcement\ Learning Reinforcement Learning 做的,那么我们就用围棋当作例子告诉大家说 S u p e r v i s e d L e a r n i n g Supervised\ Learning Supervised Learning(监督学习)跟 R e i n f o r c e m e n t L e a r n i n g Reinforcement\ Learning Reinforcement Learning(强化学习)如果用在围棋上有什么不同。
- S u p e r v i s e d L e a r n i n g Supervised\ Learning Supervised Learning(监督学习)VS R e i n f o r c e m e n t L e a r n i n g Reinforcement\ Learning Reinforcement Learning(强化学习)
-
S
u
p
e
r
v
i
s
e
d
L
e
a
r
n
i
n
g
Supervised\ Learning
Supervised Learning(监督学习):给机器一个
i
n
p
u
t
input
input,告诉它正确的输出是什么。
\qquad 如果使用 S u p e r v i s e d L e a r n i n g Supervised\ Learning Supervised Learning 方式来让机器学习下围棋,那需要给机器这样的资料:告诉机器说,看到这样的盘式应该要下在哪一步准确。即现在的输入是这样的盘式,黑子和白子的位置摆成这样,那下一步最应该落子的位置在哪里?如果说黑子和白子的位置又摆成另外一个样子,那下一步最应该落子的位置在哪里?
-
R
e
i
n
f
o
r
c
e
m
e
n
t
L
e
a
r
n
i
n
g
Reinforcement\ Learning
Reinforcement Learning(强化学习)
\qquad 如果使用 R e i n f o r c e m e n t L e a r n i n g Reinforcement\ Learning Reinforcement Learning 的话,那么就会简单很多了,不需要告诉机器每一步最应该落子的位置。 R e i n f o r c e m e n t L e a r n i n g Reinforcement\ Learning Reinforcement Learning 就是让机器自己跟自己下,或者机器去和别人下,下一下之后,机器发现它赢了,那么机器就会知道这一盘应该是某些地方下得不错,但是并没有人告诉它说哪几步走的对。如果它输了,那么机器就会知道这一盘下得不好,但是哪几步下错了,到底怎么下才是对的,没有人会告诉机器,机器要自己想办法去找出一些策略来提高正确率。而这个机器输或赢这件事情就是 R e w a r d Reward Reward,引导机器学习的方向。这个就叫做 R e i n f o r c e m e n t L e a r n i n g Reinforcement\ Learning Reinforcement Learning。
A l p h a G o \qquad AlphaGo AlphaGo 最原始的版本是先做 S u p e r v i s e d L e a r n i n g Supervised\ Learning Supervised Learning,通过棋谱来做 S u p e r v i s e d L e a r n i n g Supervised\ Learning Supervised Learning,学到一定程度以后再通过 R e i n f o r c e m e n t L e a r n i n g Reinforcement\ Learning Reinforcement Learning 越来越强,最终可以打败人类。
\qquad 新版本 A l p h a Z e r o AlphaZero AlphaZero 完全可以用 R e i n f o r c e m e n t L e a r n i n g Reinforcement\ Learning Reinforcement Learning,完全不管人类的棋谱,完全超越人类,完全不看人类以前下过的棋谱。
\qquad 我们这门课有 R e i n f o r c e m e n t L e a r n i n g Reinforcement\ Learning Reinforcement Learning 的作业。
4.3 Unsupervised Learning(无监督学习)
U
n
s
u
p
e
r
v
i
s
e
d
L
e
a
r
n
i
n
g
\qquad Unsupervised\ Learning
Unsupervised Learning 的意思是说我们就给机器一堆的
d
a
t
a
data
data,但这些
d
a
t
a
data
data 没有标注。在刚才讲的影像辨识的例子里面,我们不止要给机器大量的影像,还要对这些影像进行标注。在
U
n
s
u
p
e
r
v
i
s
e
d
L
e
a
r
n
i
n
g
Unsupervised\ Learning
Unsupervised Learning 的作业里面,我们会学到说,如果我们给机器一大堆的图片,这些图片没有标注,那我们可以让机器学到什么?这个就是
U
n
s
u
p
e
r
v
i
s
e
d
L
e
a
r
n
i
n
g
Unsupervised\ Learning
Unsupervised Learning。
5. 机器怎么找出你想要的函式?
\qquad 那我们已经通过一些方法,通过一些资料,告诉机器说我们想要找的函式长什么样。接下来,机器怎么实际找出我们想要它找的函式呢?
5.1 给定函式寻找范围
\qquad
不是所有可能的函式都是好的函式, 你告诉机器说,好的函式就在这个范围里面,你在这个范围中找到最好的函式就好。
\qquad
在前两个作业(
R
e
g
r
e
s
s
i
o
n
Regression
Regression 和
C
l
a
s
s
i
f
i
c
a
t
i
o
n
Classification
Classification)里面,我们假定我们要找的函式就是一个
l
i
n
e
a
r
linear
linear 的
f
u
n
c
t
i
o
n
function
function。
\qquad
在之后的作业,我们就会更近一步,我们所有的
f
u
n
c
t
i
o
n
function
function 的搜寻范围就是
N
e
t
w
o
r
k
A
r
c
h
i
t
e
c
t
u
r
e
Network\ Architecture
Network Architecture。这个部分等到看了
D
e
e
p
L
e
a
r
n
i
n
g
Deep\ Learning
Deep Learning 的上课录影之后就会更加清楚。现在只要了解所谓的
N
e
t
w
o
r
k
A
r
c
h
i
t
e
c
t
u
r
e
Network\ Architecture
Network Architecture 其实就是给机器一个函式搜寻的范围。我会教大家两个最经典的
N
e
t
w
o
r
k
A
r
c
h
i
t
e
c
t
u
r
e
Network\ Architecture
Network Architecture,一个是 RNN,它会用到往后的
S
e
q
2
s
e
q
Seq2seq
Seq2seq 这个作业里面。一个是 CNN,接下来有很多的作业都会使用到 CNN 这种
N
e
t
w
o
r
k
A
r
c
h
i
t
e
c
t
u
r
e
Network\ Architecture
Network Architecture。
5.2 找出最好的那个 function
\qquad
给定搜寻范围之后,怎么从这个范围里面找出最好的那个
f
u
n
c
t
i
o
n
function
function 呢?那就要透过一个最优化算法,这门课主要教大家的最优化算法就是
G
r
a
d
i
e
n
t
D
e
s
c
e
n
t
Gradient\ Descent
Gradient Descent(梯度下降法)。在前两个作业里面,要求大家自己实做
G
r
a
d
i
e
n
t
D
e
s
c
e
n
t
Gradient\ Descent
Gradient Descent 这个演算法。而在其它作业里面会使用现成的
D
e
e
p
L
e
a
r
n
i
n
g
F
r
a
m
e
w
o
r
k
Deep\ Learning\ Framework
Deep Learning Framework 来实践
G
r
a
d
i
e
n
t
D
e
s
c
e
n
t
Gradient\ Descent
Gradient Descent 这样子的做法。在
D
e
e
p
L
e
a
r
n
i
n
g
F
r
a
m
e
w
o
r
k
Deep\ Learning\ Framework
Deep Learning Framework 这里面,这学期我们会教大家使用
p
y
t
o
r
c
h
pytorch
pytorch。
6. 前沿研究
\qquad 刚才讲的都是机器学习的基础概念,这门课也会囊括一些机器学习的前沿研究。
6.1 Explainable AI(XAI,可解释人工智能)
E
x
p
l
a
i
n
a
b
l
e
A
I
\qquad Explainable\ AI
Explainable AI 的意思是说大家都知道机器可以做影像辨识,比如:给机器一张图片,它可以告诉我们图片里面有一只猫。但是,机器可不可以告诉我们它觉得图片里面有猫的理由是什么,为什么它觉得这张图片是一只猫呢。这就是
E
x
p
l
a
i
n
a
b
l
e
A
I
Explainable\ AI
Explainable AI 这个作业你会学到的事情。
6.2 Adversarial Attack(对抗攻击)
A
d
v
e
r
s
a
r
i
a
l
A
t
t
a
c
k
\qquad Adversarial\ Attack
Adversarial Attack的意思是什么呢?
A
d
v
e
r
s
a
r
i
a
l
A
t
t
a
c
k
Adversarial\ Attack
Adversarial Attack 的意思是说今天的影像辨识系统也许它已经非常的
r
o
b
u
s
t
robust
robust,
r
o
b
u
s
t
robust
robust 意思就是强健,就是说把你输入的图片加上一些杂讯,也许它往往还可以得到正确的结果。但是
A
d
v
e
r
s
a
r
i
a
l
A
t
t
a
c
k
Adversarial\ Attack
Adversarial Attack 意思是说如果人类怀着恶意去攻击这个影像辨识系统,会发生什么事情?如果我们加的杂讯不是一般的杂讯,而是刻意制造的杂讯,它就会使这个机器崩溃,可能会把猫变成其它动物。这个就是在
A
d
v
e
r
s
a
r
i
a
l
A
t
t
c
k
Adversarial\ Attck
Adversarial Attck 这个作业会学到的东西。
6.3 Network Compression(网络压缩)
\qquad
什么是
N
e
t
w
o
r
k
C
o
m
p
r
e
s
s
i
o
n
Network\ Compression
Network Compression 呢?今天在做影像辨识,也许可以得到非常高的正确率,但是这个非常高的正确率来自于一个硕大无比的
m
o
d
e
l
model
model,这个
m
o
d
e
l
model
model 能大到没办法放到手机或者其他设备里面。
N
e
t
w
o
r
k
C
o
m
p
r
e
s
s
i
o
n
Network\ Compression
Network Compression 要做的事情就是我们有没有办法将这个硕大无比的
N
e
t
w
o
r
k
Network
Network 缩小,让它可以放到手机上,甚至放到更小的设备里面。这个是
N
e
t
w
o
r
k
C
o
m
p
r
e
s
s
i
o
n
Network\ Compression
Network Compression 这个作业要教大家的事情。
\qquad
刚才讲的这三个作业都会用到在CNN这个作业里面得到的结果,所以这三个作业也算是一个题组。
6.4 Anomaly Detection(异常检测)
\qquad
异常检测要做的事情是说过去我们训练一个比如说影像辨识系统,它可能是一个动物的分类器,系统看到一个图片,它会告诉你图片里面有什么动物,但是你把系统放在线上以后,用户不见得只会放动物的图片进来,如果用户放一些怪怪的东西进来,比如放一个凉宫春日的图片进来,系统会做出什么样的反应呢?如果影像辨识系统在学习的时候只学会了辨识各种不同的动物,那么给系统看卡通人物,它也会硬是把卡通人物归类成一种动物,但这并不是最好的结果。我们今天有没有办法让机器做到说如果看到怪怪的东西,训练时候没看过的东西,机器根本不知道怎么判断,它能够反馈说我不知道。这就是
A
n
o
m
a
l
y
D
e
t
e
c
t
i
o
n
Anomaly\ Detection
Anomaly Detection 这个作业想要教大家做的事情。
6.5 Transfer Learning(迁移学习)(Domain Adversarial Learning)
D
o
m
a
i
n
A
d
v
e
r
s
a
r
i
a
l
L
e
a
r
n
i
n
g
\qquad Domain\ Adversarial\ Learning
Domain Adversarial Learning 做的事情是什么呢?一般我们在课堂上做的机器学习作业是给你一些资料,在训练资料上面学好之后在测试资料上面进行测试。通常训练资料与测试资料有相同的分布,在这种情况下,我们通常会得到非常高的正确率。但是,在真正的应用中,测试资料往往与训练资料有所不同,这样实际做起来就会导致正确率暴跌。那有什么办法能够让机器在训练资料与测试资料不同的情况下还能够学到一些东西呢?这个就是
D
o
m
a
i
n
A
d
v
e
r
s
a
r
i
a
l
L
e
a
r
n
i
n
g
Domain\ Adversarial\ Learning
Domain Adversarial Learning 这个作业想要教给大家的事情。
6.6 Meta Learning(元学习)
\qquad
什么是
M
e
t
a
L
e
a
r
n
i
n
g
Meta\ Learning
Meta Learning 呢?
M
e
t
a
L
e
a
r
n
i
n
g
Meta\ Learning
Meta Learning 可以说比机器学习更进步,机器学习是让机器具备学习的能力,
M
e
t
a
L
e
a
r
n
i
n
g
Meta\ Learning
Meta Learning 更进一步是让机器学习如何学习。
M
e
t
a
L
e
a
r
n
i
n
g
Meta\ Learning
Meta Learning 也就是说我们写一个程序
A
A
A,这个程序
A
A
A 可以写出另外一个程序
B
B
B,程序
B
B
B 让机器具备了学习的能力。过去所谓的学习方法是人所设计出来的,是我们赋予了机器学习的能力,但是在
M
e
t
a
L
e
a
r
n
i
n
g
Meta\ Learning
Meta Learning 里面,我们不是直接赋予机器学习的能力,而是赋予了机器如何学习的能力,让机器自己发明学习算法,期待它自己发明出来的算法可以比人类设计出来的还要更为有效。
\qquad
为什么要让机器学习如何学习呢?那是因为今天人类设计出来的学习算法都不是特别的有效率。机器虽然能够得到很高的正确率,但它是依靠强大的计算能力与计算时间得到的。所以我们期待机器可以自己学习出新的学习算法,期待比人类设计的学习算法更有效率。这个就是
M
e
t
a
L
e
a
r
n
i
n
g
Meta\ Learning
Meta Learning。
6.7 Lifelong Learning(终生学习)
\qquad
什么是
L
i
f
e
l
o
n
g
L
e
a
r
n
i
n
g
Lifelong\ Learning
Lifelong Learning 呢?
L
i
f
e
l
o
n
g
L
e
a
r
n
i
n
g
Lifelong\ Learning
Lifelong Learning 意思是说我们能不能让机器终身学习,让它学习一连串的任务。
L
i
f
e
l
o
n
g
l
e
a
r
n
i
n
g
Lifelong\ learning
Lifelong learning 终生学习,又名
c
o
n
t
i
n
u
o
u
s
l
e
a
r
n
i
n
g
continuous\ learning
continuous learning,
i
n
c
r
e
m
e
n
t
l
e
a
r
n
i
n
g
increment\ learning
increment learning,
n
e
v
e
r
e
n
d
i
n
g
l
e
a
r
n
i
n
g
never\ ending\ learning
never ending learning。在我们的作业中,你可能没办法学到机器怎么变成一个天网,但你可以知道说,为什么机器没有办法变成一个天网,到底
L
i
f
e
l
o
n
g
L
e
a
r
n
i
n
g
Lifelong\ Learning
Lifelong Learning 的难点在什么地方。