|
|
|
@ -159,4 +159,34 @@ Learning policy
|
|
|
|
|
|
|
|
|
|
3. 更新w,b
|
|
|
|
|
|
|
|
|
|
![1618234028471](assets/1618234028471.png)
|
|
|
|
|
![1618234028471](assets/1618234028471.png)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### 例子
|
|
|
|
|
|
|
|
|
|
Example
|
|
|
|
|
|
|
|
|
|
训练数据中,正例(y=+1)点位x1 = (3,3)T,x2 = (4,3)T,负例(y=-1)为x3 = (1, 1)T,求解感知机模型f(x) = sign(w*x + b),其中w = (w1, w2)T,x = (x1, x2)T
|
|
|
|
|
|
|
|
|
|
解:
|
|
|
|
|
|
|
|
|
|
1. 构造损失函数
|
|
|
|
|
|
|
|
|
|
![1618234528190](assets/1618234528190.png)
|
|
|
|
|
|
|
|
|
|
2. 梯度下降求解w,b。设步长为1
|
|
|
|
|
|
|
|
|
|
1. 取初值w0 = 0,b0 = 0
|
|
|
|
|
2. 对于x1,y1(w0 * x1 + b0) = 0未被正确分类,更新w,b。w1 = w0 + x1y1 = (3,3)T,b1 = b0 + y1 = 1 => w1 * x + b1 = 3x + 3x + 1
|
|
|
|
|
|
|
|
|
|
3. 对x1,x2,显然yi(w1 * xi + b1) > 0,被正确分类,不做修改。对于x3,y3(w1 * x3 + b1) 应该小于0,结果是大于0被误分类,更新w,b。
|
|
|
|
|
|
|
|
|
|
![1618234885210](assets/1618234885210.png)
|
|
|
|
|
|
|
|
|
|
4. 以此往复,直到没有误分类点,损失函数达到极小。
|
|
|
|
|
|
|
|
|
|
![1618234973878](assets/1618234973878.png)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|