14 #ifndef _MULTILAYERPERCEPTRON_H__
15 #define _MULTILAYERPERCEPTRON_H__
28 #include "perceptron.h"
29 #include "perceptron_layer.h"
38 #include "../tinyxml2/tinyxml2.h"
106 if(layers_number != 0)
109 architecture.resize(1+layers_number);
111 architecture[0] = inputs_number;
115 for(
size_t i = 0; i < layers_number; i++)
117 architecture[i+1] = layers_size[i];
121 return(architecture);
133 if(layers_number != 1)
135 complexity.resize(layers_number-1);
139 for(
size_t i = 0; i < layers_number-1; i++)
141 complexity[i] = layers_size[i];
155 if(layers_number == 0)
180 for(
size_t i = 0; i < layers_number; i++)
182 layers_inputs_number[i] =
layers[i].get_inputs_number();
185 return(layers_inputs_number);
197 for(
size_t i = 0; i < layers_number; i++)
199 layers_perceptrons_number[i] =
layers[i].get_perceptrons_number();
202 return(layers_perceptrons_number);
212 if(layers_number == 0)
218 return(
layers[layers_number-1].get_perceptrons_number());
267 void set(
const size_t&,
const size_t&);
268 void set(
const size_t&,
const size_t&,
const size_t&);
331 void grow_layer(
const size_t&,
const size_t&);
411 tinyxml2::XMLDocument*
to_XML(
void)
const;
412 void from_XML(
const tinyxml2::XMLDocument&);
Vector< double > calculate_output_layer_combination(const size_t &, const Vector< double > &) const
void set_layer_perceptrons_number(const size_t &, const size_t &)
tinyxml2::XMLDocument * to_XML(void) const
Vector< size_t > count_layers_parameters_numbers(void) const
Vector< std::string > write_layers_activation_function(void) const
bool is_empty(void) const
Returns true if the number of layers in the multilayer perceptron is zero, and false otherwise...
Vector< Perceptron::ActivationFunction > get_layers_activation_function(void) const
Returns the activation function of every layer in a single vector.
const Vector< PerceptronLayer > & get_layers(void) const
std::string write_expression(const Vector< std::string > &, const Vector< std::string > &) const
void set_layers_activation_function(const Vector< Perceptron::ActivationFunction > &)
Vector< Vector< double > > arrange_layers_biases(void) const
Matrix< double > calculate_interlayer_combination_combination_Jacobian(const size_t &, const size_t &, const Vector< double > &) const
void initialize_synaptic_weights(const double &)
size_t get_layer_synaptic_weight_index(const size_t &, const size_t &, const size_t &) const
void set_inputs_number(const size_t &)
Vector< Vector< Matrix< double > > > calculate_layers_Hessian_form(const Vector< double > &) const
void set_display(const bool &)
size_t get_layer_bias_index(const size_t &, const size_t &) const
size_t get_inputs_number(void) const
Returns the number of inputs to the multilayer perceptron.
Matrix< size_t > arrange_parameters_indices(void) const
Matrix< Matrix< double > > calculate_interlayers_combination_combination_Jacobian(const Vector< double > &) const
size_t get_layers_number(void) const
Returns the number of layers in the multilayer perceptron.
Vector< double > calculate_layer_combination_combination(const size_t &, const Vector< double > &) const
void from_XML(const tinyxml2::XMLDocument &)
Vector< Matrix< double > > calculate_layers_combination_Jacobian(const Vector< double > &) const
void perturbate_parameters(const double &)
Vector< size_t > arrange_layers_perceptrons_numbers(void) const
Returns a vector with the size of each layer.
ActivationFunction
Enumeration of available activation functions for the perceptron neuron model.
size_t get_outputs_number(void) const
Returns the number of outputs neurons in the multilayer perceptron.
Vector< double > calculate_outputs(const Vector< double > &) const
Vector< Vector< double > > get_layers_parameters(void) const
Vector< size_t > arrange_complexity(void) const
Returns a vector with the sizes of the hidden layers in the multilayer perceptron.
void randomize_parameters_uniform(void)
Matrix< Vector< Matrix< double > > > calculate_output_interlayers_Delta(const Vector< Vector< Vector< double > > > &, const Matrix< Matrix< double > > &, const Vector< Matrix< double > > &) const
Vector< Vector< double > > calculate_layers_combination(const Vector< double > &) const
void set_parameters(const Vector< double > &)
void set(void)
Sets an empty multilayer_perceptron_pointer architecture.
void prune_input(const size_t &)
Vector< size_t > arrange_layers_parameters_number(void) const
Vector< size_t > arrange_parameter_indices(const size_t &) const
Vector< Vector< double > > calculate_layers_input(const Vector< double > &) const
size_t count_perceptrons_number(void) const
void initialize_parameters(void)
Initializes the parameters at random with values chosen from a normal distribution with mean 0 and st...
void grow_layer(const size_t &, const size_t &)
Vector< Vector< Vector< double > > > calculate_perceptrons_combination_parameters_gradient(const Vector< Vector< double > > &) const
void set_layers_parameters(const Vector< Vector< double > > &)
double calculate_parameters_norm(void) const
Returns the norm of the vector of multilayer perceptron parameters.
void initialize_biases(const double &)
const bool & get_display(void) const
const PerceptronLayer & get_layer(const size_t &) const
virtual ~MultilayerPerceptron(void)
Vector< size_t > arrange_architecture(void) const
void prune_layer(const size_t &, const size_t &)
std::string to_string(void) const
Returns a string representation of the current multilayer perceptron object.
void randomize_parameters_normal(void)
Vector< Vector< double > > calculate_layers_activation_second_derivative(const Vector< double > &) const
Matrix< double > calculate_Jacobian(const Vector< double > &) const
PerceptronLayer * get_layer_pointer(const size_t &)
Matrix< double > calculate_layer_combination_combination_Jacobian(const size_t &, const Vector< double > &) const
Vector< PerceptronLayer > layers
Vector< size_t > get_layers_inputs_number(void) const
Returns a vector with the number of inputs of each layer.
Vector< double > calculate_interlayer_combination_combination(const size_t &, const size_t &, const Vector< double > &) const
Vector< Matrix< double > > calculate_layers_combination_parameters_Jacobian(const Vector< Vector< double > > &) const
Vector< Vector< double > > calculate_layers_activation_derivative(const Vector< double > &) const
Vector< size_t > count_cumulative_perceptrons_number(void) const
Returns a vector of size the number of layers, where each element is equal to the total number of neu...
Vector< Matrix< double > > calculate_layers_Jacobian(const Vector< double > &) const
void set_layers_perceptrons_number(const Vector< size_t > &)
Vector< Vector< double > > calculate_layers_activation(const Vector< double > &) const
Vector< Matrix< double > > calculate_output_layers_delta(const Vector< Vector< double > > &) const
void set_layers_synaptic_weights(const Vector< Matrix< double > > &)
Matrix< std::string > write_information(void) const
size_t get_perceptron_index(const size_t &, const size_t &) const
Vector< double > arrange_parameters(void) const
Returns the values of all the biases and synaptic weights in the multilayer perceptron as a single ve...
Vector< Vector< Vector< double > > > calculate_first_order_forward_propagation(const Vector< double > &) const
Vector< size_t > arrange_layers_cumulative_parameters_number(void) const
virtual void set_default(void)
MultilayerPerceptron & operator=(const MultilayerPerceptron &)
void set_layers(const Vector< PerceptronLayer > &)
void set_layer_activation_function(const size_t &, const Perceptron::ActivationFunction &)
Vector< Matrix< double > > calculate_Hessian_form(const Vector< double > &) const
void prune_output(const size_t &)
bool operator==(const MultilayerPerceptron &) const
bool display
Display messages to screen.
void set_layers_biases(const Vector< Vector< double > > &)
size_t get_layer_index(const size_t &) const
Vector< Vector< Vector< double > > > calculate_second_order_forward_propagation(const Vector< double > &) const
MultilayerPerceptron(void)
void initialize_random(void)
Vector< Matrix< double > > arrange_layers_synaptic_weights(void) const
Vector< Vector< double > > arrange_layers_input(const Vector< double > &, const Vector< Vector< double > > &) const
size_t count_parameters_number(void) const
Returns the number of parameters (biases and synaptic weights) in the multilayer perceptron.