9#include <mva/methods/FANN.h>
11#include <framework/logging/Logger.h>
24 int version = pt.get<
int>(
"FANN_version");
26 B2ERROR(
"Unknown weightfile version " << std::to_string(version));
27 throw std::runtime_error(
"Unknown weightfile version " + std::to_string(version));
40 m_test_rate = pt.get<
unsigned int>(
"FANN_test_rate");
50 pt.put(
"FANN_version", 1);
71 po::options_description description(
"FANN options");
72 description.add_options()
73 (
"max_epochs", po::value<unsigned int>(&
m_max_epochs),
"Number of iEpochs")
74 (
"verbose_mode", po::value<bool>(&
m_verbose_mode),
"Prints out the training status or not")
76 "Architecture with number of neurons in each hidden layer")
78 "Name of acitvation function used for hidden layers")
80 "Name of acitvation function used for output layer")
81 (
"error_function", po::value<std::string>(&
m_error_function),
"Name of error function")
82 (
"training_method", po::value<std::string>(&
m_training_method),
"Method used for backpropagation")
83 (
"validation_fraction", po::value<double>(&
m_validation_fraction),
"Fraction of training sample used for validation.")
85 "Number of times the training is repeated with a new weight random seed.")
86 (
"test_rate", po::value<unsigned int>(&
m_test_rate),
"Rate of iEpochs to check the validation error")
87 (
"number_of_threads", po::value<unsigned int>(&
m_number_of_threads),
"Number of threads for parallel training")
88 (
"scale_features", po::value<bool>(&
m_scale_features),
"Boolean indicating if features should be scaled or not")
89 (
"scale_target", po::value<bool>(&
m_scale_target),
"Boolean indicating if target should be scaled or not");
95 std::vector<unsigned int> hiddenLayers;
98 while (std::getline(iLayers, layer,
',')) {
99 for (
auto& character : layer) {
100 if (character ==
'N') character =
'x';
102 auto* iLayerSize =
new TFormula(
"iLayerSize", layer.c_str());
103 hiddenLayers.push_back(iLayerSize->Eval(nf));
double m_validation_fraction
Fraction of training sample used for validation in order to avoid overtraining.
std::string m_hidden_layers_architecture
String containing the architecture of hidden neurons.
bool m_scale_features
Scale features before training.
bool m_verbose_mode
Sets to report training status or not.
unsigned int m_random_seeds
Number of times the training is repeated with a new weight random seed.
std::string m_error_function
Loss function.
virtual po::options_description getDescription() override
Returns a program options description for all available options.
unsigned int m_number_of_threads
Number of threads for parallel training.
unsigned int m_test_rate
Error on validation is compared with the one before.
std::string m_hidden_activiation_function
Activation function in hidden layer.
bool m_scale_target
Scale target before training.
std::vector< unsigned int > getHiddenLayerNeurons(unsigned int nf) const
Returns the internal vector parameter with the number of hidden neurons per layer.
virtual void load(const boost::property_tree::ptree &pt) override
Load mechanism to load Options from a xml tree.
std::string m_training_method
Training method for back propagation.
std::string m_output_activiation_function
Activation function in output layer.
unsigned int m_max_epochs
Maximum number of epochs.
virtual void save(boost::property_tree::ptree &pt) const override
Save mechanism to store Options in a xml tree.
Abstract base class for different kinds of events.