NeuralNetwork Class Reference

This class represents the concept of neural network in the OpenNN library. More...

#include <neural_network.h>

Public Types

enum class  ProjectType {
  Approximation , Classification , Forecasting , ImageApproximation ,
  ImageClassification
}
 

Public Member Functions

 NeuralNetwork ()
 
 NeuralNetwork (const NeuralNetwork::ProjectType &, const Tensor< Index, 1 > &)
 
 NeuralNetwork (const NeuralNetwork::ProjectType &, const initializer_list< Index > &)
 
 NeuralNetwork (const Tensor< Index, 1 > &, const Index &, const Tensor< Index, 1 > &, const Index &)
 
 NeuralNetwork (const string &)
 
 NeuralNetwork (const tinyxml2::XMLDocument &)
 
 NeuralNetwork (const Tensor< Layer *, 1 > &)
 
virtual ~NeuralNetwork ()
 Destructor. More...
 
void delete_layers ()
 
void add_layer (Layer *)
 
bool check_layer_type (const Layer::Type)
 
bool has_scaling_layer () const
 
bool has_long_short_term_memory_layer () const
 
bool has_recurrent_layer () const
 
bool has_unscaling_layer () const
 
bool has_bounding_layer () const
 
bool has_probabilistic_layer () const
 
bool has_convolutional_layer () const
 
bool is_empty () const
 
const Tensor< string, 1 > & get_inputs_names () const
 Returns a string vector with the names of the variables used as inputs. More...
 
string get_input_name (const Index &) const
 
Index get_input_index (const string &) const
 
const Tensor< string, 1 > & get_outputs_names () const
 Returns a string vector with the names of the variables used as outputs. More...
 
string get_output_name (const Index &) const
 
Index get_output_index (const string &) const
 
Tensor< Layer *, 1 > get_layers_pointers () const
 Returns a pointer to the layers object composing this neural network object. More...
 
Layerget_layer_pointer (const Index &) const
 
Tensor< Layer *, 1 > get_trainable_layers_pointers () const
 Returns a pointer to the trainable layers object composing this neural network object. More...
 
Tensor< Index, 1 > get_trainable_layers_indices () const
 Returns a vector with the indices of the trainable layers. More...
 
ScalingLayerget_scaling_layer_pointer () const
 Returns a pointer to the scaling layers object composing this neural network object. More...
 
UnscalingLayerget_unscaling_layer_pointer () const
 Returns a pointer to the unscaling layers object composing this neural network object. More...
 
BoundingLayerget_bounding_layer_pointer () const
 Returns a pointer to the bounding layers object composing this neural network object. More...
 
ProbabilisticLayerget_probabilistic_layer_pointer () const
 Returns a pointer to the first probabilistic layer composing this neural network. More...
 
LongShortTermMemoryLayerget_long_short_term_memory_layer_pointer () const
 Returns a pointer to the long short term memory layer of this neural network, if exits. More...
 
RecurrentLayerget_recurrent_layer_pointer () const
 Returns a pointer to the recurrent layer of this neural network, if exits. More...
 
Layerget_last_trainable_layer_pointer () const
 
PerceptronLayerget_first_perceptron_layer_pointer () const
 
const bool & get_display () const
 
void set ()
 
void set (const NeuralNetwork::ProjectType &, const Tensor< Index, 1 > &)
 
void set (const NeuralNetwork::ProjectType &, const initializer_list< Index > &)
 
void set (const Tensor< Index, 1 > &, const Index &, const Tensor< Index, 1 > &, const Index &)
 
void set (const string &)
 
void set_layers_pointers (Tensor< Layer *, 1 > &)
 
void set_inputs_names (const Tensor< string, 1 > &)
 
void set_outputs_names (const Tensor< string, 1 > &)
 
void set_inputs_number (const Index &)
 
void set_inputs_number (const Tensor< bool, 1 > &)
 
virtual void set_default ()
 Sets those members which are not pointer to their default values. More...
 
void set_threads_number (const int &)
 
void set_scaling_layer (ScalingLayer &)
 
void set_display (const bool &)
 
Index get_layers_number () const
 
Tensor< Index, 1 > get_layers_neurons_numbers () const
 
Index get_trainable_layers_number () const
 
Index get_perceptron_layers_number () const
 
Index get_probabilistic_layers_number () const
 
Index get_long_short_term_memory_layers_number () const
 
Index get_recurrent_layers_number () const
 
Index get_inputs_number () const
 Returns the number of inputs to the neural network. More...
 
Index get_outputs_number () const
 
Tensor< Index, 1 > get_trainable_layers_neurons_numbers () const
 
Tensor< Index, 1 > get_trainable_layers_inputs_numbers () const
 
Tensor< Index, 1 > get_trainable_layers_synaptic_weight_numbers () const
 
Tensor< Index, 1 > get_architecture () const
 
Index get_parameters_number () const
 
Tensor< type, 1 > get_parameters () const
 
Tensor< Index, 1 > get_trainable_layers_parameters_numbers () const
 
Tensor< Tensor< type, 1 >, 1 > get_trainable_layers_parameters (const Tensor< type, 1 > &) const
 
void set_parameters (Tensor< type, 1 > &)
 
void set_parameters_constant (const type &)
 Initializes all the neural and the independent parameters with a given value. More...
 
void set_parameters_random ()
 
type calculate_parameters_norm () const
 Returns the norm of the vector of parameters. More...
 
void perturbate_parameters (const type &)
 
Tensor< type, 2 > calculate_outputs (const Tensor< type, 2 > &)
 
Tensor< type, 2 > calculate_outputs (const Tensor< type, 4 > &)
 
Tensor< type, 2 > calculate_directional_inputs (const Index &, const Tensor< type, 1 > &, const type &, const type &, const Index &=101) const
 
Tensor< string, 2 > get_information () const
 
Tensor< string, 2 > get_perceptron_layers_information () const
 For each perceptron layer: inputs, neurons, activation function. More...
 
Tensor< string, 2 > get_probabilistic_layer_information () const
 For each probabilistic layer: inputs, neurons, activation function. More...
 
virtual void from_XML (const tinyxml2::XMLDocument &)
 
void inputs_from_XML (const tinyxml2::XMLDocument &)
 
void layers_from_XML (const tinyxml2::XMLDocument &)
 
void outputs_from_XML (const tinyxml2::XMLDocument &)
 
virtual void write_XML (tinyxml2::XMLPrinter &) const
 
void print () const
 Prints to the screen the most important information about the neural network object. More...
 
void save (const string &) const
 
void save_parameters (const string &) const
 
virtual void load (const string &)
 
void load_parameters_binary (const string &)
 
Tensor< string, 1 > get_layers_names () const
 
string write_expression () const
 
string write_expression_python () const
 Returns a string with the python function of the expression represented by the neural network. More...
 
string write_expression_c () const
 Returns a string with the c function of the expression represented by the neural network. More...
 
void save_expression_c (const string &)
 
void save_expression_python (const string &)
 
void save_outputs (const Tensor< type, 2 > &, const string &)
 
void forward_propagate (const DataSetBatch &, NeuralNetworkForwardPropagation &) const
 Calculate forward propagation in neural network. More...
 
void forward_propagate (const DataSetBatch &, Tensor< type, 1 > &, NeuralNetworkForwardPropagation &) const
 

Protected Attributes

string name = "neural_network"
 
Tensor< string, 1 > inputs_names
 Names of inputs. More...
 
Tensor< string, 1 > outputs_names
 Names of ouputs. More...
 
Tensor< Layer *, 1 > layers_pointers
 Layers. More...
 
bool display = true
 Display messages to screen. More...
 

Detailed Description

This class represents the concept of neural network in the OpenNN library.

This neural network is used to span a function space for the problem at hand.

Definition at line 46 of file neural_network.h.

Member Enumeration Documentation

◆ ProjectType

enum class ProjectType
strong

Definition at line 51 of file neural_network.h.

Constructor & Destructor Documentation

◆ NeuralNetwork() [1/7]

NeuralNetwork ( )
explicit

Default constructor. It creates an empty neural network object. All pointers in the object are initialized to nullptr. The rest of members are initialized to their default values.

Definition at line 19 of file neural_network.cpp.

◆ NeuralNetwork() [2/7]

NeuralNetwork ( const NeuralNetwork::ProjectType &  model_type,
const Tensor< Index, 1 > &  architecture 
)
explicit

Type of model and architecture of the Neural Network constructor. It creates a neural network object with the given model type and architecture. The rest of members are initialized to their default values.

Parameters
model_typeType of problem to be solved with the neural network (Approximation, Classification, Forecasting, ImageApproximation, ImageClassification).
architectureArchitecture of the neural network({inputs_number, hidden_neurons_number, outputs_number}).

Definition at line 32 of file neural_network.cpp.

◆ NeuralNetwork() [3/7]

NeuralNetwork ( const NeuralNetwork::ProjectType &  model_type,
const initializer_list< Index > &  architecture_list 
)
explicit

Definition at line 38 of file neural_network.cpp.

◆ NeuralNetwork() [4/7]

NeuralNetwork ( const Tensor< Index, 1 > &  new_inputs_dimensions,
const Index &  new_blocks_number,
const Tensor< Index, 1 > &  new_filters_dimensions,
const Index &  new_outputs_number 
)
explicit

(Convolutional layer) constructor. It creates a neural network object with the given parameters. Note that this method is only valid when our problem presents convolutional layers.

Definition at line 51 of file neural_network.cpp.

◆ NeuralNetwork() [5/7]

NeuralNetwork ( const string &  file_name)
explicit

File constructor. It creates a neural network object by loading its members from an XML-type file. Please be careful with the format of that file, which is specified in the OpenNN manual.

Parameters
file_nameName of neural network file.

Definition at line 65 of file neural_network.cpp.

◆ NeuralNetwork() [6/7]

NeuralNetwork ( const tinyxml2::XMLDocument document)
explicit

XML constructor. It creates a neural network object by loading its members from an XML document.

Parameters
documentTinyXML document containing the neural network data.

Definition at line 75 of file neural_network.cpp.

◆ NeuralNetwork() [7/7]

NeuralNetwork ( const Tensor< Layer *, 1 > &  new_layers_pointers)
explicit

Layers constructor. It creates a neural network object by It also sets the rest of members to their default values.

Definition at line 85 of file neural_network.cpp.

◆ ~NeuralNetwork()

~NeuralNetwork ( )
virtual

Destructor.

Definition at line 95 of file neural_network.cpp.

Member Function Documentation

◆ add_layer()

void add_layer ( Layer layer_pointer)

Add a new layer to the Neural Network model.

Parameters
layer_pointerThe layer that will be added.

Definition at line 119 of file neural_network.cpp.

◆ calculate_directional_inputs()

Tensor< type, 2 > calculate_directional_inputs ( const Index &  direction,
const Tensor< type, 1 > &  point,
const type &  minimum,
const type &  maximum,
const Index &  points_number = 101 
) const

Calculates the input data which is necessary to compute the output data from the neural network in some direction.

Parameters
directionInput index(must be between 0 and number of inputs - 1).
pointInput point through the directional input passes.
minimumMinimum value of the input with the above index.
maximumMaximum value of the input with the above index.
points_numberNumber of points in the directional input data set.

Definition at line 1643 of file neural_network.cpp.

◆ calculate_outputs() [1/2]

Tensor< type, 2 > calculate_outputs ( const Tensor< type, 2 > &  inputs)

Calculates the outputs vector from the neural network in response to an inputs vector. The activity for that is the following:

  • Check inputs range.
  • Calculate scaled inputs.
  • Calculate forward propagation.
  • Calculate unscaled outputs.
  • Apply boundary condtions.
  • Calculate bounded outputs.
Parameters
inputsSet of inputs to the neural network.

Definition at line 1538 of file neural_network.cpp.

◆ calculate_outputs() [2/2]

Tensor< type, 2 > calculate_outputs ( const Tensor< type, 4 > &  inputs)

Definition at line 1574 of file neural_network.cpp.

◆ calculate_parameters_norm()

type calculate_parameters_norm ( ) const

Returns the norm of the vector of parameters.

Definition at line 1332 of file neural_network.cpp.

◆ check_layer_type()

bool check_layer_type ( const Layer::Type  layer_type)

Check if a given layer type can be added to the structure of the neural network. LSTM and Recurrent layers can only be added at the beginning.

Parameters
layer_typeType of new layer to be added.

Definition at line 199 of file neural_network.cpp.

◆ delete_layers()

void delete_layers ( )

Definition at line 101 of file neural_network.cpp.

◆ forward_propagate() [1/2]

void forward_propagate ( const DataSetBatch batch,
NeuralNetworkForwardPropagation forward_propagation 
) const

Calculate forward propagation in neural network.

Calculates the forward propagation in the neural network.

Parameters
batchDataSetBatch of data set that contains the inputs and targets to be trained.
foward_propagationNeuralNetwork class structure that saves the necessary parameters of forward propagation.
Todo:
Todo:

Definition at line 1374 of file neural_network.cpp.

◆ forward_propagate() [2/2]

void forward_propagate ( const DataSetBatch batch,
Tensor< type, 1 > &  parameters,
NeuralNetworkForwardPropagation forward_propagation 
) const

Calculates the forward propagation in the neural network.

Parameters
batchDataSetBatch of data set that contains the inputs and targets to be trained.
parametersParameters of neural network.
forward_propagationIs a NeuralNetwork class structure where save the neccesary paraneters of forward propagation.

Definition at line 1442 of file neural_network.cpp.

◆ from_XML()

void from_XML ( const tinyxml2::XMLDocument document)
virtual

Deserializes a TinyXML document into this neural network object.

Parameters
documentXML document containing the member data.

Definition at line 1890 of file neural_network.cpp.

◆ get_architecture()

Tensor< Index, 1 > get_architecture ( ) const

Returns a vector with the architecture of the neural network. The elements of this vector are as follows;

  • Number of scaling neurons(if there is a scaling layer).
  • Multilayer perceptron architecture(if there is a neural network).
  • Number of conditions neurons(if there is a conditions layer).
  • Number of unscaling neurons(if there is an unscaling layer).
  • Number of probabilistic neurons(if there is a probabilistic layer).
  • Number of bounding neurons(if there is a bounding layer).

Definition at line 1020 of file neural_network.cpp.

◆ get_bounding_layer_pointer()

BoundingLayer * get_bounding_layer_pointer ( ) const

Returns a pointer to the bounding layers object composing this neural network object.

Definition at line 521 of file neural_network.cpp.

◆ get_display()

const bool & get_display ( ) const

Returns true if messages from this class are to be displayed on the screen, or false if messages from this class are not to be displayed on the screen.

Definition at line 617 of file neural_network.cpp.

◆ get_first_perceptron_layer_pointer()

PerceptronLayer * get_first_perceptron_layer_pointer ( ) const

Definition at line 894 of file neural_network.cpp.

◆ get_information()

Tensor< string, 2 > get_information ( ) const

For each layer: inputs, neurons, activation function.

Todo:
Complete for rest of layers.

Definition at line 1674 of file neural_network.cpp.

◆ get_input_index()

Index get_input_index ( const string &  name) const

Returns the index of the variable with a given name.

Parameters
nameName of the variable to be examined.

Definition at line 361 of file neural_network.cpp.

◆ get_input_name()

string get_input_name ( const Index &  index) const

Returns a string with the name of the variable used as inputs on a certain index.

Parameters
indexIndex of the variable to be examined.

Definition at line 352 of file neural_network.cpp.

◆ get_inputs_names()

const Tensor< string, 1 > & get_inputs_names ( ) const

Returns a string vector with the names of the variables used as inputs.

Definition at line 343 of file neural_network.cpp.

◆ get_inputs_number()

Index get_inputs_number ( ) const

Returns the number of inputs to the neural network.

Definition at line 912 of file neural_network.cpp.

◆ get_last_trainable_layer_pointer()

Layer * get_last_trainable_layer_pointer ( ) const

Definition at line 2881 of file neural_network.cpp.

◆ get_layer_pointer()

Layer * get_layer_pointer ( const Index &  layer_index) const

Definition at line 411 of file neural_network.cpp.

◆ get_layers_names()

Tensor< string, 1 > get_layers_names ( ) const

Definition at line 2866 of file neural_network.cpp.

◆ get_layers_neurons_numbers()

Tensor< Index, 1 > get_layers_neurons_numbers ( ) const

Definition at line 1194 of file neural_network.cpp.

◆ get_layers_number()

Index get_layers_number ( ) const

Returns the number of layers in the neural network. That includes perceptron, scaling, unscaling, inputs trending, outputs trending, bounding, probabilistic or conditions layers.

Definition at line 1188 of file neural_network.cpp.

◆ get_layers_pointers()

Tensor< Layer *, 1 > get_layers_pointers ( ) const

Returns a pointer to the layers object composing this neural network object.

Definition at line 405 of file neural_network.cpp.

◆ get_long_short_term_memory_layer_pointer()

LongShortTermMemoryLayer * get_long_short_term_memory_layer_pointer ( ) const

Returns a pointer to the long short term memory layer of this neural network, if exits.

Definition at line 568 of file neural_network.cpp.

◆ get_long_short_term_memory_layers_number()

Index get_long_short_term_memory_layers_number ( ) const

Definition at line 1263 of file neural_network.cpp.

◆ get_output_index()

Index get_output_index ( const string &  name) const

Returns the index of the variable with a given name.

Parameters
nameName of the variable to be examined.

Definition at line 392 of file neural_network.cpp.

◆ get_output_name()

string get_output_name ( const Index &  index) const

Returns a string with the name of the variable used as outputs on a certain index.

Parameters
indexIndex of the variable to be examined.

Definition at line 383 of file neural_network.cpp.

◆ get_outputs_names()

const Tensor< string, 1 > & get_outputs_names ( ) const

Returns a string vector with the names of the variables used as outputs.

Definition at line 374 of file neural_network.cpp.

◆ get_outputs_number()

Index get_outputs_number ( ) const

Definition at line 923 of file neural_network.cpp.

◆ get_parameters()

Tensor< type, 1 > get_parameters ( ) const

Returns the values of the parameters in the neural network as a single vector. This contains all the neural network parameters(biases and synaptic weights) and preprocessed independent parameters.

Definition at line 1063 of file neural_network.cpp.

◆ get_parameters_number()

Index get_parameters_number ( ) const

Returns the number of parameters in the neural network The number of parameters is the sum of all the neural network parameters(biases and synaptic weights) and independent parameters.

Definition at line 1045 of file neural_network.cpp.

◆ get_perceptron_layers_information()

Tensor< string, 2 > get_perceptron_layers_information ( ) const

For each perceptron layer: inputs, neurons, activation function.

Definition at line 1707 of file neural_network.cpp.

◆ get_perceptron_layers_number()

Index get_perceptron_layers_number ( ) const

Definition at line 1227 of file neural_network.cpp.

◆ get_probabilistic_layer_information()

Tensor< string, 2 > get_probabilistic_layer_information ( ) const

For each probabilistic layer: inputs, neurons, activation function.

Definition at line 1742 of file neural_network.cpp.

◆ get_probabilistic_layer_pointer()

ProbabilisticLayer * get_probabilistic_layer_pointer ( ) const

Returns a pointer to the first probabilistic layer composing this neural network.

Definition at line 545 of file neural_network.cpp.

◆ get_probabilistic_layers_number()

Index get_probabilistic_layers_number ( ) const

Definition at line 1245 of file neural_network.cpp.

◆ get_recurrent_layer_pointer()

RecurrentLayer * get_recurrent_layer_pointer ( ) const

Returns a pointer to the recurrent layer of this neural network, if exits.

Definition at line 592 of file neural_network.cpp.

◆ get_recurrent_layers_number()

Index get_recurrent_layers_number ( ) const

Definition at line 1280 of file neural_network.cpp.

◆ get_scaling_layer_pointer()

ScalingLayer * get_scaling_layer_pointer ( ) const

Returns a pointer to the scaling layers object composing this neural network object.

Definition at line 473 of file neural_network.cpp.

◆ get_trainable_layers_indices()

Tensor< Index, 1 > get_trainable_layers_indices ( ) const

Returns a vector with the indices of the trainable layers.

Definition at line 446 of file neural_network.cpp.

◆ get_trainable_layers_inputs_numbers()

Tensor< Index, 1 > get_trainable_layers_inputs_numbers ( ) const

Definition at line 961 of file neural_network.cpp.

◆ get_trainable_layers_neurons_numbers()

Tensor< Index, 1 > get_trainable_layers_neurons_numbers ( ) const

Definition at line 936 of file neural_network.cpp.

◆ get_trainable_layers_number()

Index get_trainable_layers_number ( ) const

Definition at line 1207 of file neural_network.cpp.

◆ get_trainable_layers_parameters()

Tensor< Tensor< type, 1 >, 1 > get_trainable_layers_parameters ( const Tensor< type, 1 > &  parameters) const

Definition at line 1108 of file neural_network.cpp.

◆ get_trainable_layers_parameters_numbers()

Tensor< Index, 1 > get_trainable_layers_parameters_numbers ( ) const

Definition at line 1091 of file neural_network.cpp.

◆ get_trainable_layers_pointers()

Tensor< Layer *, 1 > get_trainable_layers_pointers ( ) const

Returns a pointer to the trainable layers object composing this neural network object.

Definition at line 419 of file neural_network.cpp.

◆ get_trainable_layers_synaptic_weight_numbers()

Tensor< Index, 1 > get_trainable_layers_synaptic_weight_numbers ( ) const

Definition at line 985 of file neural_network.cpp.

◆ get_unscaling_layer_pointer()

UnscalingLayer * get_unscaling_layer_pointer ( ) const

Returns a pointer to the unscaling layers object composing this neural network object.

Definition at line 497 of file neural_network.cpp.

◆ has_bounding_layer()

bool has_bounding_layer ( ) const

Returns true if the neural network object has a bounding layer object inside, and false otherwise.

Definition at line 301 of file neural_network.cpp.

◆ has_convolutional_layer()

bool has_convolutional_layer ( ) const

Returns true if the neural network object has a convolutional object inside, and false otherwise.

Definition at line 253 of file neural_network.cpp.

◆ has_long_short_term_memory_layer()

bool has_long_short_term_memory_layer ( ) const

Returns true if the neural network object has a long short term memory layer object inside, and false otherwise.

Definition at line 237 of file neural_network.cpp.

◆ has_probabilistic_layer()

bool has_probabilistic_layer ( ) const

Returns true if the neural network object has a probabilistic layer object inside, and false otherwise.

Definition at line 317 of file neural_network.cpp.

◆ has_recurrent_layer()

bool has_recurrent_layer ( ) const

Returns true if the neural network object has a recurrent layer object inside, and false otherwise.

Definition at line 269 of file neural_network.cpp.

◆ has_scaling_layer()

bool has_scaling_layer ( ) const

Returns true if the neural network object has a scaling layer object inside, and false otherwise.

Definition at line 221 of file neural_network.cpp.

◆ has_unscaling_layer()

bool has_unscaling_layer ( ) const

Returns true if the neural network object has an unscaling layer object inside, and false otherwise.

Definition at line 285 of file neural_network.cpp.

◆ inputs_from_XML()

void inputs_from_XML ( const tinyxml2::XMLDocument document)

Definition at line 1979 of file neural_network.cpp.

◆ is_empty()

bool is_empty ( ) const

Returns true if the neural network object is empty, and false otherwise.

Definition at line 333 of file neural_network.cpp.

◆ layers_from_XML()

void layers_from_XML ( const tinyxml2::XMLDocument document)

Definition at line 2049 of file neural_network.cpp.

◆ load()

void load ( const string &  file_name)
virtual

Loads from a XML file the members for this neural network object. Please mind about the file format, which is specified in the User's Guide.

Parameters
file_nameName of neural network XML file.

Definition at line 2422 of file neural_network.cpp.

◆ load_parameters_binary()

void load_parameters_binary ( const string &  file_name)

Loads the neural network parameters from a data file. The format of this file is just a sequence of numbers.

Parameters
file_nameName of parameters data file.

Definition at line 2448 of file neural_network.cpp.

◆ outputs_from_XML()

void outputs_from_XML ( const tinyxml2::XMLDocument document)

Definition at line 2287 of file neural_network.cpp.

◆ perturbate_parameters()

void perturbate_parameters ( const type &  perturbation)

Perturbate parameters of the neural network.

Parameters
perturbationMaximum distance of perturbation.

Definition at line 1345 of file neural_network.cpp.

◆ print()

void print ( ) const

Prints to the screen the most important information about the neural network object.

Definition at line 2359 of file neural_network.cpp.

◆ save()

void save ( const string &  file_name) const

Saves to a XML file the members of a neural network object.

Parameters
file_nameName of neural network XML file.

Definition at line 2378 of file neural_network.cpp.

◆ save_expression_c()

void save_expression_c ( const string &  file_name)

Saves the mathematical expression represented by the neural network to a text file.

Parameters
file_nameName of expression text file.

Definition at line 2770 of file neural_network.cpp.

◆ save_expression_python()

void save_expression_python ( const string &  file_name)

Saves the python function of the expression represented by the neural network to a text file.

Parameters
file_nameName of expression text file.

Definition at line 2794 of file neural_network.cpp.

◆ save_outputs()

void save_outputs ( const Tensor< type, 2 > &  inputs,
const string &  file_name 
)

Saves a csv file containing the outputs for a set of given inputs.

Parameters
inputsInputs to calculate the outputs.
file_nameName of data file

Definition at line 2819 of file neural_network.cpp.

◆ save_parameters()

void save_parameters ( const string &  file_name) const

Saves to a data file the parameters of a neural network object.

Parameters
file_nameName of parameters data file.

Definition at line 2393 of file neural_network.cpp.

◆ set() [1/5]

void set ( )

This method deletes all the pointers in the neural network. It also sets the rest of members to their default values.

Definition at line 626 of file neural_network.cpp.

◆ set() [2/5]

void set ( const NeuralNetwork::ProjectType &  model_type,
const initializer_list< Index > &  architecture_list 
)

Definition at line 728 of file neural_network.cpp.

◆ set() [3/5]

void set ( const NeuralNetwork::ProjectType &  model_type,
const Tensor< Index, 1 > &  architecture 
)

Sets a new neural network with a given neural network architecture. It also sets the rest of members to their default values.

Parameters
model_typeType of model.
architectureArchitecture of the neural network.

Definition at line 643 of file neural_network.cpp.

◆ set() [4/5]

void set ( const string &  file_name)

Sets the neural network members by loading them from a XML file.

Parameters
file_nameNeural network XML file_name.

Definition at line 786 of file neural_network.cpp.

◆ set() [5/5]

void set ( const Tensor< Index, 1 > &  input_variables_dimensions,
const Index &  blocks_number,
const Tensor< Index, 1 > &  filters_dimensions,
const Index &  outputs_number 
)

Sets a new neural network with a given convolutional neural network architecture (CNN). It also sets the rest of members to their default values.

Parameters
input_variables_dimensionsDefine the dimensions of the input varibales.
blocks_numberNumber of blocks.
filters_dimensionsArchitecture of the neural network.
outputs_numberArchitecture of the neural network.

Definition at line 744 of file neural_network.cpp.

◆ set_default()

void set_default ( )
virtual

Sets those members which are not pointer to their default values.

Definition at line 871 of file neural_network.cpp.

◆ set_display()

void set_display ( const bool &  new_display)

Sets a new display value. If it is set to true messages from this class are to be displayed on the screen; if it is set to false messages from this class are not to be displayed on the screen.

Parameters
new_displayDisplay value.

Definition at line 1179 of file neural_network.cpp.

◆ set_inputs_names()

void set_inputs_names ( const Tensor< string, 1 > &  new_inputs_names)

Sets the names of inputs in neural network

Parameters
new_inputs_namesTensor with the new names of inputs.

Definition at line 797 of file neural_network.cpp.

◆ set_inputs_number() [1/2]

void set_inputs_number ( const Index &  new_inputs_number)

Sets the new inputs number of this neural network object.

Parameters
new_inputs_numberNumber of inputs.

Definition at line 815 of file neural_network.cpp.

◆ set_inputs_number() [2/2]

void set_inputs_number ( const Tensor< bool, 1 > &  inputs)

Sets the new inputs number of this neural network object.

Parameters
inputsBoolean vector containing the number of inputs.

Definition at line 854 of file neural_network.cpp.

◆ set_layers_pointers()

void set_layers_pointers ( Tensor< Layer *, 1 > &  new_layers_pointers)

Definition at line 888 of file neural_network.cpp.

◆ set_outputs_names()

void set_outputs_names ( const Tensor< string, 1 > &  new_outputs_names)

Sets the names of outputs in neural network.

Parameters
new_outputs_namesTensor with the new names of outputs.

Definition at line 806 of file neural_network.cpp.

◆ set_parameters()

void set_parameters ( Tensor< type, 1 > &  new_parameters)

Sets all the parameters(neural_network_pointer parameters and independent parameters) from a single vector.

Parameters
new_parametersNew set of parameter values.

Definition at line 1136 of file neural_network.cpp.

◆ set_parameters_constant()

void set_parameters_constant ( const type &  value)

Initializes all the neural and the independent parameters with a given value.

Definition at line 1299 of file neural_network.cpp.

◆ set_parameters_random()

void set_parameters_random ( )

Initializes all the parameters in the newtork(biases and synaptic weiths + independent parameters) at random with values comprised between a given minimum and a given maximum values.

Parameters
minimumMinimum initialization value.
maximumMaximum initialization value.

Definition at line 1317 of file neural_network.cpp.

◆ set_threads_number()

void set_threads_number ( const int &  new_threads_number)

Definition at line 877 of file neural_network.cpp.

◆ write_expression()

string write_expression ( ) const

Definition at line 2584 of file neural_network.cpp.

◆ write_expression_c()

string write_expression_c ( ) const

Returns a string with the c function of the expression represented by the neural network.

Definition at line 2486 of file neural_network.cpp.

◆ write_expression_python()

string write_expression_python ( ) const

Returns a string with the python function of the expression represented by the neural network.

Definition at line 2637 of file neural_network.cpp.

◆ write_XML()

void write_XML ( tinyxml2::XMLPrinter file_stream) const
virtual

Serializes the neural network object into a XML document of the TinyXML library without keep the DOM tree in memory. See the OpenNN manual for more information about the format of this document.

Definition at line 1778 of file neural_network.cpp.

Member Data Documentation

◆ display

bool display = true
protected

Display messages to screen.

Definition at line 253 of file neural_network.h.

◆ inputs_names

Tensor<string, 1> inputs_names
protected

Names of inputs.

Definition at line 241 of file neural_network.h.

◆ layers_pointers

Tensor<Layer*, 1> layers_pointers
protected

Layers.

Definition at line 249 of file neural_network.h.

◆ name

string name = "neural_network"
protected

Definition at line 237 of file neural_network.h.

◆ outputs_names

Tensor<string, 1> outputs_names
protected

Names of ouputs.

Definition at line 245 of file neural_network.h.


The documentation for this class was generated from the following files: