您不会将同一个矩阵乘以三次。你只乘一次。你得到一个与词汇量大小相同的输出向量。我将尝试用一个例子来解释。
假设你的模型有V(vocab_size) = 6、d = 4、C(number of context words) = 2、Wi(word_embedding matrix) size= 6 X 4、Wo(output word representation) size = 4 X 6。
x = [0,1,0,0,0,0] 和 y = y = [[0,0,0,1,0,0], [1,0,0,0,0,0]] (two one-hot encoded vectors) one for each context word 的训练示例。
现在,假设在输入和处理输入(h = x*Wi; z = h*Wo)之后,你得到的输出(z)是
z = [0.01520237, 0.84253418, 0.4773877 , 0.96858308, 0.09331018,0.54090063]
# take softmax, you will get
sft_max_z = [0.0976363 , 0.22331452, 0.15500148, 0.25331406, 0.1055682,0.16516544]
# sft_max_z represent the probability of each word occuring as input's context words.
#Now, subtract sft_max_z with each one-hot encoded vector in y to get the errors.
# errors = [[-0.0976363 , -0.22331452, -0.15500148, 0.74668594, -0.1055682 ,
-0.16516544],
[ 0.9023637 , -0.22331452, -0.15500148, -0.25331406, -0.1055682 ,
-0.16516544]]
现在,您可以减少错误并进行反向传播以进行训练。如果您正在预测,则选择概率最高的两个上下文词(在本例中为 1、3)。
可以将其视为具有多个类的分类问题(多项分类),并且同一对象可以同时属于多个类(多标签分类)。