Commit 78a228b7 by xiaotong

hypothesis id

parent f8376440
...@@ -126,12 +126,19 @@ void T2TSearch::Generate(T2TStateBundle * beam) ...@@ -126,12 +126,19 @@ void T2TSearch::Generate(T2TStateBundle * beam)
CopyValues(scoreTopK, preID); CopyValues(scoreTopK, preID);
int sizePredict = score.GetDim(-1); int sizeVocab = score.GetDim(-1);
/* pre id !!! */ /* "preID" represents the id (or the offset) of previous state used to make the current
Descale(preID, sizePredict); hypothesis. Note that we reshape the "score" tensor into a matrix where each
row means a previous state. The column number is size-of-beam * vocab-size. We,
therefore, divide the top-k index by vocab-size to compute the id of previous state for
each hypothesis in the top-k list. */
Descale(preID, sizeVocab);
/* mod !!! */ /* Then we are going to do something similar to "preID". For the top-k predictions, we
need to know their indices in the vocabulary. We compute the offset of each prediction
in the vocabulary by dividing it with vocab-size and computing the remainder. */
Mod(index, sizeVocab);
score.Reshape(order, dims); score.Reshape(order, dims);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论