Output Projection in Seq2Seq model Tensorflow
<p>I'm going through the translation code implemented by <code>tensorflow</code> using <code>seq2seq</code> model. I'm following <code>tensorflow</code> tutorial about <a href="https://www.tensorflow.org/versions/r0.10/tutorials/seq2seq/index.html" rel="nofollow"><code>seq2seq</code> model</a>.</p>

<p>In that tutorial there is a part explaining a concept called <a href="https://www.tensorflow.org/versions/r0.10/tutorials/seq2seq/index.html#sampled-softmax-and-output-projection" rel="nofollow">output projection</a> which they have implemented in <a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/models/rnn/translate/seq2seq_model.py" rel="nofollow">seq2seq_model.py</a> code. I understand the code. But I don't understand what this <strong>output projection</strong> part is doing.</p>

<p>It would be great if someone can explain me what is going on behind this output projection thing..?</p>

<p>Thank You!!</p>

<p>Internally, a neural network operates on dense vectors of some size, often 256, 512 or 1024 floats (let's say 512 for here). But at the end it needs to predict a word from the vocabulary which is often much larger, e.g., 40000 words. Output projection is the final linear layer that converts (projects) from the internal representation to the larger one. So, for example, it can consist of a 512 x 40000 parameter matrix and a 40000 parameter for the bias vector. The reason it is kept separate in seq2seq code is that some loss functions (e.g., the sampled softmax loss) need direct access to the final 512-sized vector and the output projection matrix. Hope that helps!</p>

python tensorflow