OpenNN
Open-source neural networks library
Loading...
Searching...
No Matches
opennn::NeuronSelection Class Referenceabstract

Abstract base class for algorithms that select the optimal number of hidden neurons. More...

#include <neuron_selection.h>

Inheritance diagram for opennn::NeuronSelection:
[legend]

Public Types

enum class  StoppingCondition {
  MaximumTime , SelectionErrorGoal , MaximumEpochs , MaximumSelectionFailures ,
  MaximumNeurons
}
 Reasons the neurons selection loop may terminate. More...
 

Public Member Functions

 NeuronSelection (TrainingStrategy *=nullptr)
 Constructs the algorithm bound to an optional training strategy.
 
virtual ~NeuronSelection ()=default
 
const TrainingStrategyget_training_strategy () const
 
bool has_training_strategy () const
 
bool get_display () const
 
void set (TrainingStrategy *)
 Binds the algorithm to the given training strategy.
 
void set_training_strategy (TrainingStrategy *new_training_strategy)
 
void set_default ()
 Restores default search bounds and stopping criteria.
 
void set_maximum_neurons (const Index new_maximum_neurons)
 
void set_minimum_neurons (const Index new_minimum_neurons)
 
void set_trials_number (const Index new_trials_number)
 
void set_display (bool new_display)
 
void set_validation_error_goal (const float new_validation_error_goal)
 
void set_maximum_epochs (const Index new_maximum_epochs)
 
void set_maximum_validation_failures (const Index new_maximum_validation_failures)
 
void set_maximum_time (const float new_maximum_time)
 
void check () const
 Verifies that the training strategy and its dependencies are valid for neurons selection.
 
virtual NeuronsSelectionResults perform_neurons_selection ()=0
 Runs the neurons selection algorithm until a stopping criterion is met.
 
string get_name () const
 
virtual void from_JSON (const JsonDocument &)=0
 Loads algorithm configuration from a JSON document.
 
virtual void to_JSON (JsonWriter &) const =0
 Writes algorithm configuration to a JSON writer.
 
void save (const filesystem::path &) const
 Saves the algorithm configuration to disk.
 
void load (const filesystem::path &)
 Loads the algorithm configuration from disk.
 
virtual void print () const
 Prints a human-readable description of the algorithm to stdout.
 

Protected Attributes

TrainingStrategytraining_strategy = nullptr
 
VectorR validation_error_history
 
VectorR training_error_history
 
Index minimum_neurons = 0
 
Index maximum_neurons = 0
 
Index trials_number = 1
 
float validation_error_goal = 0
 
Index maximum_epochs = 10
 
Index maximum_validation_failures = 100
 
float maximum_time = 0
 
bool display = true
 
string name
 

Detailed Description

Abstract base class for algorithms that select the optimal number of hidden neurons.

Member Enumeration Documentation

◆ StoppingCondition

Reasons the neurons selection loop may terminate.

Enumerator
MaximumTime 
SelectionErrorGoal 
MaximumEpochs 
MaximumSelectionFailures 
MaximumNeurons 

Constructor & Destructor Documentation

◆ NeuronSelection()

opennn::NeuronSelection::NeuronSelection ( TrainingStrategy * = nullptr)

Constructs the algorithm bound to an optional training strategy.

◆ ~NeuronSelection()

virtual opennn::NeuronSelection::~NeuronSelection ( )
virtualdefault

Member Function Documentation

◆ check()

void opennn::NeuronSelection::check ( ) const

Verifies that the training strategy and its dependencies are valid for neurons selection.

◆ from_JSON()

virtual void opennn::NeuronSelection::from_JSON ( const JsonDocument & )
pure virtual

Loads algorithm configuration from a JSON document.

Implemented in opennn::GrowingNeurons.

◆ get_display()

bool opennn::NeuronSelection::get_display ( ) const
inline

◆ get_name()

string opennn::NeuronSelection::get_name ( ) const
inline

◆ get_training_strategy()

const TrainingStrategy * opennn::NeuronSelection::get_training_strategy ( ) const
inline

◆ has_training_strategy()

bool opennn::NeuronSelection::has_training_strategy ( ) const
inline

◆ load()

void opennn::NeuronSelection::load ( const filesystem::path & )

Loads the algorithm configuration from disk.

◆ perform_neurons_selection()

virtual NeuronsSelectionResults opennn::NeuronSelection::perform_neurons_selection ( )
pure virtual

Runs the neurons selection algorithm until a stopping criterion is met.

Returns
Results including the optimal neuron count, optimal parameters and error histories.

Implemented in opennn::GrowingNeurons.

◆ print()

virtual void opennn::NeuronSelection::print ( ) const
inlinevirtual

Prints a human-readable description of the algorithm to stdout.

◆ save()

void opennn::NeuronSelection::save ( const filesystem::path & ) const

Saves the algorithm configuration to disk.

◆ set()

void opennn::NeuronSelection::set ( TrainingStrategy * )

Binds the algorithm to the given training strategy.

◆ set_default()

void opennn::NeuronSelection::set_default ( )

Restores default search bounds and stopping criteria.

◆ set_display()

void opennn::NeuronSelection::set_display ( bool new_display)
inline

◆ set_maximum_epochs()

void opennn::NeuronSelection::set_maximum_epochs ( const Index new_maximum_epochs)
inline

◆ set_maximum_neurons()

void opennn::NeuronSelection::set_maximum_neurons ( const Index new_maximum_neurons)
inline

◆ set_maximum_time()

void opennn::NeuronSelection::set_maximum_time ( const float new_maximum_time)
inline

◆ set_maximum_validation_failures()

void opennn::NeuronSelection::set_maximum_validation_failures ( const Index new_maximum_validation_failures)
inline

◆ set_minimum_neurons()

void opennn::NeuronSelection::set_minimum_neurons ( const Index new_minimum_neurons)
inline

◆ set_training_strategy()

void opennn::NeuronSelection::set_training_strategy ( TrainingStrategy * new_training_strategy)
inline

◆ set_trials_number()

void opennn::NeuronSelection::set_trials_number ( const Index new_trials_number)
inline

◆ set_validation_error_goal()

void opennn::NeuronSelection::set_validation_error_goal ( const float new_validation_error_goal)
inline

◆ to_JSON()

virtual void opennn::NeuronSelection::to_JSON ( JsonWriter & ) const
pure virtual

Writes algorithm configuration to a JSON writer.

Implemented in opennn::GrowingNeurons.

Member Data Documentation

◆ display

bool opennn::NeuronSelection::display = true
protected

◆ maximum_epochs

Index opennn::NeuronSelection::maximum_epochs = 10
protected

◆ maximum_neurons

Index opennn::NeuronSelection::maximum_neurons = 0
protected

◆ maximum_time

float opennn::NeuronSelection::maximum_time = 0
protected

◆ maximum_validation_failures

Index opennn::NeuronSelection::maximum_validation_failures = 100
protected

◆ minimum_neurons

Index opennn::NeuronSelection::minimum_neurons = 0
protected

◆ name

string opennn::NeuronSelection::name
protected

◆ training_error_history

VectorR opennn::NeuronSelection::training_error_history
protected

◆ training_strategy

TrainingStrategy* opennn::NeuronSelection::training_strategy = nullptr
protected

◆ trials_number

Index opennn::NeuronSelection::trials_number = 1
protected

◆ validation_error_goal

float opennn::NeuronSelection::validation_error_goal = 0
protected

◆ validation_error_history

VectorR opennn::NeuronSelection::validation_error_history
protected