Skip to content

Commit

Permalink
Xiaowuhu/20200415 (microsoft#494)
Browse files Browse the repository at this point in the history
* Update 17.5-池化的前向计算与反向传播.md

* fix bug

* Create Readme.md
  • Loading branch information
xiaowuhu authored Apr 23, 2020
1 parent e2849b4 commit abd0998
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $$J = \sum_{i=1}^m loss$$

### 3.0.2 机器学习常用损失函数

符号规则:a是预测值,y是样本标签值,J是损失函数值
符号规则:a是预测值,y是样本标签值,loss是损失函数值

- Gold Standard Loss,又称0-1误差
$$
Expand All @@ -53,17 +53,17 @@ $$
- Log Loss,对数损失函数,又叫交叉熵损失函数(cross entropy error)

$$
loss = -\frac{1}{m} \sum_i^m y_i log(a_i) + (1-y_i)log(1-a_i) \qquad y_i \in \{0,1\}
loss = -[y \cdot \log (a) + (1-y) \cdot \log (1-a)] \qquad y \in \{0,1\}
$$

- Squared Loss,均方差损失函数
$$
loss=\frac{1}{2m} \sum_i^m (a_i-y_i)^2
loss=(a-y)^2
$$

- Exponential Loss,指数损失函数
$$
loss = \frac{1}{m}\sum_i^m e^{-(y_i \cdot a_i)}
loss = e^{-(y \cdot a)}
$$


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ $$

$$H(p,q) =- \sum_{j=1}^n p(x_j) \ln q(x_j) \tag{6}$$

在机器学习中,我们需要评估label和predicts之间的差距,使用KL散度刚刚好,即$D_{KL}(y||a)$,由于KL散度中的前一部分$H(y)$不变,故在优化过程中,只需要关注交叉熵就可以了。所以一般在机器学习中直接用交叉熵做损失函数来评估模型。
在机器学习中,我们需要评估标签值$y$和预测值$a$之间的差距,使用KL散度刚刚好,即$D_{KL}(y||a)$,由于KL散度中的前一部分$H(y)$不变,故在优化过程中,只需要关注交叉熵就可以了。所以一般在机器学习中直接用交叉熵做损失函数来评估模型。

$$loss =- \sum_{j=1}^n y_j \ln a_j \tag{7}$$

其中,$n$ 并不是样本个数,而是分类个数。所以,对于批量样本的交叉熵计算公式是:
公式7是单个样本的情况,$n$ 并不是样本个数,而是分类个数。所以,对于批量样本的交叉熵计算公式是:

$$J =- \sum_{i=1}^m \sum_{j=1}^n y_{ij} \ln a_{ij} \tag{8}$$

$m$ 是样本数,$n$ 是分类数。

有一类特殊问题,就是事件只有两种情况发生的可能,比如“学会了”和“没学会”,称为$0/1$分布或二分类。对于这类问题,由于$n=2$,所以交叉熵可以简化为:
有一类特殊问题,就是事件只有两种情况发生的可能,比如“学会了”和“没学会”,称为$0/1$分布或二分类。对于这类问题,由于$n=2,y_1=1-y_2,a_1=1-a_2$,所以交叉熵可以简化为:

$$loss =-[y \ln a + (1-y) \ln (1-a)] \tag{9}$$

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

- 扩大视野:就如同先从近处看一张图片,然后离远一些再看同一张图片,有些细节就会被忽略
- 降维:在保留图片局部特征的前提下,使得图片更小,更易于计算
- 平移不变性,轻微扰动不会影响输出:比如上如中最大值池化的4,即使向右偏一个像素,其输出值仍为4
- 平移不变性,轻微扰动不会影响输出:比如上图中最大值池化的4,即使向右偏一个像素,其输出值仍为4
- 维持同尺寸图片,便于后端处理:假设输入的图片不是一样大小的,就需要用池化来转换成同尺寸图片

一般我们都使用最大值池化。
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**请注意:本目录中的内容尚未成熟,尚不能作为教学、自学参考。待成熟后会把父目录中的(建设中)字样去掉**

0 comments on commit abd0998

Please sign in to comment.