Searches for the best generalizing architecture for a model.
More...
#include <model_selection.h>
Searches for the best generalizing architecture for a model.
Wraps two pluggable algorithms:
Both algorithms run on top of a user-supplied TrainingStrategy, which provides the underlying NeuralNetwork, Dataset and Loss they consume to score candidate architectures.
◆ ModelSelection()
| opennn::ModelSelection::ModelSelection |
( |
TrainingStrategy * | new_training_strategy = nullptr | ) |
|
Constructs a model selection bound to a training strategy.
Picks default selection algorithms (GrowingInputs and GrowingNeurons).
- Parameters
-
| new_training_strategy | Non-owning pointer to the strategy used to evaluate candidate architectures. May be null and supplied later via set(). |
◆ check()
| void opennn::ModelSelection::check |
( |
| ) |
const |
Validates that all components needed for selection are set.
Verifies the training strategy, its loss, the network behind the loss, the dataset, and that the dataset has at least one validation sample.
- Exceptions
-
| runtime_error | if any required component is missing. |
◆ from_JSON()
| void opennn::ModelSelection::from_JSON |
( |
const JsonDocument & | document | ) |
|
Restores the model-selection state from a JSON document.
- Parameters
-
◆ get_training_strategy()
| const TrainingStrategy * opennn::ModelSelection::get_training_strategy |
( |
| ) |
const |
|
inline |
Returns the underlying training strategy.
- Returns
- Const pointer to the strategy (may be nullptr).
◆ has_training_strategy()
| bool opennn::ModelSelection::has_training_strategy |
( |
| ) |
const |
|
inline |
Reports whether a training strategy is configured.
- Returns
- true if a non-null TrainingStrategy is set.
◆ load()
| void opennn::ModelSelection::load |
( |
const filesystem::path & | file_name | ) |
|
Loads the model-selection state from a JSON file on disk.
- Parameters
-
◆ perform_input_selection()
Runs the configured input-selection algorithm.
- Returns
- Results of the search (selected feature subset, error history, etc.).
◆ perform_neurons_selection()
Runs the configured neuron-selection algorithm.
- Returns
- Results of the search (best size found, error history, etc.).
◆ save()
| void opennn::ModelSelection::save |
( |
const filesystem::path & | file_name | ) |
const |
Saves the model-selection state to a JSON file on disk.
- Parameters
-
| file_name | Destination path. |
- Exceptions
-
| runtime_error | if the file cannot be opened for writing. |
◆ set()
Replaces the underlying training strategy.
- Parameters
-
| new_training_strategy | Non-owning pointer to the new strategy. |
◆ set_default()
| void opennn::ModelSelection::set_default |
( |
| ) |
|
Picks default selection algorithms.
Sets the neurons-selection algorithm to "GrowingNeurons" and the inputs-selection algorithm to "GrowingInputs".
◆ to_JSON()
| void opennn::ModelSelection::to_JSON |
( |
JsonWriter & | writer | ) |
const |
Serializes the model-selection state to JSON.
- Parameters
-
| writer | JSON writer that receives the configuration tree. |