BoundingLayer Class Reference

This class represents a layer of bounding neurons. More...

#include <bounding_layer.h>

Inheritance diagram for BoundingLayer:
Layer

Public Types

enum class  BoundingMethod { NoBounding , Bounding }
 Enumeration of available methods for bounding the output variables. More...
 
- Public Types inherited from Layer
enum class  Type {
  Scaling , Convolutional , Perceptron , Pooling ,
  Probabilistic , LongShortTermMemory , Recurrent , Unscaling ,
  Bounding
}
 This enumeration represents the possible types of layers. More...
 

Public Member Functions

 BoundingLayer ()
 
 BoundingLayer (const Index &)
 
virtual ~BoundingLayer ()
 
bool is_empty () const
 Returns true if the size of the layer is zero, and false otherwise. More...
 
Index get_inputs_number () const
 Get number of inputs. More...
 
Index get_neurons_number () const
 Return the neurons number in the bounding layer. More...
 
const BoundingMethodget_bounding_method () const
 Returns the method used for bounding layer. More...
 
string write_bounding_method () const
 Returns a string writing if use bounding layer or not. More...
 
const Tensor< type, 1 > & get_lower_bounds () const
 Returns the lower bounds values of all the bounding neurons in the layer. More...
 
type get_lower_bound (const Index &) const
 
const Tensor< type, 1 > & get_upper_bounds () const
 Returns the upper bounds values of all the bounding neurons in the layer. More...
 
type get_upper_bound (const Index &) const
 
void set ()
 
void set (const Index &)
 
void set (const tinyxml2::XMLDocument &)
 
void set (const BoundingLayer &)
 
void set_inputs_number (const Index &)
 
void set_neurons_number (const Index &)
 
void set_bounding_method (const BoundingMethod &)
 
void set_bounding_method (const string &)
 
void set_lower_bounds (const Tensor< type, 1 > &)
 
void set_lower_bound (const Index &, const type &)
 
void set_upper_bounds (const Tensor< type, 1 > &)
 
void set_upper_bound (const Index &, const type &)
 
void set_display (const bool &)
 
void set_default ()
 
Tensor< type, 2 > calculate_outputs (const Tensor< type, 2 > &)
 
string write_expression (const Tensor< string, 1 > &, const Tensor< string, 1 > &) const
 Returns a string with the expression of the lower and upper bounds functions. More...
 
string write_expression_c () const
 BoundingLayer::write_expression_c. More...
 
string write_expression_python () const
 BoundingLayer::write_expression_python. More...
 
void from_XML (const tinyxml2::XMLDocument &)
 
void write_XML (tinyxml2::XMLPrinter &) const
 
- Public Member Functions inherited from Layer
string get_name () const
 
virtual void set_parameters_constant (const type &)
 
virtual void set_parameters_random ()
 
virtual Tensor< type, 1 > get_parameters () const
 
virtual Index get_parameters_number () const
 
virtual void set_parameters (const Tensor< type, 1 > &, const Index &)
 
void set_threads_number (const int &)
 
virtual void insert_gradient (LayerBackPropagation *, const Index &, Tensor< type, 1 > &) const
 
virtual Tensor< type, 2 > calculate_outputs_from4D (const Tensor< type, 4 > &)
 
virtual Tensor< type, 4 > calculate_outputs_4d (const Tensor< type, 4 > &)
 
virtual void forward_propagate (const Tensor< type, 2 > &, LayerForwardPropagation *)
 
virtual void forward_propagate (const Tensor< type, 4 > &, LayerForwardPropagation *)
 
virtual void forward_propagate (const Tensor< type, 4 > &, Tensor< type, 1 >, LayerForwardPropagation *)
 
virtual void forward_propagate (const Tensor< type, 2 > &, Tensor< type, 1 >, LayerForwardPropagation *)
 
virtual void calculate_hidden_delta (LayerForwardPropagation *, LayerBackPropagation *, LayerForwardPropagation *, LayerBackPropagation *) const
 
virtual void calculate_hidden_delta_lm (LayerForwardPropagation *, LayerBackPropagationLM *, LayerBackPropagationLM *) const
 
virtual void calculate_error_gradient (const Tensor< type, 2 > &, LayerForwardPropagation *, LayerBackPropagation *) const
 
virtual void calculate_error_gradient (const Tensor< type, 4 > &, LayerForwardPropagation *, LayerBackPropagation *) const
 
virtual void calculate_squared_errors_Jacobian_lm (const Tensor< type, 2 > &, LayerForwardPropagation *, LayerBackPropagationLM *)
 
virtual void insert_squared_errors_Jacobian_lm (LayerBackPropagationLM *, const Index &, Tensor< type, 2 > &) const
 
virtual Index get_synaptic_weights_number () const
 Returns the number of layer's synaptic weights. More...
 
Type get_type () const
 
string get_type_string () const
 Takes the type of layer used by the model. More...
 

Protected Attributes

BoundingMethod bounding_method = BoundingMethod::Bounding
 Method used to bound the values. More...
 
Tensor< type, 1 > lower_bounds
 Lower bounds of output variables. More...
 
Tensor< type, 1 > upper_bounds
 Upper bounds of output variables. More...
 
bool display = true
 Display messages to screen. More...
 
- Protected Attributes inherited from Layer
ThreadPool * thread_pool = nullptr
 
ThreadPoolDevice * thread_pool_device = nullptr
 
string layer_name = "layer"
 Layer name. More...
 
Type layer_type = Type::Perceptron
 Layer type. More...
 
const Eigen::array< IndexPair< Index >, 1 > A_BT = {IndexPair<Index>(1, 1)}
 
const Eigen::array< IndexPair< Index >, 1 > AT_B = {IndexPair<Index>(0, 0)}
 
const Eigen::array< IndexPair< Index >, 1 > A_B = {IndexPair<Index>(1, 0)}
 

Additional Inherited Members

- Protected Member Functions inherited from Layer
void hard_sigmoid (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void hyperbolic_tangent (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void logistic (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void linear (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void threshold (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void symmetric_threshold (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void rectified_linear (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void scaled_exponential_linear (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void soft_plus (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void soft_sign (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void exponential_linear (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void softmax (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void binary (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void competitive (const Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void hard_sigmoid_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void hyperbolic_tangent_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void linear_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void logistic_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void threshold_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void symmetric_threshold_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void rectified_linear_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void scaled_exponential_linear_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void soft_plus_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void soft_sign_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void exponential_linear_derivatives (const Tensor< type, 1 > &, Tensor< type, 1 > &, Tensor< type, 1 > &) const
 
void hard_sigmoid (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void hyperbolic_tangent (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void logistic (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void linear (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void threshold (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void symmetric_threshold (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void rectified_linear (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void scaled_exponential_linear (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void soft_plus (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void soft_sign (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void exponential_linear (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void softmax (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void binary (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void competitive (const Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void hard_sigmoid_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void hyperbolic_tangent_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void linear_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void logistic_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void threshold_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void symmetric_threshold_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void rectified_linear_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void scaled_exponential_linear_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void soft_plus_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void soft_sign_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void exponential_linear_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 2 > &) const
 
void logistic_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 3 > &) const
 
void softmax_derivatives (const Tensor< type, 2 > &, Tensor< type, 2 > &, Tensor< type, 3 > &) const
 
void linear (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void logistic (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void hyperbolic_tangent (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void threshold (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void symmetric_threshold (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void rectified_linear (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void scaled_exponential_linear (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void soft_plus (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void soft_sign (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void hard_sigmoid (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void exponential_linear (const Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void linear_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void logistic_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void hyperbolic_tangent_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void threshold_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void symmetric_threshold_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void rectified_linear_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void scaled_exponential_linear_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void soft_plus_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void soft_sign_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void hard_sigmoid_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 
void exponential_linear_derivatives (const Tensor< type, 4 > &, Tensor< type, 4 > &, Tensor< type, 4 > &) const
 

Detailed Description

This class represents a layer of bounding neurons.

A bounding layer is used to ensure that variables will never fall below or above given values.

Definition at line 34 of file bounding_layer.h.

Member Enumeration Documentation

◆ BoundingMethod

enum class BoundingMethod
strong

Enumeration of available methods for bounding the output variables.

Definition at line 53 of file bounding_layer.h.

Constructor & Destructor Documentation

◆ BoundingLayer() [1/2]

BoundingLayer ( )
explicit

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

Definition at line 17 of file bounding_layer.cpp.

◆ BoundingLayer() [2/2]

BoundingLayer ( const Index &  neurons_number)
explicit

Bounding neurons number constructor. It creates a bounding layer with a given size.

Parameters
neurons_numberNumber of bounding neurons in the layer.

Definition at line 29 of file bounding_layer.cpp.

◆ ~BoundingLayer()

~BoundingLayer ( )
virtual

Destructor. This destructor does not delete any pointer.

Definition at line 40 of file bounding_layer.cpp.

Member Function Documentation

◆ calculate_outputs()

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

Calculates the outputs from the bounding layer for a set of inputs to that layer.

Parameters
inputsSet of inputs to the bounding layer.

Reimplemented from Layer.

Definition at line 438 of file bounding_layer.cpp.

◆ from_XML()

void from_XML ( const tinyxml2::XMLDocument document)
virtual

Deserializes a TinyXML document into this bounding layer object.

Parameters
documentTinyXML document containing the member data.

Reimplemented from Layer.

Definition at line 690 of file bounding_layer.cpp.

◆ get_bounding_method()

const BoundingLayer::BoundingMethod & get_bounding_method ( ) const

Returns the method used for bounding layer.

Definition at line 62 of file bounding_layer.cpp.

◆ get_inputs_number()

Index get_inputs_number ( ) const
virtual

Get number of inputs.

Reimplemented from Layer.

Definition at line 94 of file bounding_layer.cpp.

◆ get_lower_bound()

type get_lower_bound ( const Index &  i) const

Returns the lower bound value of a single bounding neuron.

Parameters
iIndex of bounding neuron.

Definition at line 119 of file bounding_layer.cpp.

◆ get_lower_bounds()

const Tensor< type, 1 > & get_lower_bounds ( ) const

Returns the lower bounds values of all the bounding neurons in the layer.

Definition at line 110 of file bounding_layer.cpp.

◆ get_neurons_number()

Index get_neurons_number ( ) const
virtual

Return the neurons number in the bounding layer.

Reimplemented from Layer.

Definition at line 102 of file bounding_layer.cpp.

◆ get_upper_bound()

type get_upper_bound ( const Index &  i) const

Returns the upper bound value of a single bounding neuron.

Parameters
iIndex of bounding neuron.

Definition at line 153 of file bounding_layer.cpp.

◆ get_upper_bounds()

const Tensor< type, 1 > & get_upper_bounds ( ) const

Returns the upper bounds values of all the bounding neurons in the layer.

Definition at line 144 of file bounding_layer.cpp.

◆ is_empty()

bool is_empty ( ) const

Returns true if the size of the layer is zero, and false otherwise.

Definition at line 47 of file bounding_layer.cpp.

◆ set() [1/4]

void set ( )

Sets the number of bounding neurons to be zero. It also sets the rest of memebers to their default values.

Definition at line 189 of file bounding_layer.cpp.

◆ set() [2/4]

void set ( const BoundingLayer other_bounding_layer)

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

Parameters
other_bounding_layerObject to be copied.

Definition at line 249 of file bounding_layer.cpp.

◆ set() [3/4]

void set ( const Index &  new_neurons_number)

Resizes the bounding layer. It also sets the rest of memebers to their default values.

Parameters
new_neurons_numberSize of the bounding layer.

Definition at line 204 of file bounding_layer.cpp.

◆ set() [4/4]

void set ( const tinyxml2::XMLDocument bounding_layer_document)

Sets the bounding layer members from a XML document.

Parameters
bounding_layer_documentPointer to a TinyXML document containing the member data.

Definition at line 238 of file bounding_layer.cpp.

◆ set_bounding_method() [1/2]

void set_bounding_method ( const BoundingMethod new_method)

Sets a new bounding method.

Parameters
new_methodNew bounding method.

Definition at line 262 of file bounding_layer.cpp.

◆ set_bounding_method() [2/2]

void set_bounding_method ( const string &  new_method_string)

Sets a new bounding method.

Parameters
new_method_stringNew bounding method string.

Definition at line 271 of file bounding_layer.cpp.

◆ set_default()

void set_default ( )

Sets the members to their default values:

  • Display: True.

Definition at line 425 of file bounding_layer.cpp.

◆ set_display()

void set_display ( const bool &  new_display)

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

Parameters
new_displayDisplay value.

Definition at line 414 of file bounding_layer.cpp.

◆ set_inputs_number()

void set_inputs_number ( const Index &  new_inputs_number)
virtual

Resize the number of inputs.

Parameters
new_inputs_numberSize of the inputs array.

Reimplemented from Layer.

Definition at line 215 of file bounding_layer.cpp.

◆ set_lower_bound()

void set_lower_bound ( const Index &  index,
const type &  new_lower_bound 
)

Sets a new lower bound for a single neuron. This value is used for unscaling that variable so that it is not less than the lower bound.

Parameters
indexIndex of bounding neuron.
new_lower_boundNew lower bound for the neuron with index i.

Definition at line 327 of file bounding_layer.cpp.

◆ set_lower_bounds()

void set_lower_bounds ( const Tensor< type, 1 > &  new_lower_bounds)

Sets new lower bounds for all the neurons in the layer.

Parameters
new_lower_boundsNew set of lower bounds for the bounding neurons.

Definition at line 297 of file bounding_layer.cpp.

◆ set_neurons_number()

void set_neurons_number ( const Index &  new_neurons_number)
virtual

Resize the number of bound neurons from the bounding layer.

Parameters
new_neurons_numberNumber of the neurons from the bounding layer.

Reimplemented from Layer.

Definition at line 225 of file bounding_layer.cpp.

◆ set_upper_bound()

void set_upper_bound ( const Index &  index,
const type &  new_upper_bound 
)

Sets a new upper bound for a single neuron. This value is used for unscaling that variable so that it is not greater than the upper bound.

Parameters
indexIndex of bounding neuron.
new_upper_boundNew upper bound for the bounding neuron with that index.

Definition at line 379 of file bounding_layer.cpp.

◆ set_upper_bounds()

void set_upper_bounds ( const Tensor< type, 1 > &  new_upper_bounds)

Sets new upper bounds for all the bounding neurons. These values are used for unscaling variables so that they are not greater than the upper bounds.

Parameters
new_upper_boundsNew set of upper bounds for the layer.

Definition at line 362 of file bounding_layer.cpp.

◆ write_bounding_method()

string write_bounding_method ( ) const

Returns a string writing if use bounding layer or not.

Definition at line 69 of file bounding_layer.cpp.

◆ write_expression()

string write_expression ( const Tensor< string, 1 > &  inputs_names,
const Tensor< string, 1 > &  outputs_names 
) const
virtual

Returns a string with the expression of the lower and upper bounds functions.

Reimplemented from Layer.

Definition at line 475 of file bounding_layer.cpp.

◆ write_expression_c()

string write_expression_c ( ) const
virtual

BoundingLayer::write_expression_c.

Returns

Reimplemented from Layer.

Definition at line 504 of file bounding_layer.cpp.

◆ write_expression_python()

string write_expression_python ( ) const
virtual

BoundingLayer::write_expression_python.

Returns

Reimplemented from Layer.

Definition at line 551 of file bounding_layer.cpp.

◆ write_XML()

void write_XML ( tinyxml2::XMLPrinter file_stream) const
virtual

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

Reimplemented from Layer.

Definition at line 590 of file bounding_layer.cpp.

Member Data Documentation

◆ bounding_method

BoundingMethod bounding_method = BoundingMethod::Bounding
protected

Method used to bound the values.

Definition at line 121 of file bounding_layer.h.

◆ display

bool display = true
protected

Display messages to screen.

Definition at line 133 of file bounding_layer.h.

◆ lower_bounds

Tensor<type, 1> lower_bounds
protected

Lower bounds of output variables.

Definition at line 125 of file bounding_layer.h.

◆ upper_bounds

Tensor<type, 1> upper_bounds
protected

Upper bounds of output variables.

Definition at line 129 of file bounding_layer.h.


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