Commit add249c5 by xiaotong

bug fixes

parent 86cb0715
......@@ -101,9 +101,9 @@ void T2TPredictor::Create(T2TModel * model, XTensor * top, const XTensor * input
dims[i] = input->GetDim(i);
dims[input->order - 1] = beamSize;
InitTensor(&state->probPath, input->order, dims, X_FLOAT);
InitTensor(&state->nstep, input->order, dims, X_FLOAT);
InitTensor(&state->endMark, input->order, dims, X_FLOAT);
InitTensor(&state->probPath, input->order, dims, X_FLOAT, 1.0F, input->devID, input->mem);
InitTensor(&state->nstep, input->order, dims, X_FLOAT, 1.0F, input->devID, input->mem);
InitTensor(&state->endMark, input->order, dims, X_FLOAT, 1.0F, input->devID, input->mem);
state->probPath.SetZeroAll();
state->nstep.SetZeroAll();
......@@ -206,7 +206,6 @@ void T2TPredictor::Predict(T2TStateBundle * next, XTensor * encoding, XTensor *
/* the decoder output of the last position */
decodingStep = CopyIndexed(decoding, decoding.order - 2, selectSrc, selectTgt);
/* generate the output probabilities */
m->outputLayer->Make(decodingStep, output);
......
......@@ -160,25 +160,25 @@ void T2TSearch::Score(T2TStateBundle * prev, T2TStateBundle * beam)
InitTensor(&len, &lenPrev);
InitTensor(&lp, &lenPrev);
//_ScaleAndShift(&lenPrev, &len, 1.0F, 1.0F);
_ScaleAndShift(&lenPrev, &len, 1.0F, 1.0F);
/* the GNMT-like length penalty */
//lp = T2TLengthPenalizer::GNMT(len, alpha);
lp = T2TLengthPenalizer::GNMT(len, alpha);
lp.Reshape(lp.unitNum);
/* score = log-prob/lp */
//_DivDim(&score, &lp, &score, 0);
_DivDim(&score, &lp, &score, 0);
InitTensor(&mask, &prev->endMark);
//CopyValues(prev->endMark, mask);
//_ScaleAndShiftMe(&mask, -1e9F);
CopyValues(prev->endMark, mask);
_ScaleAndShiftMe(&mask, -1e9F);
mask.Reshape(mask.unitNum);
/* mask the completed hypotheses so that they cannot
be involved in further sorting and beam search. */
//_SumDim(&score, &mask, &score, 0);
_SumDim(&score, &mask, &score, 0);
prob.Reshape(order, dims);
score.Reshape(order, dims);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论