Model Selection class
The model selection is used to find a neural network topology that minimizes error for new data. Two ways to obtain an optimal topology are neuron selection and input selection.
Neuron selection algorithms aim to get the optimal number of neurons in the neural network’s hidden perceptron layer, while input selection algorithms are responsible for finding the optimal subset of inputs.
As we did in previous sections, we will continue working with the iris data set, which can be downloaded from the DataSet class chapter. Before continuing, it is advisable to read the previous chapter on the TrainingStrategy class.
To construct a model selection object associated with a training strategy object, we write:
ModelSelection model_selection(&training_strategy);
The default model selection consists of a growing input or incremental neuron selection algorithm. The following sentence allows us to change this:
model_selection.set_inputs_selection_method(ModelSelection::InputsSelectionMethod::GENETIC_ALGORITHM); model_selection.set_neurons_selection_method(ModelSelection::NeuronsSelectionMethod::GROWING_NEURONS); GeneticAlgorithm* genetic_algorithm = model_selection.get_genetic_algorithm(); genetic_algorithm->set_individuals_number(100); GrowingNeurons* growing_neurons = model_selection.get_growing_neurons(); growing_neurons ->set_maximum_selection_failures(3);
Model selection’s main methods are those that perform input and neuron selection. To call them, we use:
model_selection.perform_input_selection(); model_selection.perform_neurons_selection();
We can save the above object to an XML file.
model_selection.save("model_selection.xml");
For more information on the ModelSelection class visit the ModelSelection Class Reference.