diff --git a/maca_common/src/programOptionsTemplates.cpp b/maca_common/src/programOptionsTemplates.cpp index 99c9c6697d5d6216ac4712b62eb55c5b98e5bc42..d08163d6206c318c93f4abbc722f42fdee85dfa9 100644 --- a/maca_common/src/programOptionsTemplates.cpp +++ b/maca_common/src/programOptionsTemplates.cpp @@ -253,13 +253,13 @@ void launchTraining() if(ProgramParameters::devFilename.empty()) { - trainer.reset(new Trainer(transitionMachine, trainBD, trainConfig)); + trainer.reset(new Trainer(transitionMachine, trainConfig)); } else { devBD.reset(new BD(ProgramParameters::bdFilename, ProgramParameters::mcdFilename)); devConfig.reset(new Config(*devBD.get(), ProgramParameters::devFilename)); - trainer.reset(new Trainer(transitionMachine, trainBD, trainConfig, devBD.get(), devConfig.get())); + trainer.reset(new Trainer(transitionMachine, trainConfig, devConfig.get())); } trainer->train(); diff --git a/trainer/include/Trainer.hpp b/trainer/include/Trainer.hpp index 5ffe8ef960b32668087dff8e422ef9f181267e86..e52c2c7b9291ab894722a3e2dedabcfbba79ec1d 100644 --- a/trainer/include/Trainer.hpp +++ b/trainer/include/Trainer.hpp @@ -5,6 +5,7 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ + /// @file Trainer.hpp /// @author Franck Dary /// @version 1.0 @@ -14,11 +15,10 @@ #define TRAINER__H #include "TransitionMachine.hpp" -#include "BD.hpp" #include "Config.hpp" #include "TrainInfos.hpp" -/// @brief An object capable of training a TransitionMachine given a BD initialized with training examples. +/// @brief An object capable of training a TransitionMachine given a Config initialized with training examples. class Trainer { private : @@ -48,16 +48,10 @@ class Trainer /// @brief The TransitionMachine that will be trained. TransitionMachine & tm; - /// @brief The BD initialized with training examples. - BD & trainBD; - /// @brief The configuration of the TransitionMachine while processing trainBD. + /// @brief The configuration of the TransitionMachine while processing train corpus. Config & trainConfig; - /// @brief The BD initialized with dev examples. - /// - /// Can be nullptr if dev is not used in this training. - BD * devBD; - /// @brief The configuration of the TransitionMachine while processing devBD. + /// @brief The configuration of the TransitionMachine while processing dev corpus. /// /// Can be nullptr if dev is not used in this training. Config * devConfig; @@ -100,23 +94,19 @@ class Trainer /// @brief Construct a new Trainer without a dev set. /// /// @param tm The TransitionMachine to use. - /// @param bd The BD to use. /// @param config The config to use. - Trainer(TransitionMachine & tm, BD & bd, Config & config); + Trainer(TransitionMachine & tm, Config & config); /// @brief Construct a new Trainer with a dev set. /// /// @param tm The TransitionMachine to use. - /// @param bd The BD corresponding to the training dataset. /// @param config The Config corresponding to bd. - /// @param devBD The BD corresponding to the dev dataset. - /// @param devConfig The Config corresponding to devBD. - Trainer(TransitionMachine & tm, BD & bd, Config & config, BD * devBD, Config * devConfig); + /// @param devConfig The Config corresponding to dev corpus. + Trainer(TransitionMachine & tm, Config & config, Config * devConfig); /// @brief Train the TransitionMachine one example at a time. /// /// For each epoch all the Classifier of the TransitionMachine are fed all the /// training examples, at the end of the epoch Classifier are evaluated on - /// the devBD if available, and each Classifier will be saved only if its score /// on the current epoch is its all time best.\n /// When a Classifier is saved that way, all the Dict involved are also saved. void train(); diff --git a/trainer/src/Trainer.cpp b/trainer/src/Trainer.cpp index d05667fafff86114d9a16fc17ec93a153c098c6d..1c1b0b706616e6e866531f8394e01aca2fc40925 100644 --- a/trainer/src/Trainer.cpp +++ b/trainer/src/Trainer.cpp @@ -5,13 +5,13 @@ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ + #include "Trainer.hpp" #include "util.hpp" -Trainer::Trainer(TransitionMachine & tm, BD & bd, Config & config) -: tm(tm), trainBD(bd), trainConfig(config) +Trainer::Trainer(TransitionMachine & tm, Config & config) +: tm(tm), trainConfig(config) { - this->devBD = nullptr; this->devConfig = nullptr; nbSteps = 0; @@ -21,7 +21,7 @@ Trainer::Trainer(TransitionMachine & tm, BD & bd, Config & config) pastTime = std::chrono::high_resolution_clock::now(); } -Trainer::Trainer(TransitionMachine & tm, BD & bd, Config & config, BD * devBD, Config * devConfig) : tm(tm), trainBD(bd), trainConfig(config), devBD(devBD), devConfig(devConfig) +Trainer::Trainer(TransitionMachine & tm, Config & config, Config * devConfig) : tm(tm), trainConfig(config), devConfig(devConfig) { nbSteps = 0; nbActions = 0;