二进制数而不是一个热矢量

Rag*_*lli 7 nlp machine-learning computer-vision neural-network

在进行逻辑回归时,通常的做法是使用一个热矢量作为期望的结果.所以,no of classes = no of nodes in output layer.我们不使用词汇表中的单词索引(或一般的类号),因为这可能错误地表示两个类的接近程度.但为什么我们不能使用二进制数而不是单热数?

即如果有4个类,我们可以将每个类表示为00,01,10,11,从而log(no of classes)在输出层中生成节点.

Meh*_*hdi 11

如果用二进制编码就可以了.但您可能需要添加另一个图层(或过滤器),具体取决于您的任务和模型.因为您的编码现在涉及由于二进制表示而导致的无效共享功能.

例如,input(x = [x1, x2])的二进制编码:

'apple' = [0, 0]
'orange' = [0, 1]
'table' = [1, 0]
'chair' = [1, 1]
Run Code Online (Sandbox Code Playgroud)

这意味着orangechair共享相同的功能x2.现在预测两个类y:

'fruit' = 0
'furniture' = 1
Run Code Online (Sandbox Code Playgroud)

标记数据样本的线性优化模型(W = [w1, w2]和偏差b):

(argmin W) Loss = y - (w1 * x1 + w2 * x2 + b)
Run Code Online (Sandbox Code Playgroud)

每次更新w2的权重chairfurniture你选择的一个积极的改善orange这一类为好.在这种特殊情况下,如果添加另一个图层U = [u1, u2],则可以解决它:

(argmin U,W) Loss = y - (u1 * (w1 * x1 + w2 * x2 + b) +
                         u2 * (w1 * x1 + w2 * x2 + b) +
                         b2)
Run Code Online (Sandbox Code Playgroud)

好的,为什么不通过使用单热编码来避免这种错过表示.:)