OpenNN  2.2
Open Neural Networks Library
Public Member Functions | Protected Attributes | List of all members
OpenNN::MultilayerPerceptron Class Reference

#include <multilayer_perceptron.h>

Public Member Functions

 MultilayerPerceptron (void)
 
 MultilayerPerceptron (const Vector< PerceptronLayer > &)
 
 MultilayerPerceptron (const Vector< size_t > &)
 
 MultilayerPerceptron (const size_t &, const size_t &)
 
 MultilayerPerceptron (const size_t &, const size_t &, const size_t &)
 
 MultilayerPerceptron (const MultilayerPerceptron &)
 
virtual ~MultilayerPerceptron (void)
 
MultilayerPerceptronoperator= (const MultilayerPerceptron &)
 
bool operator== (const MultilayerPerceptron &) const
 
Vector< size_t > arrange_architecture (void) const
 
Vector< size_t > arrange_complexity (void) const
 
size_t get_inputs_number (void) const
 
size_t get_layers_number (void) const
 
Vector< size_t > get_layers_inputs_number (void) const
 
Vector< size_t > arrange_layers_perceptrons_numbers (void) const
 
size_t get_outputs_number (void) const
 
const Vector< PerceptronLayer > & get_layers (void) const
 
const PerceptronLayerget_layer (const size_t &) const
 
PerceptronLayerget_layer_pointer (const size_t &)
 
size_t count_perceptrons_number (void) const
 
Vector< size_t > count_cumulative_perceptrons_number (void) const
 
Vector< size_t > arrange_layers_parameters_number (void) const
 
Vector< size_t > arrange_layers_cumulative_parameters_number (void) const
 
Vector< Vector< double > > arrange_layers_biases (void) const
 
Vector< Matrix< double > > arrange_layers_synaptic_weights (void) const
 
Vector< Vector< double > > get_layers_parameters (void) const
 
size_t count_parameters_number (void) const
 
Vector< double > arrange_parameters (void) const
 
Vector< size_t > count_layers_parameters_numbers (void) const
 
size_t get_layer_index (const size_t &) const
 
size_t get_perceptron_index (const size_t &, const size_t &) const
 
size_t get_layer_bias_index (const size_t &, const size_t &) const
 
size_t get_layer_synaptic_weight_index (const size_t &, const size_t &, const size_t &) const
 
Vector< size_t > arrange_parameter_indices (const size_t &) const
 
Matrix< size_t > arrange_parameters_indices (void) const
 
Vector< Perceptron::ActivationFunctionget_layers_activation_function (void) const
 
Vector< std::string > write_layers_activation_function (void) const
 
const bool & get_display (void) const
 
void set (void)
 
void set (const Vector< PerceptronLayer > &)
 
void set (const Vector< size_t > &)
 
void set (const size_t &, const size_t &)
 
void set (const size_t &, const size_t &, const size_t &)
 
void set (const MultilayerPerceptron &)
 
virtual void set_default (void)
 
void set_inputs_number (const size_t &)
 
void set_layers_perceptrons_number (const Vector< size_t > &)
 
void set_layer_perceptrons_number (const size_t &, const size_t &)
 
void set_layers (const Vector< PerceptronLayer > &)
 
void set_layers_biases (const Vector< Vector< double > > &)
 
void set_layers_synaptic_weights (const Vector< Matrix< double > > &)
 
void set_layers_parameters (const Vector< Vector< double > > &)
 
void set_parameters (const Vector< double > &)
 
void initialize_biases (const double &)
 
void initialize_synaptic_weights (const double &)
 
void initialize_parameters (const double &)
 
void randomize_parameters_uniform (void)
 
void randomize_parameters_uniform (const double &, const double &)
 
void randomize_parameters_uniform (const Vector< double > &, const Vector< double > &)
 
void randomize_parameters_uniform (const Vector< Vector< double > > &)
 
void randomize_parameters_normal (void)
 
void randomize_parameters_normal (const double &, const double &)
 
void randomize_parameters_normal (const Vector< double > &, const Vector< double > &)
 
void randomize_parameters_normal (const Vector< Vector< double > > &)
 
void initialize_parameters (void)
 
void perturbate_parameters (const double &)
 
double calculate_parameters_norm (void) const
 
void set_layers_activation_function (const Vector< Perceptron::ActivationFunction > &)
 
void set_layers_activation_function (const Vector< std::string > &)
 
void set_layer_activation_function (const size_t &, const Perceptron::ActivationFunction &)
 
void set_display (const bool &)
 
bool is_empty (void) const
 
void grow_input (void)
 
void grow_layer (const size_t &, const size_t &)
 
void prune_input (const size_t &)
 
void prune_output (const size_t &)
 
void prune_layer (const size_t &, const size_t &)
 
void initialize_random (void)
 
Vector< double > calculate_layer_combination_combination (const size_t &, const Vector< double > &) const
 
Matrix< double > calculate_layer_combination_combination_Jacobian (const size_t &, const Vector< double > &) const
 
Vector< double > calculate_output_layer_combination (const size_t &, const Vector< double > &) const
 
Vector< Matrix< double > > calculate_output_layers_delta (const Vector< Vector< double > > &) const
 
Matrix< Vector< Matrix< double > > > calculate_output_interlayers_Delta (const Vector< Vector< Vector< double > > > &, const Matrix< Matrix< double > > &, const Vector< Matrix< double > > &) const
 
Vector< double > calculate_interlayer_combination_combination (const size_t &, const size_t &, const Vector< double > &) const
 
Matrix< double > calculate_interlayer_combination_combination_Jacobian (const size_t &, const size_t &, const Vector< double > &) const
 
Vector< Vector< double > > calculate_layers_input (const Vector< double > &) const
 
Vector< Vector< double > > arrange_layers_input (const Vector< double > &, const Vector< Vector< double > > &) const
 
Vector< Vector< double > > arrange_layers_input (const Vector< double > &, const Vector< Vector< Vector< double > > > &) const
 
Vector< Vector< double > > calculate_layers_combination (const Vector< double > &) const
 
Vector< Matrix< double > > calculate_layers_combination_Jacobian (const Vector< double > &) const
 
Vector< Matrix< double > > calculate_layers_combination_parameters_Jacobian (const Vector< Vector< double > > &) const
 
Vector< Vector< Vector< double > > > calculate_perceptrons_combination_parameters_gradient (const Vector< Vector< double > > &) const
 
Vector< Vector< double > > calculate_layers_activation (const Vector< double > &) const
 
Vector< Vector< double > > calculate_layers_activation_derivative (const Vector< double > &) const
 
Vector< Vector< double > > calculate_layers_activation_second_derivative (const Vector< double > &) const
 
Vector< Matrix< double > > calculate_layers_Jacobian (const Vector< double > &) const
 
Vector< Vector< Matrix< double > > > calculate_layers_Hessian_form (const Vector< double > &) const
 
Matrix< Matrix< double > > calculate_interlayers_combination_combination_Jacobian (const Vector< double > &) const
 
Matrix< Matrix< double > > calculate_interlayers_combination_combination_Jacobian (const Vector< Vector< double > > &) const
 
Vector< Vector< Vector< double > > > calculate_first_order_forward_propagation (const Vector< double > &) const
 
Vector< Vector< Vector< double > > > calculate_second_order_forward_propagation (const Vector< double > &) const
 
Vector< double > calculate_outputs (const Vector< double > &) const
 
Matrix< double > calculate_Jacobian (const Vector< double > &) const
 
Vector< Matrix< double > > calculate_Hessian_form (const Vector< double > &) const
 
Vector< double > calculate_outputs (const Vector< double > &, const Vector< double > &) const
 
Matrix< double > calculate_Jacobian (const Vector< double > &, const Vector< double > &) const
 
Vector< Matrix< double > > calculate_Hessian_form (const Vector< double > &, const Vector< double > &) const
 
tinyxml2::XMLDocument * to_XML (void) const
 
void from_XML (const tinyxml2::XMLDocument &)
 
Matrix< std::string > write_information (void) const
 
std::string write_expression (const Vector< std::string > &, const Vector< std::string > &) const
 
std::string to_string (void) const
 

Protected Attributes

Vector< PerceptronLayerlayers
 
bool display
 

Detailed Description

This class represents the concept of multilayer perceptron. A multilayer perceptron is a feed-forward network of layers of perceptrons. This is the most important class included in the definition of a neural network.

Definition at line 48 of file multilayer_perceptron.h.

Constructor & Destructor Documentation

OpenNN::MultilayerPerceptron::MultilayerPerceptron ( void  )
explicit

Default constructor. It creates a multilayer perceptron object witout any layer. This constructor also initializes the rest of class members to their default values.

Definition at line 27 of file multilayer_perceptron.cpp.

OpenNN::MultilayerPerceptron::MultilayerPerceptron ( const Vector< PerceptronLayer > &  new_layers)
explicit

Layers constructor. It creates a multilayer perceptron object with given layers of perceptrons. This constructor also initializes the rest of class members to their default values.

Definition at line 39 of file multilayer_perceptron.cpp.

OpenNN::MultilayerPerceptron::MultilayerPerceptron ( const Vector< size_t > &  new_architecture)
explicit

Architecture constructor. It creates a multilayer perceptron object with an arbitrary deep learning architecture. The architecture is represented by a vector of integers. The first element is the number of inputs. The rest of elements are the number of perceptrons in the subsequent layers. The multilayer perceptron parameters are initialized at random.

Parameters
new_architectureVector of integers representing the architecture of the multilayer perceptron.

Definition at line 55 of file multilayer_perceptron.cpp.

OpenNN::MultilayerPerceptron::MultilayerPerceptron ( const size_t &  new_inputs_number,
const size_t &  new_neurons_number 
)
explicit

One layer constructor. It creates a one-layer perceptron object. The multilayer perceptron parameters are initialized at random. This constructor also initializes the rest of class members to their default values:

Parameters
new_inputs_numberNumber of inputs in the layer.
new_neurons_numberNumber of neurons in the layer.

Definition at line 73 of file multilayer_perceptron.cpp.

OpenNN::MultilayerPerceptron::MultilayerPerceptron ( const size_t &  new_inputs_number,
const size_t &  new_hidden_neurons_number,
const size_t &  new_outputs_number 
)
explicit

Two layers constructor. It creates a multilayer perceptron object with a hidden layer of perceptrons and an outputs layer of perceptrons. The multilayer perceptron parameters are initialized at random. This constructor also initializes the rest of class members to their default values.

Parameters
new_inputs_numberNumber of inputs in the multilayer perceptron
new_hidden_neurons_numberNumber of neurons in the hidden layer of the multilayer perceptron
new_outputs_numberNumber of outputs neurons.

Definition at line 90 of file multilayer_perceptron.cpp.

OpenNN::MultilayerPerceptron::MultilayerPerceptron ( const MultilayerPerceptron other_multilayer_perceptron)

Copy constructor. It creates a copy of an existing multilayer perceptron object.

Parameters
other_multilayer_perceptronMultilayer perceptron object to be copied.

Definition at line 104 of file multilayer_perceptron.cpp.

OpenNN::MultilayerPerceptron::~MultilayerPerceptron ( void  )
virtual

Destructor. This destructor does not delete any pointer.

Definition at line 115 of file multilayer_perceptron.cpp.

Member Function Documentation

Vector<size_t> OpenNN::MultilayerPerceptron::arrange_architecture ( void  ) const
inline

Returns a vector with the architecture of the multilayer perceptron. The elements of this vector are as follows;

  • Number of inputs.
  • Size of the first hidden layer.
  • ...
  • Number of output perceptrons.

Definition at line 100 of file multilayer_perceptron.h.

Vector< Vector< double > > OpenNN::MultilayerPerceptron::arrange_layers_biases ( void  ) const

Returns the bias values from the neurons in all the layers. The format is a vector of vectors of real values. The size of this vector is the number of layers. The size of each subvector is the number of neurons in the corresponding layer.

Definition at line 324 of file multilayer_perceptron.cpp.

Vector< size_t > OpenNN::MultilayerPerceptron::arrange_layers_cumulative_parameters_number ( void  ) const

Returns a vector of integers with size the number of layers, where each element contains the total number of parameters in the corresponding and the previous layers.

Definition at line 300 of file multilayer_perceptron.cpp.

Vector< Vector< double > > OpenNN::MultilayerPerceptron::arrange_layers_input ( const Vector< double > &  inputs,
const Vector< Vector< double > > &  layers_activation 
) const

Returns the layers inputs from the multilayer perceptron inputs and the layers outputs. The format is a vector of subvectors. The size of the vector is the number of layers. The size of each subvector is the number of inputs to the corresponding layer.

Parameters
inputsInput values to the multilayer perceptron.
layers_activationOutput values from each layer.

Definition at line 2771 of file multilayer_perceptron.cpp.

Vector< Vector< double > > OpenNN::MultilayerPerceptron::arrange_layers_input ( const Vector< double > &  input,
const Vector< Vector< Vector< double > > > &  first_order_forward_propagation 
) const

Returns the layers inputs from the multilayer perceptron inputs and the layers outputs. The format is a vector of subvectors. The size of the vector is the number of layers. The size of each subvector is the number of inputs to the corresponding layer.

Parameters
inputInput values to the multilayer perceptron.
first_order_forward_propagationForward propagation quantities.

Definition at line 2835 of file multilayer_perceptron.cpp.

Vector< size_t > OpenNN::MultilayerPerceptron::arrange_layers_parameters_number ( void  ) const

Returns a vector of integers with size the number of layers, where each element contains the number of parameters in the corresponding layer.

Definition at line 280 of file multilayer_perceptron.cpp.

Vector< Matrix< double > > OpenNN::MultilayerPerceptron::arrange_layers_synaptic_weights ( void  ) const

Returns the synaptic weight values from the neurons in all the layers. The format is a vector of matrices of real values. The size of this vector is the number of layers. The number of rows of each sub_matrix is the number of neurons in the corresponding layer. The number of columns of each sub_matrix is the number of inputs to the corresponding layer.

Definition at line 347 of file multilayer_perceptron.cpp.

Vector< size_t > OpenNN::MultilayerPerceptron::arrange_parameter_indices ( const size_t &  parameter_index) const

Returns the layer, neuron and parameter indices of a neural parameter.

Parameters
parameter_indexIndex of parameter within the parameters vector.

Definition at line 662 of file multilayer_perceptron.cpp.

Matrix< size_t > OpenNN::MultilayerPerceptron::arrange_parameters_indices ( void  ) const

Returns a matrix with the indices of the multilayer perceptron parameters. That indices include the layer index, the neuron index and the parameter index. The number of rows is the number of multilayer perceptron parameters. The number of columns is 3.

Definition at line 694 of file multilayer_perceptron.cpp.

Vector< Vector< Vector< double > > > OpenNN::MultilayerPerceptron::calculate_first_order_forward_propagation ( const Vector< double > &  inputs) const

Returns the first order forward propagation quantities from the multilayer perceptron for a given inputs. That quantites include the activation and the activation derivative of all layers. The format is a vector of vectors of vectors. The first index refers to the quantity (0 for the activation and 1 for the activation derivative). The second index is the index of the layer. The third index is the index of the neuron.

Parameters
inputsVector of inputs to the multilayer perceptron

Definition at line 3388 of file multilayer_perceptron.cpp.

Vector< Matrix< double > > OpenNN::MultilayerPerceptron::calculate_Hessian_form ( const Vector< double > &  inputs) const

Returns the second partial derivatives of the outputs from the last layer with respect to the inputs to the first layer. That is, the Hessian matrix of the multilayer perceptron architectue inputs-outputs function.

Todo:

Definition at line 1981 of file multilayer_perceptron.cpp.

Vector< Matrix< double > > OpenNN::MultilayerPerceptron::calculate_Hessian_form ( const Vector< double > &  inputs,
const Vector< double > &   
) const

Returns the second partial derivatives of the outputs from the multilayer perceptron with respect to the multilayer perceptron parameters.

Todo:

Definition at line 2655 of file multilayer_perceptron.cpp.

Vector< double > OpenNN::MultilayerPerceptron::calculate_interlayer_combination_combination ( const size_t &  domain_layer_index,
const size_t &  image_layer_index,
const Vector< double > &  domain_layer_combination 
) const

Returns the combination vector of a layer (image) with respect to the combination vector of another layer (domain).

Parameters
domain_layer_indexIndex of domain layer.
image_layer_indexIndex of image layer.
domain_layer_combinationCombination vector of domain layer.

Definition at line 2185 of file multilayer_perceptron.cpp.

Matrix< double > OpenNN::MultilayerPerceptron::calculate_interlayer_combination_combination_Jacobian ( const size_t &  domain_layer_index,
const size_t &  image_layer_index,
const Vector< double > &  domain_layer_combination 
) const

Returns the partial derivatives of the combinations of a layer (image) with respect to the combinations of another layer (domain). This quantity is the Jacobian matrix of the interlayers combination combination function.

Parameters
image_layer_indexIndex of image layer.
domain_layer_indexIndex of domain layer.
domain_layer_combinationVector of combination values of the domain layer.

Definition at line 2224 of file multilayer_perceptron.cpp.

Matrix< Matrix< double > > OpenNN::MultilayerPerceptron::calculate_interlayers_combination_combination_Jacobian ( const Vector< double > &  inputs) const

Returns the partial derivatives of the combination of one neuron with respect to the combination of another neuron for all layers in the multilayer perceptron This quantity is a Jacobian form, and it is represented as a matrix of matrices.

Parameters
inputsVector of inputs to the multilayer perceptron

Definition at line 3300 of file multilayer_perceptron.cpp.

Matrix< Matrix< double > > OpenNN::MultilayerPerceptron::calculate_interlayers_combination_combination_Jacobian ( const Vector< Vector< double > > &  layers_combination) const

Returns the partial derivatives of the combination of one neuron with respect to the combination of another neuron for all layers in the multilayer perceptron This quantity is a Jacobian form, and it is represented as a matrix of matrices.

Parameters
layers_combinationVector vectors representing the combinations of all layers.

Definition at line 3333 of file multilayer_perceptron.cpp.

Matrix< double > OpenNN::MultilayerPerceptron::calculate_Jacobian ( const Vector< double > &  inputs) const

Returns the partial derivatives of the outputs from the last layer with respect to the inputs to the first layer. That is, it computes the inputs-outputs partial derivatives of the raw multilayer perceptron.

Parameters
inputsVector of inputs to the first layer of the multilayer perceptron architecture.

Definition at line 1930 of file multilayer_perceptron.cpp.

Matrix< double > OpenNN::MultilayerPerceptron::calculate_Jacobian ( const Vector< double > &  inputs,
const Vector< double > &   
) const

Calculates the parameters matrix of the multilayer perceptron for an inputs vector. The elements of that matrix are the partial derivatives of the outputs with respect to the multilayer perceptron parameters.

Definition at line 2602 of file multilayer_perceptron.cpp.

Vector< double > OpenNN::MultilayerPerceptron::calculate_layer_combination_combination ( const size_t &  layer_index,
const Vector< double > &  previous_layer_combination 
) const

Returns the combination vector of a given layer as a function of the combination vector of the previous layer.

Parameters
layer_indexIndex of layer.
previous_layer_combinationCombination vector of previous layer.

Definition at line 2060 of file multilayer_perceptron.cpp.

Matrix< double > OpenNN::MultilayerPerceptron::calculate_layer_combination_combination_Jacobian ( const size_t &  layer_index,
const Vector< double > &  previous_layer_activation_derivative 
) const

Returns the partial derivatives of the combinations of one layer with respect to the combinations in the previous layer. Note that, for efficiency issues, the argument here is the activation derivative of the previous layer, and not the combination of the previous layer. This quantity is the Jacobian matrix of the layer combination-combination function.

Parameters
layer_indexIndex of layer.
previous_layer_activation_derivativeVector of activation derivatives of the previous layer.

Definition at line 2123 of file multilayer_perceptron.cpp.

Vector< Vector< double > > OpenNN::MultilayerPerceptron::calculate_layers_activation ( const Vector< double > &  inputs) const

Returns a vector of vectors, where each element contains the activation values of a layer in response to an inputs to the multilayer perceptron

Parameters
inputsInput values to the multilayer perceptron

Definition at line 3088 of file multilayer_perceptron.cpp.

Vector< Vector< double > > OpenNN::MultilayerPerceptron::calculate_layers_activation_derivative ( const Vector< double > &  inputs) const

Returns a vector of vectors, where each element contains the activation derivatives of a layer in response to an inputs to the multilayer perceptron

Parameters
inputsInput values to the multilayer perceptron

Definition at line 3135 of file multilayer_perceptron.cpp.

Vector< Vector< double > > OpenNN::MultilayerPerceptron::calculate_layers_activation_second_derivative ( const Vector< double > &  inputs) const

Returns a vector of vectors with the forward propagation values, their derivatives and their second derivatives. The size of the vector is equal to the number of layers. The elements are the following:

  • Activation second derivative from layers.
  • Activation second derivative from outputs layer.
Parameters
inputsSet of inputs to the multilayer perceptron

Definition at line 3192 of file multilayer_perceptron.cpp.

Vector< Vector< double > > OpenNN::MultilayerPerceptron::calculate_layers_combination ( const Vector< double > &  inputs) const

Returns a vector of vectors, where each element contains the combination values of a layer in response to an inputs to the multilayer perceptron

Parameters
inputsInput values to the multilayer perceptron

Definition at line 2883 of file multilayer_perceptron.cpp.

Vector< Matrix< double > > OpenNN::MultilayerPerceptron::calculate_layers_combination_Jacobian ( const Vector< double > &  inputs) const

Returns the Jacobians of all the layer combination functions. The format of this quantity is a vector of matrices.

Definition at line 2935 of file multilayer_perceptron.cpp.

Vector< Matrix< double > > OpenNN::MultilayerPerceptron::calculate_layers_combination_parameters_Jacobian ( const Vector< Vector< double > > &  layers_inputs) const

Returns the Jacobian matix of the combination function for each layer. The format is a vector of matrices. The size of the vector is the number of layers.

Parameters
layers_inputsInput values for each layer.

Definition at line 2990 of file multilayer_perceptron.cpp.

Vector< Vector< Matrix< double > > > OpenNN::MultilayerPerceptron::calculate_layers_Hessian_form ( const Vector< double > &  inputs) const

Returns the second partial derivatives of the outputs from each layer with respect to the inputs to the corresponding layer, for a vector of inputs to the neural netwok. The format of this quantity is a vector of vectors of matrices.

Parameters
inputsVector of inputs to the multilayer perceptron

Definition at line 3273 of file multilayer_perceptron.cpp.

Vector< Vector< double > > OpenNN::MultilayerPerceptron::calculate_layers_input ( const Vector< double > &  inputs) const

Returns a vector of vectors, where each element contains the input values of a layer in response to an inputs to the multilayer perceptron

Parameters
inputsInput values to the multilayer perceptron

Definition at line 2860 of file multilayer_perceptron.cpp.

Vector< Matrix< double > > OpenNN::MultilayerPerceptron::calculate_layers_Jacobian ( const Vector< double > &  inputs) const

Returns the partial derivatives of the outputs from each layer with respect to the inputs to the corresponding layer, for a vector of inputs to the neural netwok. The format of this quantity is a vector of matrices.

Parameters
inputsVector of inputs to the multilayer perceptron

Definition at line 3245 of file multilayer_perceptron.cpp.

Matrix< Vector< Matrix< double > > > OpenNN::MultilayerPerceptron::calculate_output_interlayers_Delta ( const Vector< Vector< Vector< double > > > &  second_order_forward_propagation,
const Matrix< Matrix< double > > &  interlayers_combination_combination_Jacobian,
const Vector< Matrix< double > > &  output_layers_delta 
) const
Todo:
Parameters
second_order_forward_propagation
interlayers_combination_combination_Jacobian
output_layers_delta

Definition at line 2377 of file multilayer_perceptron.cpp.

Vector< double > OpenNN::MultilayerPerceptron::calculate_output_layer_combination ( const size_t &  layer_index,
const Vector< double > &  layer_combinations 
) const

Calculates the output values from the neural network from the combination values of a given layer.

Parameters
layer_indexIndex of a layer.
layer_combinationsCombination values of the layer with the previous index.

Definition at line 2276 of file multilayer_perceptron.cpp.

Vector< Matrix< double > > OpenNN::MultilayerPerceptron::calculate_output_layers_delta ( const Vector< Vector< double > > &  layers_activation_derivative) const

Calculates the output delta matrix for each layer in the multilayer perceptron. The format is a vector of matrices.

Parameters
layers_activation_derivativeActivation derivative values for each layer.

Definition at line 2321 of file multilayer_perceptron.cpp.

Vector< double > OpenNN::MultilayerPerceptron::calculate_outputs ( const Vector< double > &  inputs) const

Returns the outputs from the multilayer perceptron for a given set of inputs to it. That is, it computes the inputs-outputs relationship of the raw multilayer perceptron

Parameters
inputsVector of inputs to the first layer of the multilayer perceptron.

Definition at line 1879 of file multilayer_perceptron.cpp.

Vector< double > OpenNN::MultilayerPerceptron::calculate_outputs ( const Vector< double > &  inputs,
const Vector< double > &  parameters 
) const

Returns the outputs from the multilayer perceptron for given sets of inputs and parameters. This function is called the parameters outputs.

Parameters
inputsVector of inputs to the first layer of the multilayer perceptron.
parametersVector of potential parameters for the multilayer perceptron.

Definition at line 2527 of file multilayer_perceptron.cpp.

Vector< Vector< Vector< double > > > OpenNN::MultilayerPerceptron::calculate_perceptrons_combination_parameters_gradient ( const Vector< Vector< double > > &  layers_inputs) const

Returns the combination parameters gradient of all neurons in the network architecture. The format is a vector of subvectors of subsubvectors. The size of the vector is the number of layers. The size of each subvector is the number of perceptrons in the layer. The size of each subsubvector is the number of inputs to the perceptron. That quantities will be useful for calculating some multilayer perceptron derivatives.

Parameters
layers_inputsVector of subvectors with the inputs to each layer.

Definition at line 3017 of file multilayer_perceptron.cpp.

Vector< Vector< Vector< double > > > OpenNN::MultilayerPerceptron::calculate_second_order_forward_propagation ( const Vector< double > &  inputs) const

Returns the second order forward propagation quantities from the multilayer perceptron for a given inputs. That quantites include the activation, the activation derivative and the activation second derivative of all layers. The format is a vector of vectors of vectors. The first index refers to the activation derivative order (0 for the activation, 1 for the activation derivative and 2 for the activation second derivative). The second index is the index of the layer. The third index is the index of the neuron.

Parameters
inputsVector of inputs to the multilayer perceptron

Definition at line 3449 of file multilayer_perceptron.cpp.

Vector< size_t > OpenNN::MultilayerPerceptron::count_layers_parameters_numbers ( void  ) const

Returns the number of parameters for each layer in this multilayer perceptron. The format is a vector with size the number of layers. Each element contains the number of parameters (biases and synaptic weights) in the corresponding layer.

Definition at line 438 of file multilayer_perceptron.cpp.

size_t OpenNN::MultilayerPerceptron::count_perceptrons_number ( void  ) const

Returns the total number of perceptrons in the multilayer perceptron. This is equal to the sum of the perceptrons of all layers.

Definition at line 241 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::from_XML ( const tinyxml2::XMLDocument &  document)

Deserializes a TinyXML document into this multilayer perceptron object.

Parameters
documentTinyXML document containing the member data.

Definition at line 3592 of file multilayer_perceptron.cpp.

const bool & OpenNN::MultilayerPerceptron::get_display ( void  ) 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 771 of file multilayer_perceptron.cpp.

const PerceptronLayer & OpenNN::MultilayerPerceptron::get_layer ( const size_t &  i) const

Returns a reference to the vector of perceptrons in a single layer.

Parameters
iIndex of layer.

Definition at line 181 of file multilayer_perceptron.cpp.

size_t OpenNN::MultilayerPerceptron::get_layer_bias_index ( const size_t &  layer_index,
const size_t &  perceptron_index 
) const

Returns the index in the vector of parameters of a bias.

Parameters
layer_indexIndex of layer.
perceptron_indexIndex of perceptron within that layer.

Definition at line 514 of file multilayer_perceptron.cpp.

size_t OpenNN::MultilayerPerceptron::get_layer_index ( const size_t &  neuron_index) const

Returns the index of the layer at which a perceptron belongs to.

Parameters
neuron_indexIndex of the neuron.

Definition at line 458 of file multilayer_perceptron.cpp.

PerceptronLayer * OpenNN::MultilayerPerceptron::get_layer_pointer ( const size_t &  i)

Returns a pointer to a given layer of perceptrons.

Parameters
iIndex of perceptron layer.

Definition at line 211 of file multilayer_perceptron.cpp.

size_t OpenNN::MultilayerPerceptron::get_layer_synaptic_weight_index ( const size_t &  layer_index,
const size_t &  perceptron_index,
const size_t &  input_index 
) const

Returns the index in the vector of parameters of a synaptic weight.

Parameters
layer_indexIndex of layer.
perceptron_indexIndex of perceptron within that layer.
input_indexIndex of inputs within that perceptron.

Definition at line 576 of file multilayer_perceptron.cpp.

const Vector< PerceptronLayer > & OpenNN::MultilayerPerceptron::get_layers ( void  ) const

Returns the layers of the multilayer perceptron The format is a reference to the vector of vectors of perceptrons. Note that each layer might have a different size.

Definition at line 170 of file multilayer_perceptron.cpp.

Vector< Vector< double > > OpenNN::MultilayerPerceptron::get_layers_parameters ( void  ) const

Returns the neural parameter values (biases and synaptic weights) from the neurons in all the layers. The format is a vector of matrices of real values. The size of this vector is the number of layers. The number of rows of each sub_matrix is the number of neurons in the corresponding layer. The number of columns of each sub_matrix is the number of parameters (inputs + 1) to the corresponding layer.

Definition at line 371 of file multilayer_perceptron.cpp.

size_t OpenNN::MultilayerPerceptron::get_perceptron_index ( const size_t &  layer_index,
const size_t &  perceptron_position 
) const

Returns the index of a neuron, given the layer it belongs and its position in that layer.

Parameters
layer_indexIndex of layer.
perceptron_positionPosition on the perceptron in that layer.

Definition at line 493 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::grow_input ( void  )
Todo:

Definition at line 1376 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::grow_layer ( const size_t &  layer_index,
const size_t &  perceptrons_number 
)

Adds a new perceptron in a given layer of the multilayer perceptron.

Parameters
layer_indexIndex of the layer to be grown.
perceptrons_numberNumber of perceptrons to be added.

Definition at line 1393 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::initialize_biases ( const double &  value)

Initializes the biases of all the perceptrons in the multilayer perceptron with a given value.

Parameters
valueBiases initialization value.

Definition at line 1620 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::initialize_parameters ( const double &  value)

Initializes all the biases and synaptic weights in the neural newtork with a given value.

Parameters
valueMultilayer perceptron parameters initialization value.

Definition at line 1653 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::initialize_random ( void  )

Sets a random architecture in the multilayer perceptron. It also sets random activation functions for each layer. This method is useful for testing purposes.

Definition at line 1544 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::initialize_synaptic_weights ( const double &  value)

Initializes the synaptic weights of all the perceptrons in the multilayer perceptron with a given value.

Parameters
valueSynaptic weights initialization value.

Definition at line 1636 of file multilayer_perceptron.cpp.

MultilayerPerceptron & OpenNN::MultilayerPerceptron::operator= ( const MultilayerPerceptron other_multilayer_perceptron)

Assignment operator. It assigns to this object the members of an existing multilayer perceptron object.

Parameters
other_multilayer_perceptronMultilayer perceptron object to be assigned.

Definition at line 126 of file multilayer_perceptron.cpp.

bool OpenNN::MultilayerPerceptron::operator== ( const MultilayerPerceptron other_multilayer_perceptron) const

Equal to operator. It compares this object with another object of the same class. It returns true if the members of the two objects have the same values, and false otherwise. @ param other_multilayer_perceptron Multilayer perceptron to be compared with.

Definition at line 148 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::perturbate_parameters ( const double &  perturbation)

Perturbate parameters of the multilayer perceptron.

Parameters
perturbationMaximum distance of perturbation.

Definition at line 1830 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::prune_input ( const size_t &  index)

Removes a given input to the multilayer perceptron.

Parameters
indexIndex of input to be pruned.

Definition at line 1434 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::prune_layer ( const size_t &  layer_index,
const size_t &  perceptron_index 
)

Removes a perceptron from the multilayer perceptron.

Parameters
layer_indexIndex of the layer where is the perceptron to be removed.
perceptron_indexIndex of the perceptron to be pruned.

Definition at line 1505 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::prune_output ( const size_t &  index)

Removes a given output neuron from the multilayer perceptron.

Parameters
indexIndex of output to be pruned.

Definition at line 1469 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::randomize_parameters_normal ( void  )

Initializes all the biases and synaptic weights in the newtork with random values chosen from a normal distribution with mean 0 and standard deviation 1.

Definition at line 1744 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::randomize_parameters_normal ( const double &  mean,
const double &  standard_deviation 
)

Initializes all the biases and synaptic weights in the multilayer perceptron with random random values chosen from a normal distribution with a given mean and a given standard deviation.

Parameters
meanMean of normal distribution.
standard_deviationStandard deviation of normal distribution.

Definition at line 1763 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::randomize_parameters_normal ( const Vector< double > &  mean,
const Vector< double > &  standard_deviation 
)

Initializes all the biases an synaptic weights in the multilayer perceptron with random values chosen from normal distributions with different mean and standard deviation for each parameter.

Parameters
meanVector of mean values.
standard_deviationVector of standard deviation values.

Definition at line 1782 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::randomize_parameters_normal ( const Vector< Vector< double > > &  mean_standard_deviation)

Initializes all the biases and synaptic weights in the multilayer perceptron with random values chosen from normal distributions with different mean and standard deviation for each parameter. All mean and standard deviation values are given from a vector of two real vectors. The first element must contain the mean value for each parameter. The second element must contain the standard deviation value for each parameter.

Parameters
mean_standard_deviationVector of mean and standard deviation values.

Definition at line 1803 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::randomize_parameters_uniform ( void  )

Initializes all the biases and synaptic weights in the neural newtork at random with values comprised between -1 and +1.

Definition at line 1668 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::randomize_parameters_uniform ( const double &  minimum,
const double &  maximum 
)

Initializes all the biases and synaptic weights in the multilayer perceptron at random with values comprised between a minimum and a maximum values.

Parameters
minimumMinimum initialization value.
maximumMaximum initialization value.

Definition at line 1687 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::randomize_parameters_uniform ( const Vector< double > &  minimum,
const Vector< double > &  maximum 
)

Initializes all the biases and synaptic weights in the multilayer perceptron at random, with values comprised between different minimum and maximum numbers for each parameter.

Parameters
minimumVector of minimum initialization values.
maximumVector of maximum initialization values.

Definition at line 1706 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::randomize_parameters_uniform ( const Vector< Vector< double > > &  minimum_maximum)

Initializes all the biases and synaptic weights in the multilayer perceptron at random, with values comprised between a different minimum and maximum numbers for each parameter. All minimum are maximum initialization values must be given from a vector of two real vectors. The first element must contain the minimum inizizalization value for each parameter. The second element must contain the maximum inizizalization value for each parameter.

Parameters
minimum_maximumVector of minimum and maximum initialization values.

Definition at line 1727 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set ( const Vector< PerceptronLayer > &  new_layers)

Sets a multilayer_perceptron_pointer architecture with given layers of perceptrons.

Parameters
new_layersVector of vectors of perceptrons, which represent the multilayer perceptron architecture.

Definition at line 823 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set ( const Vector< size_t > &  new_architecture)

Sets a deep learning architecture for the multilayer perceptron. The architecture is represented as a vector of integers. The number of layers is the size of that vector minus one. The first element in the vector represents the number of inputs. The rest of elements represent the corresponding number of perceptrons in each layer. All the parameters of the multilayer perceptron are initialized at random.

Parameters
new_architectureArchitecture of the multilayer perceptron.

Definition at line 839 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set ( const size_t &  new_inputs_number,
const size_t &  new_perceptrons_number 
)

Sets a new architecture with just one layer.

Parameters
new_inputs_numberNumber of inputs to the multilayer perceptron.
new_perceptrons_numberNumber of perceptrons in the unique layer. This is also the number of outputs.

Definition at line 899 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set ( const size_t &  new_inputs_number,
const size_t &  new_hidden_neurons_number,
const size_t &  new_outputs_number 
)

Sets a new multilayer_perceptron_pointer architecture with two layers, a hidden layer and an outputs layer.

Parameters
new_inputs_numberNumber of inputs to the multilayer perceptron.
new_hidden_neurons_numberNumber of neurons in the hidden layer.
new_outputs_numberNumber of outputs from the multilayer perceptron.

Definition at line 939 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set ( const MultilayerPerceptron other_multilayer_perceptron)

Sets the members of this object to be the members of another object of the same class.

Parameters
other_multilayer_perceptronObject to be copied.

Definition at line 989 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set_default ( void  )
virtual

Sets those members not related to the multilayer perceptron architecture to their default values:

  • First perceptron layers activation function: Hyperbolic tangent.
  • Last perceptron layer activation function: Linear.
  • Display: True.

Definition at line 786 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::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 1349 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set_inputs_number ( const size_t &  new_inputs_number)

This method set a new number of inputs in the multilayer perceptron.

Parameters
new_inputs_numberNumber of inputs.

Definition at line 1002 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set_layer_activation_function ( const size_t &  i,
const Perceptron::ActivationFunction new_layer_activation_function 
)

This class sets a new activation (or transfer) function in a single layer of the multilayer perceptron

Parameters
iIndex of layer.
new_layer_activation_functionActivation function for that layer.

Definition at line 1280 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set_layer_perceptrons_number ( const size_t &  layer_index,
const size_t &  new_layer_perceptrons_number 
)

Sets the size of the layer of the multilayer perceptron when this is unique. All the parameters of the multilayer perceptron are initialized at random.

Parameters
layer_indexIndex of layer.
new_layer_perceptrons_numberNew numbers of neurons for that layer of the multilayer perceptron

Definition at line 1041 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set_layers ( const Vector< PerceptronLayer > &  new_layers)

Sets a new multilayer_perceptron_pointer architecture by means of a pack of layers of perceptrons.

Parameters
new_layersVector o vectors of perceptron neurons representing a multilayer_perceptron_pointer architecture arranged in layers.

Definition at line 1063 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set_layers_activation_function ( const Vector< Perceptron::ActivationFunction > &  new_layers_activation_function)

This class sets a new activation (or transfer) function in all the layers of the multilayer perceptron

Parameters
new_layers_activation_functionActivation function for the layers. The size of this Vector must be equal to the number of layers, and each element corresponds to the activation function of one layer.

Definition at line 1243 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set_layers_activation_function ( const Vector< std::string > &  new_layers_activation_function)

Sets a new activation (or transfer) function in all the layers. The argument is a string containing the name of the function ("Logistic", "HyperbolicTangent", "Threshold", etc).

Parameters
new_layers_activation_functionActivation function for the layers.

Definition at line 1311 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set_layers_biases ( const Vector< Vector< double > > &  new_layers_biases)

Sets all the biases of the layers in the multilayer perceptron The format is a vector of vectors of real numbers. The size of this vector is the number of layers. The size of each subvector is the number of neurons in the corresponding layer.

Parameters
new_layers_biasesNew set of biases in the layers.

Definition at line 1077 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set_layers_parameters ( const Vector< Vector< double > > &  new_layers_parameters)

Sets the multilayer perceptron parameters of all layers in the multilayer perceptron The argument is a vector of vectors of real numbers. The number of elements is the number of layers. Each element contains the vector of parameters of a single layer

Parameters
new_layers_parametersNew vector of layers parameters.

Definition at line 1157 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set_layers_perceptrons_number ( const Vector< size_t > &  new_layers_size)

Sets the size of the layers of the multilayer perceptron. It neither modifies the number of inputs nor the number of outputs.

Parameters
new_layers_sizeNew numbers of neurons for the layers of the multilayer perceptron The number of elements of this vector is the number of layers.

Definition at line 1026 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set_layers_synaptic_weights ( const Vector< Matrix< double > > &  new_layers_synaptic_weights)

Sets all the synaptic weights of the layers in the multilayer perceptron The format is a vector of matrices of real numbers. The size of this vector is the number of layers. The number of rows of each sub_matrix is the number of neurons in the corresponding layer. The number of columns of each sub_matrix is the number of inputs to the corresponding layer.

Parameters
new_layers_synaptic_weightsNew set of synaptic weights in the layers.

Definition at line 1118 of file multilayer_perceptron.cpp.

void OpenNN::MultilayerPerceptron::set_parameters ( const Vector< double > &  new_parameters)

Sets all the biases and synaptic weights in the multilayer perceptron from a single vector.

Parameters
new_parametersNew set of biases and synaptic weights values.

Definition at line 1192 of file multilayer_perceptron.cpp.

tinyxml2::XMLDocument * OpenNN::MultilayerPerceptron::to_XML ( void  ) const

Serializes the multilayer perceptron object into a XML document of the TinyXML library. See the OpenNN manual for more information about the format of this document->

Definition at line 3528 of file multilayer_perceptron.cpp.

std::string OpenNN::MultilayerPerceptron::write_expression ( const Vector< std::string > &  inputs_name,
const Vector< std::string > &  outputs_name 
) const

Returns a string with the expression of the forward propagation process in a multilayer perceptron.

Parameters
inputs_nameName of input variables.
outputs_nameName of output variables.

Definition at line 3754 of file multilayer_perceptron.cpp.

Matrix< std::string > OpenNN::MultilayerPerceptron::write_information ( void  ) const

Returns a string matrix with certain information about the multilayer perceptron, which includes the number of inputs, the number of perceptrons and the activation function of all the layers. The number of rows is the number of layers, and the number of columns is three. Each row in the matrix contains the information of a single layer.

Definition at line 3704 of file multilayer_perceptron.cpp.

Vector< std::string > OpenNN::MultilayerPerceptron::write_layers_activation_function ( void  ) const

Returns a vector of strings with the name of the activation functions for the layers. The size of this vector is the number of layers.

Definition at line 751 of file multilayer_perceptron.cpp.

Member Data Documentation

Vector<PerceptronLayer> OpenNN::MultilayerPerceptron::layers
protected

Multilayer perceptron layers. It is built as a vector of vectors of perceptrons. The size of this vector is equal to the number of layers. The size of each subvector is equal to the number of neurons in the corresponding layer.

Definition at line 433 of file multilayer_perceptron.h.


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