CBOW Formula Deduction

In our setting, the vocabulary size is $V$, and the hidden layer size is $N$.

The input is a one-hot representation vector, which means for a given input context word, only one out of $V$ units, $\{x_1,\cdots,x_V\}$, will be 1, and all other units are 0.

The weight between the input layer and the output layer can be represented by a $V \times N$ matrix $W$. Each row of $W$ is the $N$-dimension vector representation $v_w$ of the associated word of the input layer.

Given a context (a word), assuming $x_k=1$ and $x_{k’}=0$ for $k’\neq k$ then

\[h=x^TW=W{(k,\cdot):=v_{w_I}}\]

which is just copying the $k$-throw of $W$ to $h$. $v_{w_I}$ is the vector representation of the input word $w_I$. This implies that the link (activation) function of the hidden layer units is simply linear (i.e., directly passing its weighted sum of inputs to the next layer).

From the hidden layer to the output layer, there is a different weight matrix $W’=\{w’_{ij}\}$, which is a $N \times V$ matrix. Using these weights, we can compute a score $u_j$ for each word in the vocabulary,

\[ u_j={v’_{w_j}}^T \cdot h \]

where $v’_{w_j}$ is the $j$-th column of the matrix $W’$. Then we can use the softmax classification model to obtain the posterior distribution of the words, which is a multinomial distribution.

\[p(w_j|w_I)=y_j=\frac{\exp(u_j)}{\sum_{j’=1}^V{\exp(u_{j’})}}\]

where $y_j$ is the output of the $j$-th unit in the output layer.

Finally, we obtain:

\[p(w_j | w_I) = y_j = \frac{\exp( {v’_{w_o}}^T v_{w_I})}{\sum_{j’=1}^V{\exp( {v’_{w’_j}}^T v_{w_I})}}\]

时间: 2024-10-24 10:48:41

CBOW Formula Deduction的相关文章

redmine computed custom field formula tips

项目中要用到Computed custom field插件,公式不知道怎么写,查了些资料,记录在这里. 1.http://apidock.com/ruby/Time/strftime 查看ruby的字符串格式,用于改写Date/time format只显示日期,不显示时间. 2.https://github.com/annikoff/redmine_plugin_computed_custom_field/issues/34 看到formula里可以写复杂代码,比如增加变量.指定返回值等. 3.

hdu 5139 Formula(离线处理)

Formula Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1200    Accepted Submission(s): 415 Problem Description You are expected to write a program to calculate f(n) when a certain n is given.

Bestcoder #21&&hdoj 5139 Formula 【另类打表之分块】

Formula Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 155    Accepted Submission(s): 69 Problem Description f(n)=(∏i=1nin?i+1)%1000000007 You are expected to write a program to calculate f(n)

Calculate the formula

Problem Description You just need to calculate the sum of the formula: 1^2+3^2+5^2+……+ n ^2. Input In each case, there is an odd positive integer n. Output Print the sum. Make sure the sum will not exceed 2^31-1 Sample Input 3 Sample Output 10 用普通的做法

HDU2139 Calculate the formula【水题】

Calculate the formula Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7441    Accepted Submission(s): 2284 Problem Description You just need to calculate the sum of the formula: 1^2+3^2+5^2+--+

hdu 5139 Formula (找规律+离线处理)

Formula Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 206    Accepted Submission(s): 83 Problem Description f(n)=(∏i=1nin−i+1)%1000000007You are expected to write a program to calculate f(n) w

bzoj 4451 : [Cerc2015]Frightful Formula FFT

4451: [Cerc2015]Frightful Formula Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 177  Solved: 57[Submit][Status][Discuss] Description 给你一个n*n矩阵的第一行和第一列,其余的数通过如下公式推出: F[i,j]=a*f[i,j-1]+b*f[i-1,j]+c 求f[n][n]%(10^6+3) Input 第一行三个数n,a,b,c 第二行n个数,第i个表示f[i

bzoj1814: Ural 1519 Formula 1 2011-12-20

1814: Ural 1519 Formula 1Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 263  Solved: 70[Submit][Status][Discuss]DescriptionRegardless of the fact, that Vologda could not get rights to hold the Winter Olympic games of 20**, it is well- known, that the 

[BZOJ]|[Ura] Formula 1-----插头DP入门

1519. Formula 1 Time limit: 1.0 secondMemory limit: 64 MB Background Regardless of the fact, that Vologda could not get rights to hold the Winter Olympic games of 20**, it is well-known, that the city will conduct one of the Formula 1 events. Surely,