avoid duplicate generation of source-side features when training VW

This commit is contained in:
Ales Tamchyna 2015-02-04 11:07:07 +01:00
parent f69c1dab02
commit e932e96db7

View File

@ -155,11 +155,6 @@ public:
const WordsRange &sourceRange = translationOptionList.Get(0)->GetSourceWordsRange();
const InputPath &inputPath = translationOptionList.Get(0)->GetInputPath();
for(size_t i = 0; i < sourceFeatures.size(); ++i)
(*sourceFeatures[i])(input, inputPath, sourceRange, classifier);
const std::vector<VWFeatureBase*>& targetFeatures = VWFeatureBase::GetTargetFeatures(GetScoreProducerDescription());
// optionally update translation options using leave-one-out
std::vector<bool> keep = (m_leaveOneOut.size() > 0)
? LeaveOneOut(translationOptionList)
@ -186,6 +181,11 @@ public:
}
}
for(size_t i = 0; i < sourceFeatures.size(); ++i)
(*sourceFeatures[i])(input, inputPath, sourceRange, classifier);
const std::vector<VWFeatureBase*>& targetFeatures = VWFeatureBase::GetTargetFeatures(GetScoreProducerDescription());
std::vector<bool>::const_iterator iterKeep;
for(iterTransOpt = translationOptionList.begin(), iterLoss = losses.begin(), iterKeep = keep.begin() ;
iterTransOpt != translationOptionList.end() ; ++iterTransOpt, ++iterLoss) {