Commit 5a9327f8 by xiaotong

debugging

parent 9a4446f1
...@@ -107,11 +107,14 @@ void T2TSearch::Search(T2TModel * model, XTensor * input, XTensor * padding, XTe ...@@ -107,11 +107,14 @@ void T2TSearch::Search(T2TModel * model, XTensor * input, XTensor * padding, XTe
paddingBeam.ReshapeMerged(paddingBeam.order - 3); paddingBeam.ReshapeMerged(paddingBeam.order - 3);
/* max output-length = 2 * source-length */ /* max output-length = 2 * source-length */
maxLength = input->GetDim(-1) * 2; int lengthLimit = input->GetDim(-1) * 2;
CheckNTErrors(maxLength > 0, "no max length specified!"); int l = 0;
CheckNTErrors(lengthLimit > 0, "no max length specified!");
T2TStateBundle * states = new T2TStateBundle[maxLength + 1]; T2TStateBundle * states = new T2TStateBundle[lengthLimit + 1];
T2TStateBundle * first = states; T2TStateBundle * first = states;
T2TStateBundle * cur = NULL;
T2TStateBundle * next = NULL;
/* create the first state */ /* create the first state */
predictor.Create(model, &encodingBeam, input, beamSize, first); predictor.Create(model, &encodingBeam, input, beamSize, first);
...@@ -120,9 +123,9 @@ void T2TSearch::Search(T2TModel * model, XTensor * input, XTensor * padding, XTe ...@@ -120,9 +123,9 @@ void T2TSearch::Search(T2TModel * model, XTensor * input, XTensor * padding, XTe
first->isStart = true; first->isStart = true;
/* generate the sequence from left to right */ /* generate the sequence from left to right */
for(int i = 0 ; i < maxLength; i++){ for(int l = 0 ; l < lengthLimit; l++){
T2TStateBundle * cur = states + i; cur = states + l;
T2TStateBundle * next = states + i + 1; next = states + l + 1;
/* read the current state */ /* read the current state */
predictor.Read(model, cur); predictor.Read(model, cur);
...@@ -148,7 +151,7 @@ void T2TSearch::Search(T2TModel * model, XTensor * input, XTensor * padding, XTe ...@@ -148,7 +151,7 @@ void T2TSearch::Search(T2TModel * model, XTensor * input, XTensor * padding, XTe
} }
/* fill the heap with imcomplete hypotheses if neccesary */ /* fill the heap with imcomplete hypotheses if neccesary */
FillHeap(&states[maxLength]); FillHeap(next);
Dump(output); Dump(output);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论