diff --git a/trainer/include/TrainInfos.hpp b/trainer/include/TrainInfos.hpp index 3fb815a8901cee1543c047eb63b8853d83f9d42a..c263f46d72deda8e339b2c652eb42d5f8185692b 100644 --- a/trainer/include/TrainInfos.hpp +++ b/trainer/include/TrainInfos.hpp @@ -18,7 +18,6 @@ class TrainInfos std::string filename; int lastEpoch; int lastSaved; - int lastIndexTreated; std::map< std::string, std::vector<float> > trainLossesPerClassifierPerEpoch; std::map< std::string, std::vector<float> > devLossesPerClassifierPerEpoch; std::map< std::string, std::vector<float> > trainScoresPerClassifierPerEpoch; @@ -36,7 +35,7 @@ class TrainInfos void saveToFilename(); void addTrainScore(const std::string & classifier, float score); void addDevScore(const std::string & classifier, float score); - float computeScoreOnTapes(Config & c, std::vector<std::string> tapes); + float computeScoreOnTapes(Config & c, std::vector<std::string> tapes, int from, int to); public : diff --git a/trainer/src/TrainInfos.cpp b/trainer/src/TrainInfos.cpp index b8ea23177648fdcf8f2e3ae92c33c86c2cbcb721..aa84078b4c96c34413fba549b4e6ba7669352a55 100644 --- a/trainer/src/TrainInfos.cpp +++ b/trainer/src/TrainInfos.cpp @@ -143,12 +143,12 @@ void TrainInfos::addDevScore(const std::string & classifier, float score) devScoresPerClassifierPerEpoch[classifier].emplace_back(score); } -float TrainInfos::computeScoreOnTapes(Config & c, std::vector<std::string> tapes) +float TrainInfos::computeScoreOnTapes(Config & c, std::vector<std::string> tapes, int from, int to) { float res = 0.0; for (auto & tape : tapes) - res += c.getTape(tape).getScore(0, lastIndexTreated); + res += c.getTape(tape).getScore(from, to); return res / tapes.size(); } @@ -158,13 +158,13 @@ void TrainInfos::computeTrainScores(Config & c) for (auto & it : topologyPrinted) { if (it.first == "Parser") - addTrainScore(it.first, computeScoreOnTapes(c, {"GOV", "LABEL"})); + addTrainScore(it.first, computeScoreOnTapes(c, {"GOV", "LABEL"}, 0, c.getHead())); else if (it.first == "Tagger") - addTrainScore(it.first, computeScoreOnTapes(c, {"POS"})); + addTrainScore(it.first, computeScoreOnTapes(c, {"POS"}, 0, c.getHead())); else if (it.first == "Morpho") - addTrainScore(it.first, computeScoreOnTapes(c, {"MORPHO"})); + addTrainScore(it.first, computeScoreOnTapes(c, {"MORPHO"}, 0, c.getHead())); else if (it.first == "Lemmatizer_Rules") - addTrainScore(it.first, computeScoreOnTapes(c, {"LEMMA"})); + addTrainScore(it.first, computeScoreOnTapes(c, {"LEMMA"}, 0, c.getHead())); else if (split(it.first, '_')[0] == "Error") addTrainScore(it.first, 100.0); else @@ -180,15 +180,15 @@ void TrainInfos::computeDevScores(Config & c) for (auto & it : topologyPrinted) { if (it.first == "Parser") - addDevScore(it.first, computeScoreOnTapes(c, {"GOV", "LABEL"})); + addDevScore(it.first, computeScoreOnTapes(c, {"GOV", "LABEL"}, 0, c.getHead())); else if (it.first == "Parser") - addDevScore(it.first, computeScoreOnTapes(c, {"GOV", "LABEL"})); + addDevScore(it.first, computeScoreOnTapes(c, {"GOV", "LABEL"}, 0, c.getHead())); else if (it.first == "Tagger") - addDevScore(it.first, computeScoreOnTapes(c, {"POS"})); + addDevScore(it.first, computeScoreOnTapes(c, {"POS"}, 0, c.getHead())); else if (it.first == "Morpho") - addDevScore(it.first, computeScoreOnTapes(c, {"MORPHO"})); + addDevScore(it.first, computeScoreOnTapes(c, {"MORPHO"}, 0, c.getHead())); else if (it.first == "Lemmatizer_Rules") - addDevScore(it.first, computeScoreOnTapes(c, {"LEMMA"})); + addDevScore(it.first, computeScoreOnTapes(c, {"LEMMA"}, 0, c.getHead())); else if (split(it.first, '_')[0] == "Error") addDevScore(it.first, 100.0); else @@ -292,8 +292,3 @@ bool TrainInfos::mustSave(const std::string & classifier) return mustSavePerClassifierPerEpoch.count(classifier) && mustSavePerClassifierPerEpoch[classifier].back(); } -void TrainInfos::setLastIndexTreated(int index) -{ - lastIndexTreated = index; -} - diff --git a/trainer/src/Trainer.cpp b/trainer/src/Trainer.cpp index 7d847ddbb81aaffae55105b27ee858ab68557817..56a2a4997cae7cd785fadbdee2ee3fa4d280b7bb 100644 --- a/trainer/src/Trainer.cpp +++ b/trainer/src/Trainer.cpp @@ -192,7 +192,6 @@ void Trainer::resetAndShuffle() { tm.reset(); trainConfig.reset(); - TI.setLastIndexTreated(0); if(ProgramParameters::shuffleExamples) trainConfig.shuffle(ProgramParameters::sequenceDelimiterTape, ProgramParameters::sequenceDelimiter); @@ -541,8 +540,6 @@ void Trainer::train() if (ProgramParameters::iterationSize != -1 && nbSteps >= ProgramParameters::iterationSize) try {prepareNextEpoch();} catch (EndOfTraining &) {break;} - - TI.setLastIndexTreated(trainConfig.getHead()); } if (ProgramParameters::debug)