【发布时间】:2017-10-23 14:44:20
【问题描述】:
我知道二元交叉熵与分类交叉熵在两个类的情况下是相同的。
此外,我很清楚 softmax 是什么。
因此,我看到分类交叉熵只会惩罚应该为 1 的一个分量(概率)。
但是为什么我不能或不应该在 one-hot 向量上使用二元交叉熵?
Normal Case for 1-Label-Multiclass-Mutual-exclusivity-classification:
################
pred = [0.1 0.3 0.2 0.4]
label (one hot) = [0 1 0 0]
costfunction: categorical crossentropy
= sum(label * -log(pred)) //just consider the 1-label
= 0.523
Why not that?
################
pred = [0.1 0.3 0.2 0.4]
label (one hot) = [0 1 0 0]
costfunction: binary crossentropy
= sum(- label * log(pred) - (1 - label) * log(1 - pred))
= 1*-log(0.3)-log(1-0.1)-log(1-0.2)-log(1-0.4)
= 0.887
我看到,在二进制交叉熵中,zero 是一个目标类,对应于以下 one-hot 编码:
target class zero 0 -> [1 0]
target class one 1 -> [0 1]
总结:为什么我们只计算/总结预测类的负对数似然。为什么我们不惩罚其他应该为零/不应该的类?
如果使用二元交叉熵来处理单热向量。预期为零标签的概率也会受到惩罚。
【问题讨论】:
标签: machine-learning classification multilabel-classification one-hot-encoding cross-entropy