OpenNN  2.2
Open Neural Networks Library
bounding_layer.h
1 /****************************************************************************************************************/
2 /* */
3 /* OpenNN: Open Neural Networks Library */
4 /* www.artelnics.com/opennn */
5 /* */
6 /* B O U N D I N G L A Y E R C L A S S H E A D E R */
7 /* */
8 /* Roberto Lopez */
9 /* Artelnics - Making intelligent use of data */
11 /* */
12 /****************************************************************************************************************/
13 
14 #ifndef __BOUNDINGLAYER_H__
15 #define __BOUNDINGLAYER_H__
16 
17 // System includes
18 
19 #include <cmath>
20 #include <cstdlib>
21 #include <fstream>
22 #include <iostream>
23 #include <string>
24 #include <sstream>
25 
26 // OpenNN includes
27 
28 #include "vector.h"
29 #include "matrix.h"
30 
31 // TinyXml includes
32 
33 #include "../tinyxml2/tinyxml2.h"
34 
35 namespace OpenNN
36 {
37 
40 
42 {
43 
44 public:
45 
46  // DEFAULT CONSTRUCTOR
47 
48  explicit BoundingLayer(void);
49 
50  // BOUNDING NEURONS NUMBER CONSTRUCTOR
51 
52  explicit BoundingLayer(const size_t&);
53 
54  // XML CONSTRUCTOR
55 
56  explicit BoundingLayer(const tinyxml2::XMLDocument&);
57 
58  // COPY CONSTRUCTOR
59 
61 
62  // DESTRUCTOR
63 
64  virtual ~BoundingLayer(void);
65 
66  // ASSIGNMENT OPERATOR
67 
69 
70  // EQUAL TO OPERATOR
71 
72  bool operator == (const BoundingLayer&) const;
73 
74  // ENUMERATIONS
75 
77 
78  enum BoundingMethod{NoBounding, Boundind};
79 
80  // METHODS
81 
82  bool is_empty(void) const;
83 
84  size_t get_bounding_neurons_number(void) const;
85 
86  // Variables bounds
87 
88  const Vector<double>& get_lower_bounds(void) const;
89  double get_lower_bound(const size_t&) const;
90 
91  const Vector<double>& get_upper_bounds(void) const;
92  double get_upper_bound(const size_t&) const;
93 
95 
96  // Variables bounds
97 
98  void set(void);
99  void set(const size_t&);
100  void set(const tinyxml2::XMLDocument&);
101  void set(const BoundingLayer&);
102 
103  void set_lower_bounds(const Vector<double>&);
104  void set_lower_bound(const size_t&, const double&);
105 
106  void set_upper_bounds(const Vector<double>&);
107  void set_upper_bound(const size_t&, const double&);
108 
109  void set_bounds(const Vector< Vector<double> >&);
110 
111  void set_display(const bool&);
112 
113  void set_default(void);
114 
115  // Pruning and growing
116 
117  void prune_bounding_neuron(const size_t&);
118 
119  // Initialization
120 
121  void initialize_random(void);
122 
123  // Lower and upper bounds
124 
128 
131 
132  // Expression methods
133 
134  std::string write_expression(const Vector<std::string>&, const Vector<std::string>&) const;
135 
136  // Serialization methods
137 
138  std::string to_string(void) const;
139 
140  tinyxml2::XMLDocument* to_XML(void) const;
141  void from_XML(const tinyxml2::XMLDocument&);
142 
143 protected:
144 
145  // MEMBERS
146 
148 
150 
152 
154 
156 
157  bool display;
158 };
159 
160 }
161 
162 #endif
163 
164 
165 // OpenNN: Open Neural Networks Library.
166 // Copyright (c) 2005-2015 Roberto Lopez.
167 //
168 // This library is free software; you can redistribute it and/or
169 // modify it under the terms of the GNU Lesser General Public
170 // License as published by the Free Software Foundation; either
171 // version 2.1 of the License, or any later version.
172 //
173 // This library is distributed in the hope that it will be useful,
174 // but WITHOUT ANY WARRANTY; without even the implied warranty of
175 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
176 // Lesser General Public License for more details.
177 
178 // You should have received a copy of the GNU Lesser General Public
179 // License along with this library; if not, write to the Free Software
180 
181 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
182 
std::string to_string(void) const
Returns a string representation of the current bonding layer object.
Vector< Matrix< double > > arrange_Hessian_form(const Vector< double > &) const
tinyxml2::XMLDocument * to_XML(void) const
void set_display(const bool &)
Vector< double > calculate_derivative(const Vector< double > &) const
const Vector< double > & get_upper_bounds(void) const
Returns the upper bounds values of all the bounding neurons in the layer.
Matrix< double > arrange_Jacobian(const Vector< double > &) const
bool display
Display messages to screen.
void from_XML(const tinyxml2::XMLDocument &)
bool is_empty(void) const
Returns true if the size of the layer is zero, and false otherwise.
bool operator==(const BoundingLayer &) const
size_t get_bounding_neurons_number(void) const
Returns the number of bounding neurons in the layer.
std::string write_expression(const Vector< std::string > &, const Vector< std::string > &) const
Returns a string with the expression of the lower and upper bounds functions.
BoundingMethod
Enumeration of available methods for bounding the output variables.
void set_lower_bounds(const Vector< double > &)
void set_bounds(const Vector< Vector< double > > &)
Vector< double > calculate_outputs(const Vector< double > &) const
void set_upper_bounds(const Vector< double > &)
double get_lower_bound(const size_t &) const
Vector< double > lower_bounds
Lower bounds of output variables.
Vector< double > calculate_second_derivative(const Vector< double > &) const
Vector< Vector< double > * > get_bounds(void)
void initialize_random(void)
Initializes the lower and upper bounds of all the bounding neurons with random values.
void set_lower_bound(const size_t &, const double &)
Vector< double > upper_bounds
Upper bounds of output variables.
virtual ~BoundingLayer(void)
void prune_bounding_neuron(const size_t &)
const Vector< double > & get_lower_bounds(void) const
Returns the lower bounds values of all the bounding neurons in the layer.
double get_upper_bound(const size_t &) const
void set_upper_bound(const size_t &, const double &)
BoundingLayer & operator=(const BoundingLayer &)