diff --git a/MLP/src/MLP.cpp b/MLP/src/MLP.cpp index daf41e8660438eda5434ebf3bc648bbe02170bdb..409b054d287d985755e70980bb4fd90a7e57e566 100644 --- a/MLP/src/MLP.cpp +++ b/MLP/src/MLP.cpp @@ -149,6 +149,11 @@ void MLP::addLayerToModel(Layer & layer) { dynet::Parameter W = model.add_parameters({(unsigned)layer.output_dim, (unsigned)layer.input_dim}); dynet::Parameter b = model.add_parameters({(unsigned)layer.output_dim}); + if (!ProgramParameters::randomParameters) + { + W.set_value(std::vector<float>((unsigned)layer.output_dim * (unsigned)layer.input_dim, 1.0)); + b.set_value(std::vector<float>((unsigned)layer.output_dim, 1.0)); + } parameters.push_back({W,b}); } diff --git a/error_correction/src/macaon_train_error_detector.cpp b/error_correction/src/macaon_train_error_detector.cpp index 1751e92eac409a517dcf7df1958ac06b2968f135..e1f87e87db3afd78d0ff638cee24be9d1f634817 100644 --- a/error_correction/src/macaon_train_error_detector.cpp +++ b/error_correction/src/macaon_train_error_detector.cpp @@ -67,6 +67,8 @@ po::options_description getOptionsDescription() "Is the shell interactive ? Display advancement informations") ("randomEmbeddings", po::value<bool>()->default_value(false), "When activated, the embeddings will be randomly initialized") + ("randomParameters", po::value<bool>()->default_value(true), + "When activated, the parameters will be randomly initialized") ("sequenceDelimiterTape", po::value<std::string>()->default_value("EOS"), "The name of the buffer's tape that contains the delimiter token for a sequence") ("sequenceDelimiter", po::value<std::string>()->default_value("1"), @@ -510,6 +512,7 @@ int main(int argc, char * argv[]) ProgramParameters::interactive = vm["interactive"].as<bool>(); ProgramParameters::shuffleExamples = vm["shuffle"].as<bool>(); ProgramParameters::randomEmbeddings = vm["randomEmbeddings"].as<bool>(); + ProgramParameters::randomParameters = vm["randomParameters"].as<bool>(); ProgramParameters::sequenceDelimiterTape = vm["sequenceDelimiterTape"].as<std::string>(); ProgramParameters::sequenceDelimiter = vm["sequenceDelimiter"].as<std::string>(); ProgramParameters::learningRate = vm["lr"].as<float>(); diff --git a/maca_common/include/ProgramParameters.hpp b/maca_common/include/ProgramParameters.hpp index 8e706fe7a5290a7b2d0203450554f3f132281049..0bc40747e9e3d9b575ff3c3f03863f3fc03f4c7b 100644 --- a/maca_common/include/ProgramParameters.hpp +++ b/maca_common/include/ProgramParameters.hpp @@ -45,6 +45,7 @@ struct ProgramParameters static int iterationSize; static int nbTrain; static bool randomEmbeddings; + static bool randomParameters; static bool printEntropy; static bool printTime; static std::string sequenceDelimiterTape; diff --git a/maca_common/src/ProgramParameters.cpp b/maca_common/src/ProgramParameters.cpp index 00283642a93d03d9e269d06a1b73f2f251bc5427..c5c8328d0d9a671ecf1e1be9548ca20e9f02dda1 100644 --- a/maca_common/src/ProgramParameters.cpp +++ b/maca_common/src/ProgramParameters.cpp @@ -38,6 +38,7 @@ int ProgramParameters::dynamicEpoch; float ProgramParameters::dynamicProbability; int ProgramParameters::showFeatureRepresentation; bool ProgramParameters::randomEmbeddings; +bool ProgramParameters::randomParameters; bool ProgramParameters::printEntropy; bool ProgramParameters::printTime; int ProgramParameters::iterationSize; diff --git a/trainer/src/Trainer.cpp b/trainer/src/Trainer.cpp index 4d2b8819a9b15f1f4453dd3e2946360d97467641..991cc15ba9912373f26d7c639521277f1795847c 100644 --- a/trainer/src/Trainer.cpp +++ b/trainer/src/Trainer.cpp @@ -210,6 +210,12 @@ void Trainer::train() if (zeroCostActions.empty()) { + if (trainConfig.head >= (int)trainConfig.tapes[0].ref.size()-1) + { + while (!trainConfig.stackEmpty()) + trainConfig.stackPop(); + break; + } fprintf(stderr, "ERROR (%s) : Unable to find any zero cost action. Aborting.\n", ERRINFO); fprintf(stderr, "State : %s\n", currentState->name.c_str()); trainConfig.printForDebug(stderr); diff --git a/trainer/src/macaon_train.cpp b/trainer/src/macaon_train.cpp index e7965a72c9f6ce2548401ecd523178c2a710d6da..358599950f44e82268186ac214d198d858958114 100644 --- a/trainer/src/macaon_train.cpp +++ b/trainer/src/macaon_train.cpp @@ -65,6 +65,8 @@ po::options_description getOptionsDescription() "Is the shell interactive ? Display advancement informations") ("randomEmbeddings", po::value<bool>()->default_value(false), "When activated, the embeddings will be randomly initialized") + ("randomParameters", po::value<bool>()->default_value(true), + "When activated, the parameters will be randomly initialized") ("sequenceDelimiterTape", po::value<std::string>()->default_value("EOS"), "The name of the buffer's tape that contains the delimiter token for a sequence") ("sequenceDelimiter", po::value<std::string>()->default_value("1"), @@ -253,6 +255,7 @@ int main(int argc, char * argv[]) ProgramParameters::interactive = vm["interactive"].as<bool>(); ProgramParameters::shuffleExamples = vm["shuffle"].as<bool>(); ProgramParameters::randomEmbeddings = vm["randomEmbeddings"].as<bool>(); + ProgramParameters::randomParameters = vm["randomParameters"].as<bool>(); ProgramParameters::sequenceDelimiterTape = vm["sequenceDelimiterTape"].as<std::string>(); ProgramParameters::sequenceDelimiter = vm["sequenceDelimiter"].as<std::string>(); ProgramParameters::learningRate = vm["lr"].as<float>();