diff --git a/maca_common/include/ProgramParameters.hpp b/maca_common/include/ProgramParameters.hpp index a149a50196c277e2e79c0fa282ce8b735346cdec..e7ab85cd14cb01d441971d3032e506cf2a7ffe49 100644 --- a/maca_common/include/ProgramParameters.hpp +++ b/maca_common/include/ProgramParameters.hpp @@ -73,6 +73,8 @@ struct ProgramParameters static bool featureExtraction; static bool devEvalOnGold; static bool devLoss; + static bool randomDebug; + static float randomDebugProbability; private : diff --git a/maca_common/src/Dict.cpp b/maca_common/src/Dict.cpp index b28df180ceb17a451c8a3f83866a5e7f2881b19d..03f8753473920be3fd5a2568a376f16f26b6bbd2 100644 --- a/maca_common/src/Dict.cpp +++ b/maca_common/src/Dict.cpp @@ -375,7 +375,8 @@ unsigned int Dict::addEntry(const std::string & s) if ((int)str2index.size() >= ProgramParameters::dictCapacity) { - fprintf(stderr, "ERROR (%s) : Dict %s of maximal capacity %d is full. Aborting.\n", ERRINFO, name.c_str(), ProgramParameters::dictCapacity); + fprintf(stderr, "ERROR (%s) : Dict %s of maximal capacity %d is full. Saving dict than aborting.\n", ERRINFO, name.c_str(), ProgramParameters::dictCapacity); + save(); exit(1); } diff --git a/maca_common/src/ProgramParameters.cpp b/maca_common/src/ProgramParameters.cpp index 07be5b4422bb0c37d52a272046e1edcdbcf0add5..13a6629c785e4d46f428683889455fabbd283d70 100644 --- a/maca_common/src/ProgramParameters.cpp +++ b/maca_common/src/ProgramParameters.cpp @@ -67,4 +67,6 @@ float ProgramParameters::maskRate; bool ProgramParameters::featureExtraction; bool ProgramParameters::devEvalOnGold; bool ProgramParameters::devLoss; +bool ProgramParameters::randomDebug; +float ProgramParameters::randomDebugProbability; diff --git a/trainer/include/Trainer.hpp b/trainer/include/Trainer.hpp index 7568a73278ddf1cc9bb9d4eef93d45a283ffaa40..12942838f77490a3ed658f7dd4619669c5ce8705 100644 --- a/trainer/include/Trainer.hpp +++ b/trainer/include/Trainer.hpp @@ -83,6 +83,8 @@ class Trainer void doStepTrain(); /// @brief Compute and print dev scores, increase epoch counter. void prepareNextEpoch(); + /// @brief Set the debug variable ProgramParameters::debug. + void setDebugValue(); public : diff --git a/trainer/src/TrainInfos.cpp b/trainer/src/TrainInfos.cpp index d754cd6577f713d74efe0217f83d6c3046242a7f..bc893e3d763dd222e28cf7fef69ccd86adb41797 100644 --- a/trainer/src/TrainInfos.cpp +++ b/trainer/src/TrainInfos.cpp @@ -281,7 +281,7 @@ void TrainInfos::printScores(FILE * output) } if (ProgramParameters::interactive) - fprintf(stderr, " \r"); + fprintf(output, " \r"); if (ProgramParameters::printTime) fprintf(output, "[%s] ", getTime().c_str()); fprintf(output, "Iteration %d/%d : \n", getEpoch(), ProgramParameters::nbIter); diff --git a/trainer/src/Trainer.cpp b/trainer/src/Trainer.cpp index 6076320b5a65e03b2bc93019631b0c8af208c3eb..f33d5387c895130ca7fe6b1cc33360b03f16cc1c 100644 --- a/trainer/src/Trainer.cpp +++ b/trainer/src/Trainer.cpp @@ -23,6 +23,19 @@ Trainer::Trainer(TransitionMachine & tm, BD & bd, Config & config, BD * devBD, C pastTime = std::chrono::high_resolution_clock::now(); } +void Trainer::setDebugValue() +{ + if (!ProgramParameters::randomDebug) + return; + + if (ProgramParameters::interactive) + fprintf(stderr, " \r"); + if (ProgramParameters::printTime) + fprintf(stderr, "[%s] :\n", getTime().c_str()); + + ProgramParameters::debug = choiceWithProbability(ProgramParameters::randomDebugProbability); +} + void Trainer::computeScoreOnDev() { if (!devConfig) diff --git a/trainer/src/macaon_train.cpp b/trainer/src/macaon_train.cpp index 7a9a2b80211c781de3ca871571fa28de8da69066..ede41e24d363d95a83fd6aaa6362814ee286d351 100644 --- a/trainer/src/macaon_train.cpp +++ b/trainer/src/macaon_train.cpp @@ -40,6 +40,9 @@ po::options_description getOptionsDescription() opt.add_options() ("help,h", "Produce this help message") ("debug,d", "Print infos on stderr") + ("randomDebug", "Print infos on stderr with a probability of randomDebugProbability") + ("randomDebugProbability", po::value<float>()->default_value(0.001), + "Probability that debug infos will be printed") ("printEntropy", "Print mean entropy and standard deviation accross sequences") ("dicts", po::value<std::string>()->default_value(""), "The .dict file describing all the dictionaries to be used in the experiement. By default the filename specified in the .tm file will be used") @@ -270,6 +273,7 @@ int main(int argc, char * argv[]) ProgramParameters::bdName = vm["bd"].as<std::string>(); ProgramParameters::mcdName = vm["mcd"].as<std::string>(); ProgramParameters::debug = vm.count("debug") == 0 ? false : true; + ProgramParameters::randomDebug = vm.count("randomDebug") == 0 ? false : true; ProgramParameters::printEntropy = vm.count("printEntropy") == 0 ? false : true; ProgramParameters::printTime = vm.count("printTime") == 0 ? false : true; ProgramParameters::featureExtraction = vm.count("featureExtraction") == 0 ? false : true; @@ -291,6 +295,7 @@ int main(int argc, char * argv[]) ProgramParameters::sequenceDelimiterTape = vm["sequenceDelimiterTape"].as<std::string>(); ProgramParameters::sequenceDelimiter = vm["sequenceDelimiter"].as<std::string>(); ProgramParameters::learningRate = vm["lr"].as<float>(); + ProgramParameters::randomDebugProbability = vm["randomDebugProbability"].as<float>(); ProgramParameters::beta1 = vm["b1"].as<float>(); ProgramParameters::beta2 = vm["b2"].as<float>(); ProgramParameters::bias = vm["bias"].as<float>();