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

#include <probabilistic_layer.h>

Public Types

enum  ProbabilisticMethod { Competitive, Softmax, NoProbabilistic }
 

Public Member Functions

 ProbabilisticLayer (void)
 
 ProbabilisticLayer (const size_t &)
 
 ProbabilisticLayer (const ProbabilisticLayer &)
 
virtual ~ProbabilisticLayer (void)
 
ProbabilisticLayeroperator= (const ProbabilisticLayer &)
 
bool operator== (const ProbabilisticLayer &) const
 
const size_t & get_probabilistic_neurons_number (void) const
 
const ProbabilisticMethodget_probabilistic_method (void) const
 
std::string write_probabilistic_method (void) const
 
std::string write_probabilistic_method_text (void) const
 
const bool & get_display (void) const
 
void set (void)
 
void set (const size_t &)
 
void set (const ProbabilisticLayer &)
 
void set_probabilistic_neurons_number (const size_t &)
 
void set_probabilistic_method (const ProbabilisticMethod &)
 
void set_probabilistic_method (const std::string &)
 
virtual void set_default (void)
 
void set_display (const bool &)
 
void prune_probabilistic_neuron (void)
 
void initialize_random (void)
 
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_competitive_output (const Vector< double > &) const
 
Matrix< double > calculate_competitive_Jacobian (const Vector< double > &) const
 
Vector< Matrix< double > > calculate_competitive_Hessian_form (const Vector< double > &) const
 
Vector< double > calculate_softmax_output (const Vector< double > &) const
 
Matrix< double > calculate_softmax_Jacobian (const Vector< double > &) const
 
Vector< Matrix< double > > calculate_softmax_Hessian_form (const Vector< double > &) const
 
Vector< double > calculate_no_probabilistic_output (const Vector< double > &) const
 
Matrix< double > calculate_no_probabilistic_Jacobian (const Vector< double > &) const
 
Vector< Matrix< double > > calculate_no_probabilistic_Hessian_form (const Vector< double > &) const
 
std::string write_competitive_expression (const Vector< std::string > &, const Vector< std::string > &) const
 
std::string write_softmax_expression (const Vector< std::string > &, const Vector< std::string > &) const
 
std::string write_no_probabilistic_expression (const Vector< std::string > &, const Vector< std::string > &) const
 
std::string write_expression (const Vector< std::string > &, const Vector< std::string > &) const
 
std::string to_string (void) const
 
virtual tinyxml2::XMLDocument * to_XML (void) const
 
virtual void from_XML (const tinyxml2::XMLDocument &)
 

Protected Attributes

size_t probabilistic_neurons_number
 
ProbabilisticMethod probabilistic_method
 
bool display
 

Detailed Description

This class represents a layer of probabilistic neurons. The neural network defined in OpenNN includes a probabilistic layer for those problems when the outptus are to be interpreted as probabilities.

Definition at line 42 of file probabilistic_layer.h.

Constructor & Destructor Documentation

OpenNN::ProbabilisticLayer::ProbabilisticLayer ( void  )
explicit

Default constructor. It creates a probabilistic layer object with zero probabilistic neurons.

Definition at line 26 of file probabilistic_layer.cpp.

OpenNN::ProbabilisticLayer::ProbabilisticLayer ( const size_t &  new_probabilistic_neurons_number)
explicit

Probabilistic neurons number constructor. It creates a probabilistic layer with a given size.

Parameters
new_probabilistic_neurons_numberNumber of neurons in the layer.

Definition at line 38 of file probabilistic_layer.cpp.

OpenNN::ProbabilisticLayer::ProbabilisticLayer ( const ProbabilisticLayer other_probabilistic_layer)

Copy constructor. It creates a copy of an existing probabilistic layer object.

Parameters
other_probabilistic_layerProbabilistic layer to be copied.

Definition at line 50 of file probabilistic_layer.cpp.

OpenNN::ProbabilisticLayer::~ProbabilisticLayer ( void  )
virtual

Destructor. This destructor does not delete any pointer.

Definition at line 61 of file probabilistic_layer.cpp.

Member Function Documentation

Vector< double > OpenNN::ProbabilisticLayer::calculate_competitive_output ( const Vector< double > &  inputs) const

Returns the outputs from the layer for given inputs when the probabilistic method is the competitive.

Parameters
inputsVector of input values to the probabilistic layer.

Definition at line 602 of file probabilistic_layer.cpp.

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

Calculates the Hessian form of the probabilistic layer. This is a vector of matrices. The elements contain second partial derivatives of the outputs from the layer with resptect to the inputs to it.

Definition at line 540 of file probabilistic_layer.cpp.

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

Returns the partial derivatives of the outputs from the probabilistic layer with respect to its inputs, depending on the probabilistic method to be used. This quantity is the Jacobian matrix of the probabilistic function.

Parameters
inputsInputs to the probabilistic layer.

Definition at line 477 of file probabilistic_layer.cpp.

Vector< Matrix< double > > OpenNN::ProbabilisticLayer::calculate_no_probabilistic_Hessian_form ( const Vector< double > &  ) const

Returns the second partial derivatives of the no probabilistic outputs with respect to the inputs, in the so called Hessian form.

Todo:

Definition at line 728 of file probabilistic_layer.cpp.

Matrix< double > OpenNN::ProbabilisticLayer::calculate_no_probabilistic_Jacobian ( const Vector< double > &  ) const

Returns the partial derivatives of the no probabilistic outputs with respect to the inputs. This is just the identity matrix of size the number of probabilistic neurons.

Definition at line 712 of file probabilistic_layer.cpp.

Vector< double > OpenNN::ProbabilisticLayer::calculate_no_probabilistic_output ( const Vector< double > &  inputs) const

Returns the outputs of the no probabilistic function for given inputs. This is just the identity function.

Parameters
inputsInput values to the probabilistic layer.

Definition at line 701 of file probabilistic_layer.cpp.

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

This method processes the input to the probabilistic layer in order to obtain a set of outputs which can be interpreted as probabilities. This posprocessing is performed according to the probabilistic method to be used.

Parameters
inputsSet of inputs to the probabilistic layer.

Definition at line 413 of file probabilistic_layer.cpp.

Vector< Matrix< double > > OpenNN::ProbabilisticLayer::calculate_softmax_Hessian_form ( const Vector< double > &  ) const

Returns the second partial derivatives of the softmax outputs with respect to the inputs, in the so called Hessian form.

Todo:

Definition at line 687 of file probabilistic_layer.cpp.

Matrix< double > OpenNN::ProbabilisticLayer::calculate_softmax_Jacobian ( const Vector< double > &  inputs) const

Returns the partial derivatives of the softmax outputs with respect to the inputs.

Parameters
inputsInput values to the probabilistic layer.

Definition at line 656 of file probabilistic_layer.cpp.

Vector< double > OpenNN::ProbabilisticLayer::calculate_softmax_output ( const Vector< double > &  inputs) const

Returns the outputs of the softmax function for given inputs.

Parameters
inputsInput values to the probabilistic layer.

Definition at line 645 of file probabilistic_layer.cpp.

void OpenNN::ProbabilisticLayer::from_XML ( const tinyxml2::XMLDocument &  document)
virtual

Deserializes a TinyXML document into this probabilistic layer object.

Parameters
documentXML document containing the member data.

Definition at line 813 of file probabilistic_layer.cpp.

const bool & OpenNN::ProbabilisticLayer::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 203 of file probabilistic_layer.cpp.

const ProbabilisticLayer::ProbabilisticMethod & OpenNN::ProbabilisticLayer::get_probabilistic_method ( void  ) const

Returns the method to be used for interpreting the outputs as probabilistic values. The two methods available for that are Competitive and Softmax.

Definition at line 128 of file probabilistic_layer.cpp.

ProbabilisticLayer & OpenNN::ProbabilisticLayer::operator= ( const ProbabilisticLayer other_probabilistic_layer)

Assignment operator. It assigns to this object the members of an existing probabilistic layer object.

Parameters
other_probabilistic_layerProbabilistic layer object to be assigned.

Definition at line 72 of file probabilistic_layer.cpp.

bool OpenNN::ProbabilisticLayer::operator== ( const ProbabilisticLayer other_probabilistic_layer) 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_probabilistic_layer Probabilistic layer to be compared with.

Definition at line 96 of file probabilistic_layer.cpp.

void OpenNN::ProbabilisticLayer::prune_probabilistic_neuron ( void  )

Removes a probabilistic neuron from the probabilistic layer. As probabilistic neurons do not have any parameter, it does not matter which one is pruned.

Definition at line 341 of file probabilistic_layer.cpp.

void OpenNN::ProbabilisticLayer::set ( void  )

Sets a probabilistic layer with zero probabilistic neurons. It also sets the rest of members to their default values.

Definition at line 214 of file probabilistic_layer.cpp.

void OpenNN::ProbabilisticLayer::set ( const size_t &  new_probabilistic_neurons_number)

Resizes the size of the probabilistic layer. It also sets the rest of class members to their default values.

Parameters
new_probabilistic_neurons_numberNew size for the probabilistic layer.

Definition at line 228 of file probabilistic_layer.cpp.

void OpenNN::ProbabilisticLayer::set ( const ProbabilisticLayer other_probabilistic_layer)

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

Parameters
other_probabilistic_layerProbabilistic layer object to be copied.

Definition at line 241 of file probabilistic_layer.cpp.

void OpenNN::ProbabilisticLayer::set_default ( void  )
virtual

Sets the members to their default values:

  • Probabilistic method: Softmax.
  • Display: True.

Definition at line 270 of file probabilistic_layer.cpp.

void OpenNN::ProbabilisticLayer::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 330 of file probabilistic_layer.cpp.

void OpenNN::ProbabilisticLayer::set_probabilistic_method ( const ProbabilisticMethod new_probabilistic_method)

Sets the chosen method for probabilistic postprocessing. Current probabilistic methods include Competitive and Softmax.

Parameters
new_probabilistic_methodMethod for interpreting the outputs as probabilistic values.

Definition at line 284 of file probabilistic_layer.cpp.

void OpenNN::ProbabilisticLayer::set_probabilistic_method ( const std::string &  new_probabilistic_method)

Sets a new method for probabilistic processing from a string with the name. Current probabilistic methods include Competitive and Softmax.

Parameters
new_probabilistic_methodMethod for interpreting the outputs as probabilistic values.

Definition at line 296 of file probabilistic_layer.cpp.

void OpenNN::ProbabilisticLayer::set_probabilistic_neurons_number ( const size_t &  new_probabilistic_neurons_number)

Resizes the size of the probabilistic layer.

Parameters
new_probabilistic_neurons_numberNew size for the probabilistic layer.

Definition at line 256 of file probabilistic_layer.cpp.

tinyxml2::XMLDocument * OpenNN::ProbabilisticLayer::to_XML ( void  ) const
virtual

Serializes the probabilistic layer object into a XML document of the TinyXML library. See the OpenNN manual for more information about the format of this element.

Definition at line 758 of file probabilistic_layer.cpp.

std::string OpenNN::ProbabilisticLayer::write_competitive_expression ( const Vector< std::string > &  inputs_names,
const Vector< std::string > &  outputs_names 
) const

Returns a string with the expression of the competitive probabilistic outputs function.

Parameters
inputs_namesNames of inputs to the probabilistic layer.
outputs_namesNames of outputs to the probabilistic layer.

Definition at line 901 of file probabilistic_layer.cpp.

std::string OpenNN::ProbabilisticLayer::write_expression ( const Vector< std::string > &  inputs_names,
const Vector< std::string > &  outputs_names 
) const

Returns a string with the expression of the probabilistic outputs function, depending on the probabilistic method to be used.

Parameters
inputs_namesNames of inputs to the probabilistic layer.
outputs_namesNames of outputs to the probabilistic layer.

Definition at line 959 of file probabilistic_layer.cpp.

std::string OpenNN::ProbabilisticLayer::write_no_probabilistic_expression ( const Vector< std::string > &  inputs_names,
const Vector< std::string > &  outputs_names 
) const

Returns a string with the expression of the no probabilistic outputs function.

Parameters
inputs_namesNames of inputs to the probabilistic layer.
outputs_namesNames of outputs to the probabilistic layer.

Definition at line 939 of file probabilistic_layer.cpp.

std::string OpenNN::ProbabilisticLayer::write_probabilistic_method ( void  ) const

Returns a string with the probabilistic method for the outputs ("Competitive", "Softmax" or "NoProbabilistic").

Definition at line 139 of file probabilistic_layer.cpp.

std::string OpenNN::ProbabilisticLayer::write_probabilistic_method_text ( void  ) const

Returns a string with the probabilistic method for the outputs to be included in some text ("competitive", "softmax" or "no probabilistic").

Definition at line 171 of file probabilistic_layer.cpp.

std::string OpenNN::ProbabilisticLayer::write_softmax_expression ( const Vector< std::string > &  inputs_names,
const Vector< std::string > &  outputs_names 
) const

Returns a string with the expression of the softmax probabilistic outputs function.

Parameters
inputs_namesNames of inputs to the probabilistic layer.
outputs_namesNames of outputs to the probabilistic layer.

Definition at line 920 of file probabilistic_layer.cpp.


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