我最近开始使用 ML 和 TensorFlow。在经历CIFAR10-tutorial时在网站上我看到一段让我有点困惑的段落:
The usual method for training a network to perform N-way classification is multinomial logistic regression, aka. softmax regression. Softmax regression applies a softmax nonlinearity to the output of the network and calculates the cross-entropy between the normalized predictions and a 1-hot encoding of the label. For regularization, we also apply the usual weight decay losses to all learned variables. The objective function for the model is the sum of the cross entropy loss and all these weight decay terms, as returned by the loss() function.
我在论坛上读过一些关于什么是权重衰减的答案,我可以说它是用于正则化的目的,以便可以计算权重值以获得最小的损失和更高的准确性。
现在,在上面的文本中,我了解到 loss()
由交叉熵损失(即预测和正确标签值的差异)和权重衰减损失组成。
我很清楚交叉熵损失,但是这个权重衰减损失是什么,为什么不只是权重衰减呢?这个损失是如何计算的?
最佳答案
权重衰减
只不过是权重的L2正则化
,可以使用tf.nn.l2_loss
来实现。
正则化的损失函数由下式给出:
上式的第二项定义了权重 (theta) 的 L2 正则化
。一般是为了避免过拟合而添加的。这会惩罚峰值权重并确保考虑所有输入。 (很少的峰值权重意味着只有那些与之相关的输入才会被考虑用于决策。)
在梯度下降参数更新过程中,上述L2正则化最终意味着每个权重都线性衰减:W_new = (1 - lambda)* W_old + alpha*delta_J/delta_w
。这就是为什么它通常被称为权重衰减
。
关于machine-learning - 什么是体重衰减?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45540908/