#include "./Neurone/NeuroneB.h" #include "./Common/fonctions.h" #include "./Option/OptionTab.h" #include "./Neurone/FonctionActivation.h" #include "./Neurone/Neurone.h" #include "./Reseau/Reseau.h" #include "./Option/Option.h" #include "./Layer/Layer.h" #include #include #include #include #include #include #include #include /** * @method main * @param argc Nombre d'argument * @param argv Tableaux des arguments * @return Code de sortie : 0 si sortie normal */ int main (int argc, char **argv) { /* Initialisation des options */ OptionTab opts; enum Options {HELP,VERSION,DEVS,INPUT,OFF,ARCHI,EPOCH,ETA,GRAD,FCT}; opts.addOption(Option( HELP, "--help","-h", Type::NONE, "show help")); opts.addOption(Option( VERSION, "--version","-v", Type::NONE, "show the Neurone version")); opts.addOption(Option( DEVS, "--devs","-d", Type::NONE, "display author's names")); opts.addOption(Option( INPUT, "--input","-i", Type::NONE, "configure the network to run a specific trainingSet")); opts.addOption(Option( OFF, "--autooff","-o", Type::FLOAT, "set the percentage of error to stop (can slow the learning)")); opts.addOption(Option( ARCHI, "--archi","-a", Type::NONE, "display the architecture of the current configuration")); opts.addOption(Option( EPOCH, "--epoch","-e", Type::INT, "Configure the max number of epoch")); opts.addOption(Option( ETA, "--eta","-lr", Type::FLOAT, "Configure the learning rate")); opts.addOption(Option( GRAD, "--gradiant","-gr",Type::INT, "Configure the number of epoch before doing the backpropagation (error average)")); opts.addOption(Option( FCT, "--function","-f", Type::INT, "Configure the activation function")); /* Configuration par défaut */ std::string filename = "iris.data"; bool archi = false; double eta = 0.01; int epoch = 5000; unsigned int gradiant = 1; float auto_off = 0; FonctionActivation::EnumFonctionActivation fct = FonctionActivation::SIGMOID; /* Reconfiguration du réseau selon les arguments */ for(int i = 1; i < argc; i++) { switch(opts.getOptionID(argv[i])) { case HELP : std::cout << "Usage : ./launcher [OPTIONS] " << std::endl; std::cout << "Available options :" << std::endl; opts.printOptions(); return 0; break; case VERSION : std::cout << "Neural Network : version 1.0 " << std::endl; return 0; break; case DEVS : std::cout << "This tool was created by: [in alpabetic order]"<i+1&&isdigit(*argv[i+1])) { choice = atoi(argv[i+1]); i++; } else{ std::cout << "Please chose a file from the following list [more information in trainingSet directory] : "<>choice; } while(choice < 1 || choice > 5){ std::cout << "\033[1;31m Wrong input, please make a valid choice :\033[0m "; std::cin>>choice; } switch(choice) { case 1 : filename = "cancer.data"; break; case 2 : filename = "iris.data"; break; case 3 : filename = "bank.data"; break; case 4 : filename = "spam.data"; break; case 5 : std::cout << "Enter filename (has to be in trainingSet/ ) :"; std::cin>>filename; break; } } break; case OFF : if (argc>i+1&&isdigit(*argv[i+1])) { auto_off = atof(argv[i+1]); std::cout << "Auto_off percentage has been set to " << auto_off << std::endl; i++; } else { std::cout << "Please specify Auto_off percentage : "; std::cin >> auto_off; } break; case ARCHI : archi = true; break; case EPOCH : if (argc>i+1&&isdigit(*argv[i+1])) { epoch = atoi(argv[i+1]); std::cout << "Epoch has been set to " << epoch << std::endl; i++; } else { std::cout << "Please specify number of epoch : "; std::cin >> epoch; } break; case ETA : if (argc>i+1&&isdigit(*argv[i+1])) { eta = atof(argv[i+1]); std::cout<<"The learning rate has been set to "<> eta; } break; case GRAD : if(argc>i+1&&isdigit(*argv[i+1])) { gradiant = atoi(argv[i+1]); std::cout<<"The gradient descent as been set to "<> gradiant; } break; default : std::cout << "\033[1;31mAn argument could not be recognized. Please use "<i+1&&isdigit(*argv[i+1])) { choice = atoi(argv[i+1]); i++; } else{ std::cout << "Please chose a function from the following list : "<>choice; } while(choice < 1 || choice > 9){ std::cout << "\033[1;31m No function, please make a valid choice :\033[0m "; std::cin>>choice; } switch(choice) { case 1 : fct = FonctionActivation::IDENTITY; break; case 2 : fct = FonctionActivation::BINARYSTEP; break; case 3 : fct = FonctionActivation::SIGMOID; break; case 4 : fct = FonctionActivation::TAN; break; case 5 : fct = FonctionActivation::SIN; break; case 6 : fct = FonctionActivation::RELU; break; case 7 : fct = FonctionActivation::LRELU; break; case 8 : fct = FonctionActivation::PRELU; break; case 9 : fct = FonctionActivation::ELU; break; } } break; } } /* Lancement */ startLauncher(filename,archi,epoch,eta,gradiant,fct,auto_off); return 0; }