2016-08-03 72 views

回答

0

RNN的輸出不是嵌入。我們將RNN單元中最後一層的輸出轉換爲vocabulary_size的向量,方法是將其與適當的矩陣相乘。

查看PTB Language Model示例以獲得更好的想法。具體看行133-136:

softmax_w = tf.get_variable("softmax_w", [size, vocab_size], dtype=data_type()) 
softmax_b = tf.get_variable("softmax_b", [vocab_size], dtype=data_type()) 
logits = tf.matmul(output, softmax_w) + softmax_b 

上面的操作會給你logits。這個logits是你的詞彙量的概率分佈。 numpy.random.choice可能會幫助您使用這些logits進行預測。

相關問題