2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function

例:housing Price

监督学习:给出正确的答案

回归问题:预测出正确的结果


训练回归模型:

training set——算法——hypothesis


Cost:

目标函数——代价函数(平方误差代价函数——大多数回归问题):去最小化或最大化代价函数


问题设定:

2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function

图示:

1图

2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function

2图

2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function

3图

2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function

4图

2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function

算法利用程序去自动寻找“碗底”,使得损失函数J最小

随着参数增多,维度增大,图形无法表示。

学习率:即参数变化的速度


how?——Gradient Descent——have J,  want min J——可以用来最小化任何loss function

2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function

①设置各参数初始值;

②对各参数求偏导数;

③给定学习率,即参数值进行变化的步伐大小 Learning rate

④参数进行梯度下降(给定同一学习率,各参数梯度下降是同时进行的,同时更新参数)

⑤直到收敛,梯度下降结束


图解:

2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function


说明:

Learning rate:

太小:慢;太大:overshoot 碗底。

越接近碗底,虽然LR固定,但越来越慢,步伐越小,因为梯度在变小。

2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function


局部最优解问题:存在多个碗底,一般来说,致力于构造一个convex function(bowl function),即只有全局最优解的问题


Finally——Combined

2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function

# Batch Gradient Descent

梯度下降的每一步都会使用全部的训练样本。

2-1 2-2 2-3 2-4 2-5 2-6 2-7: Model regression and Cost function