自编码算法与稀疏性
From Ufldl
Line 238: | Line 238: | ||
这一惩罚因子有如下性质,当 <math>\textstyle \hat\rho_j = \rho</math> 时 <math>\textstyle {\rm KL}(\rho || \hat\rho_j) = 0</math> ,并且随着 <math>\textstyle \hat\rho_j</math> 与 <math>\textstyle \rho</math> 之间的差异增大而单调递增。举例来说,在下图中,我们设定 <math>\textstyle \rho = 0.2</math> 并且画出了相对熵值 <math>\textstyle {\rm KL}(\rho || \hat\rho_j)</math> 随着 <math>\textstyle \hat\rho_j</math> 变化的变化。 | 这一惩罚因子有如下性质,当 <math>\textstyle \hat\rho_j = \rho</math> 时 <math>\textstyle {\rm KL}(\rho || \hat\rho_j) = 0</math> ,并且随着 <math>\textstyle \hat\rho_j</math> 与 <math>\textstyle \rho</math> 之间的差异增大而单调递增。举例来说,在下图中,我们设定 <math>\textstyle \rho = 0.2</math> 并且画出了相对熵值 <math>\textstyle {\rm KL}(\rho || \hat\rho_j)</math> 随着 <math>\textstyle \hat\rho_j</math> 变化的变化。 | ||
+ | [[Image:KLPenaltyExample.png|400px|center]] | ||
- | 我们可以看出,相对熵在 | + | 【原文】 |
+ | |||
+ | We see that the KL-divergence reaches its minimum of 0 at | ||
+ | <math>\textstyle \hat\rho_j = \rho</math>, and blows up (it actually approaches <math>\textstyle \infty</math>) as <math>\textstyle \hat\rho_j</math> | ||
+ | approaches 0 or 1. Thus, minimizing | ||
+ | this penalty term has the effect of causing <math>\textstyle \hat\rho_j</math> to be close to <math>\textstyle \rho</math>. | ||
+ | |||
+ | Our overall cost function is now | ||
+ | :<math>\begin{align} | ||
+ | J_{\rm sparse}(W,b) = J(W,b) + \beta \sum_{j=1}^{s_2} {\rm KL}(\rho || \hat\rho_j), | ||
+ | \end{align}</math> | ||
+ | where <math>\textstyle J(W,b)</math> is as defined previously, and <math>\textstyle \beta</math> controls the weight of | ||
+ | the sparsity penalty term. The term <math>\textstyle \hat\rho_j</math> (implicitly) depends on <math>\textstyle W,b</math> also, | ||
+ | because it is the average activation of hidden unit <math>\textstyle j</math>, and the activation of a hidden | ||
+ | unit depends on the parameters <math>\textstyle W,b</math>. | ||
+ | |||
+ | 【初译】 | ||
+ | |||
+ | 我们可以看出,相对熵在 <math>\textstyle \hat\rho_j = \rho</math> 时达到它的最小值0,而当 <math>\textstyle \hat\rho_j</math> 靠近0或者1的时候,相对熵则变得非常大(其实是趋向于<math>\textstyle \infty</math>)。所以,最小化这一惩罚因子具有使得 <math>\textstyle \hat\rho_j</math> 靠近 <math>\textstyle \rho</math> 的效果。 | ||
总体来说,我们的代价函数可以表示为 | 总体来说,我们的代价函数可以表示为 | ||
- | + | :<math>\begin{align} | |
- | 其中 如之前所定义,而 控制稀疏性惩罚因子的权重。 项则间接地取决于 | + | J_{\rm sparse}(W,b) = J(W,b) + \beta \sum_{j=1}^{s_2} {\rm KL}(\rho || \hat\rho_j), |
+ | \end{align}</math> | ||
+ | 其中 <math>\textstyle J(W,b)</math> 如之前所定义,而 <math>\textstyle \beta</math> 控制稀疏性惩罚因子的权重。 <math>\textstyle \hat\rho_j</math> 项则间接地取决于 <math>\textstyle W,b</math> ,因为它是隐藏神经元 <math>\textstyle j</math> 的平均激活度,而隐层神经元的激活度取决于 <math>\textstyle W,b</math> 。 | ||
+ | |||
+ | 【一审】 | ||
+ | |||
+ | 我们看到,KL距离在 处达到了最小值0,而当 接近于0或1时,KL距离逐渐增大(最终达到 )。因此,要最小化这个惩罚项就等同于让 接近于 。 | ||
+ | 最后,整体代价函数如下: | ||
+ | |||
+ | 其中, 在之前课程中已有定义, 控制稀疏性惩罚项的权重, (间接)依赖于 ,因为它是隐藏单元 的平均激活值,而隐藏单元的激活值依赖于参数 。 | ||
+ | |||
+ | |||
+ | 【二审】 | ||
+ | |||
+ | |||
+ | 我们可以看出,相对熵在 时达到它的最小值 ,而当 靠近0或者1的时候,相对熵则变得非常大(其实是趋向于正无穷)。所以,最小化这一惩罚因子具有使得 靠近 的效果。 |