#include <perceptron.h>
Public Types | |
enum | ActivationFunction { Threshold, SymmetricThreshold, Logistic, HyperbolicTangent, Linear } |
Public Member Functions | |
Perceptron (void) | |
Perceptron (const unsigned int &) | |
Perceptron (const unsigned int &, const double &) | |
Perceptron (const Perceptron &) | |
virtual | ~Perceptron (void) |
Perceptron & | operator= (const Perceptron &) |
bool | operator== (const Perceptron &) const |
unsigned int | count_inputs_number (void) const |
const ActivationFunction & | get_activation_function (void) const |
std::string | write_activation_function (void) const |
const double & | get_bias (void) const |
const Vector< double > & | arrange_synaptic_weights (void) const |
const double & | get_synaptic_weight (const unsigned int &) const |
unsigned int | count_parameters_number (void) const |
Vector< double > | arrange_parameters (void) const |
const bool & | get_display (void) const |
void | set (void) |
void | set (const unsigned int &) |
void | set (const unsigned int &, const double &) |
void | set (const Perceptron &) |
void | set_inputs_number (const unsigned int &) |
void | set_activation_function (const ActivationFunction &) |
void | set_activation_function (const std::string &) |
void | set_bias (const double &) |
void | set_synaptic_weights (const Vector< double > &) |
void | set_synaptic_weight (const unsigned int &, const double &) |
void | set_parameters (const Vector< double > &) |
void | set_display (const bool &) |
void | initialize_bias (const double &) |
void | initialize_bias_uniform (const double &, const double &) |
void | initialize_bias_normal (const double &, const double &) |
void | initialize_synaptic_weights (const double &) |
void | initialize_synaptic_weights_uniform (const double &, const double &) |
void | initialize_synaptic_weights_normal (const double &, const double &) |
void | initialize_parameters (const double &) |
double | calculate_combination (const Vector< double > &) const |
double | calculate_combination_parameters (const Vector< double > &, const Vector< double > &) const |
Vector< double > | calculate_combination_gradient (const Vector< double > &) const |
Matrix< double > | calculate_combination_Hessian (const Vector< double > &) const |
Vector< double > | calculate_combination_parameters_gradient (const Vector< double > &) const |
Matrix< double > | calculate_combination_parameters_Hessian (const Vector< double > &) const |
double | calculate_activation (const double &) const |
double | calculate_activation_derivative (const double &) const |
double | calculate_activation_second_derivative (const double &) const |
double | calculate_outputs (const Vector< double > &) const |
Vector< double > | calculate_gradient (const Vector< double > &) const |
Matrix< double > | calculate_Hessian (const Vector< double > &) const |
double | calculate_parameters_output (const Vector< double > &, const Vector< double > &) const |
Vector< double > | calculate_parameters_gradient (const Vector< double > &) const |
Matrix< double > | calculate_parameters_Hessian (const Vector< double > &) const |
void | grow_input (void) |
void | prune_input (const unsigned int &) |
std::string | write_expression (const Vector< std::string > &, const std::string &) const |
Definition at line 30 of file perceptron.h.
Enumeration of available activation functions for the perceptron neuron model.
Definition at line 66 of file perceptron.h.
OpenNN::Perceptron::Perceptron | ( | void | ) | [explicit] |
Default constructor. It creates a perceptron object with zero inputs. The neuron's bias is initialized to zero. This constructor also initializes the rest of class members to their default values.
Definition at line 37 of file perceptron.cpp.
OpenNN::Perceptron::Perceptron | ( | const unsigned int & | new_inputs_number | ) | [explicit] |
Inputs number constructor. It creates a perceptron object with a given number of inputs. The neuron's free paramameters (bias and synaptic weights) are initialized at random with a normal distribution of mean 0 and standard deviation 1. This constructor also initializes the rest of class members to their default values.
new_inputs_number | Number of inputs in the neuron. |
Definition at line 50 of file perceptron.cpp.
OpenNN::Perceptron::Perceptron | ( | const unsigned int & | new_inputs_number, | |
const double & | new_parameters_value | |||
) | [explicit] |
Inputs number and initialization constructor. This creates a perceptron with a given number of inputs. It also initializes the bias and synaptic weights with a given value.
new_inputs_number | Number of inputs in the neuron. | |
new_parameters_value | Bias and synaptic weights initialization value. |
Definition at line 62 of file perceptron.cpp.
OpenNN::Perceptron::Perceptron | ( | const Perceptron & | other_perceptron | ) |
Copy constructor. It creates a percdeptron object by copying its members with those for other perceptron object.
other_perceptron | Perceptron object to be copied. |
Definition at line 72 of file perceptron.cpp.
OpenNN::Perceptron::~Perceptron | ( | void | ) | [virtual] |
Destructor. This destructor does not delete any pointer.
Definition at line 81 of file perceptron.cpp.
Perceptron & OpenNN::Perceptron::operator= | ( | const Perceptron & | other_perceptron | ) |
Assignment operator. It assigns to the current perceptron the members of an existing perceptron.
other_perceptron | Assigning perceptron object . |
Definition at line 92 of file perceptron.cpp.
bool OpenNN::Perceptron::operator== | ( | const Perceptron & | other_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_perceptron Perceptron to be compared with.
Definition at line 118 of file perceptron.cpp.
unsigned int OpenNN::Perceptron::count_inputs_number | ( | void | ) | const |
This method returns the number of inputs to the neuron.
Definition at line 203 of file perceptron.cpp.
const Perceptron::ActivationFunction & OpenNN::Perceptron::get_activation_function | ( | void | ) | const |
This method returns the activation function of the neuron.
Definition at line 140 of file perceptron.cpp.
std::string OpenNN::Perceptron::write_activation_function | ( | void | ) | const |
This method returns a string with the name of the activation function of the neuron.
Definition at line 150 of file perceptron.cpp.
const double & OpenNN::Perceptron::get_bias | ( | void | ) | const |
const Vector< double > & OpenNN::Perceptron::arrange_synaptic_weights | ( | void | ) | const |
This method returns the synaptic weight values of the neuron.
Definition at line 223 of file perceptron.cpp.
const double & OpenNN::Perceptron::get_synaptic_weight | ( | const unsigned int & | synaptic_weight_index | ) | const |
This method returns the synaptic weight value with index i of the neuron.
synaptic_weight_index | Synaptic weight index. |
Definition at line 234 of file perceptron.cpp.
unsigned int OpenNN::Perceptron::count_parameters_number | ( | void | ) | const |
This method returns the number of parameters (bias and synaptic weights) in the perceptron.
Definition at line 504 of file perceptron.cpp.
Vector< double > OpenNN::Perceptron::arrange_parameters | ( | void | ) | const |
This method returns the parameters (bias and synaptic weights) of the perceptron.
Definition at line 516 of file perceptron.cpp.
const bool & OpenNN::Perceptron::get_display | ( | void | ) | const |
This method 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 266 of file perceptron.cpp.
void OpenNN::Perceptron::set | ( | void | ) |
This method sets the number of inputs to zero and the rest of members to their default values.
Definition at line 276 of file perceptron.cpp.
void OpenNN::Perceptron::set | ( | const unsigned int & | new_inputs_number | ) |
This method sets a new number of inputs. It also sets the other members of this object to their defaul values.
new_inputs_number | Number of inputs in the neuron. |
Definition at line 294 of file perceptron.cpp.
void OpenNN::Perceptron::set | ( | const unsigned int & | new_inputs_number, | |
const double & | new_parameters_value | |||
) |
This method sets the number of inputs to a given value and initializes the bias and the synaptic weights with a given value.
new_inputs_number | Number of inputs in the neuron. | |
new_parameters_value | Parameters initialization value. |
Definition at line 315 of file perceptron.cpp.
void OpenNN::Perceptron::set | ( | const Perceptron & | other_perceptron | ) |
This method sets the members of this perceptron object with those from other perceptron object.
other_perceptron | Setting perceptron object. |
Definition at line 331 of file perceptron.cpp.
void OpenNN::Perceptron::set_inputs_number | ( | const unsigned int & | new_inputs_number | ) |
This method sets a new number of inputs in the neuron. The new synaptic weights are initialized at random with a normal distribution of mean 0 and standard deviation 1.
new_inputs_number | Number of inputs in the neuton. |
Definition at line 491 of file perceptron.cpp.
void OpenNN::Perceptron::set_activation_function | ( | const ActivationFunction & | new_activation_function | ) |
This method sets a new activation function in the neuron.
new_activation_function | Activation function. |
Definition at line 348 of file perceptron.cpp.
void OpenNN::Perceptron::set_activation_function | ( | const std::string & | new_activation_function_name | ) |
This method sets a new activation function in the perceptron with a string containing the name of the activation function.
new_activation_function_name | String with name of activation function. |
Definition at line 360 of file perceptron.cpp.
void OpenNN::Perceptron::set_bias | ( | const double & | new_bias | ) |
This method sets a new bias value for the perceptron.
new_bias | Bias value. |
Definition at line 400 of file perceptron.cpp.
void OpenNN::Perceptron::set_synaptic_weights | ( | const Vector< double > & | new_synaptic_weights | ) |
This method a new set of synaptic weights for the perceptron.
new_synaptic_weights | Synaptic weight values. |
Definition at line 411 of file perceptron.cpp.
void OpenNN::Perceptron::set_synaptic_weight | ( | const unsigned int & | synaptic_weight_index, | |
const double & | new_synaptic_weight | |||
) |
This method sets the synaptic weight value with index i for the neuron.
synaptic_weight_index | Synaptic weight index. | |
new_synaptic_weight | Synaptic weight value. |
Definition at line 444 of file perceptron.cpp.
void OpenNN::Perceptron::set_parameters | ( | const Vector< double > & | new_parameters | ) |
This method set a new set of parameters (bias and synaptic weights) to the perceptron.
new_parameters | New set of parameters |
Definition at line 540 of file perceptron.cpp.
void OpenNN::Perceptron::set_display | ( | const bool & | new_display | ) |
This method 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.
new_display | Display value. |
Definition at line 478 of file perceptron.cpp.
void OpenNN::Perceptron::initialize_bias | ( | const double & | value | ) |
This method initializes the bias with a given value.
value | Initialization value. |
Definition at line 577 of file perceptron.cpp.
void OpenNN::Perceptron::initialize_bias_uniform | ( | const double & | minimum, | |
const double & | maximum | |||
) |
This method initializes the neuron's bias with a random value chosen from a uniform distribution.
minimum | Minimum initialization value. | |
maximum | Maximum initialization value. |
Definition at line 589 of file perceptron.cpp.
void OpenNN::Perceptron::initialize_bias_normal | ( | const double & | mean, | |
const double & | standard_deviation | |||
) |
This method initializes the neuron's bias with random values chosen from a normal distribution.
mean | Mean of normal distribution. | |
standard_deviation | Standard deviation of normal distribution. |
Definition at line 641 of file perceptron.cpp.
void OpenNN::Perceptron::initialize_synaptic_weights | ( | const double & | value | ) |
This method initializes all the synaptic weights of the neuron with a given value.
value | Initialization value. |
Definition at line 617 of file perceptron.cpp.
void OpenNN::Perceptron::initialize_synaptic_weights_uniform | ( | const double & | minimum, | |
const double & | maximum | |||
) |
This method initializes the neuron's synaptic weights with random values chosen from an uniform distribution.
minimum | Minimum initialization value. | |
maximum | Maximum initialization value. |
Definition at line 629 of file perceptron.cpp.
void OpenNN::Perceptron::initialize_synaptic_weights_normal | ( | const double & | mean, | |
const double & | standard_deviation | |||
) |
This method initializes the neuron's synaptic weights with random values chosen from a normal distribution.
mean | Mean of normal distribution. | |
standard_deviation | Standard deviation of normal distribution. |
Definition at line 670 of file perceptron.cpp.
void OpenNN::Perceptron::initialize_parameters | ( | const double & | value | ) |
This method initializes the bias and the synaptic weights with a given value.
value | Parameters initialization value. |
Definition at line 681 of file perceptron.cpp.
double OpenNN::Perceptron::calculate_combination | ( | const Vector< double > & | inputs | ) | const |
This method returns the combination to the neuron for a set of inputs signals, using the dot product combination function.
inputs | Set of inputs signals to the neuron. |
Definition at line 694 of file perceptron.cpp.
double OpenNN::Perceptron::calculate_combination_parameters | ( | const Vector< double > & | inputs, | |
const Vector< double > & | parameters | |||
) | const |
This method returns which would be the combination for some inputs and for a potential set of parameters.
inputs | Vector of inputs to the perceptron. | |
parameters | Potential bias and synaptic weights in the perceptron. |
Definition at line 740 of file perceptron.cpp.
Vector< double > OpenNN::Perceptron::calculate_combination_gradient | ( | const Vector< double > & | ) | const |
This method returns the partial derivatives of the combination with respect to the inputs.
Definition at line 1202 of file perceptron.cpp.
Matrix< double > OpenNN::Perceptron::calculate_combination_Hessian | ( | const Vector< double > & | ) | const |
This method retuns the second derivatives of the combination with respect to the inputs.
Definition at line 1362 of file perceptron.cpp.
Vector< double > OpenNN::Perceptron::calculate_combination_parameters_gradient | ( | const Vector< double > & | inputs | ) | const |
This method returns the partial derivatives of the combination with respect to the parameters at some inputs point.
inputs | Vector of inputs to the perceptron. |
Definition at line 1213 of file perceptron.cpp.
Matrix< double > OpenNN::Perceptron::calculate_combination_parameters_Hessian | ( | const Vector< double > & | ) | const |
This method retuns the second derivatives of the combination with respect to the parameters.
Definition at line 1376 of file perceptron.cpp.
double OpenNN::Perceptron::calculate_activation | ( | const double & | combination | ) | const |
This method returns the activation from the neuron for a combination. The outputs depends on the activation function used.
combination | Combination of the neuron. |
Definition at line 795 of file perceptron.cpp.
double OpenNN::Perceptron::calculate_activation_derivative | ( | const double & | combination | ) | const |
This method returns the activation derivative of the neuron for a combination. The activation derivative depends on the activation function used.
combination | Combination of the neuron. |
Definition at line 864 of file perceptron.cpp.
double OpenNN::Perceptron::calculate_activation_second_derivative | ( | const double & | combination | ) | const |
This method returns the activation second derivative of the neuron for a combination. The second derivative of the outputs depends on the activation function used.
combination | Combination of the neuron. |
Definition at line 947 of file perceptron.cpp.
double OpenNN::Perceptron::calculate_outputs | ( | const Vector< double > & | inputs | ) | const |
This method returns the outputs from the neuron for a set of inputs signals. The outputs depends on the activation function used.
inputs | Set of inputs signals to the neuron. |
Definition at line 1030 of file perceptron.cpp.
This method returns the partial derivatives of the outputs with respect to the inputs.
inputs | Vector of inputs to the perceptron. |
Definition at line 1115 of file perceptron.cpp.
This method returns the second partial derivatives of the outputs with respect to the inputs.
inputs | Vector of inputs to the perceptron. |
Definition at line 1260 of file perceptron.cpp.
double OpenNN::Perceptron::calculate_parameters_output | ( | const Vector< double > & | inputs, | |
const Vector< double > & | parameters | |||
) | const |
This method returns the outputs from the neuron for a set of inputs. The outputs depends on the activation function used.
inputs | Set of inputs signals to the neuron. | |
parameters | Set of potential bias and synaptic weights in the perceptron. |
Definition at line 1065 of file perceptron.cpp.
Vector< double > OpenNN::Perceptron::calculate_parameters_gradient | ( | const Vector< double > & | inputs | ) | const |
This method returns the partial derivatives of the outputs with respect to the parameters at some inputs point.
inputs | Vector of inputs to the perceptron. |
Definition at line 1152 of file perceptron.cpp.
Matrix< double > OpenNN::Perceptron::calculate_parameters_Hessian | ( | const Vector< double > & | inputs | ) | const |
This method retuns the second derivatives of the outputs with respect to the parameters at some inputs point.
inputs | Input vector. |
Definition at line 1294 of file perceptron.cpp.
void OpenNN::Perceptron::grow_input | ( | void | ) |
This method makes the perceptron to have one more input. The corresponding synaptic weight is initialized to zero.
Definition at line 1391 of file perceptron.cpp.
void OpenNN::Perceptron::prune_input | ( | const unsigned int & | index | ) |
This method removes a given input from the neuron.
index | Index of input to be removed. |
Definition at line 1402 of file perceptron.cpp.
std::string OpenNN::Perceptron::write_expression | ( | const Vector< std::string > & | inputs_name, | |
const std::string & | output_name | |||
) | const |
This method returns a string with the mathematical expression represented by the perceptron.
inputs_name | Name of input variables to the neuron. | |
output_name | Name of output variable from the neuron. |
Definition at line 1414 of file perceptron.cpp.