OpenNN  2.2
Open Neural Networks Library
unscaling_layer.h
1 /****************************************************************************************************************/
2 /* */
3 /* OpenNN: Open Neural Networks Library */
4 /* www.artelnics.com/opennn */
5 /* */
6 /* U N S C A L 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 __UNSCALINGLAYER_H__
15 #define __UNSCALINGLAYER_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 
36 namespace OpenNN
37 {
38 
42 
44 {
45 
46 public:
47 
48  // DEFAULT CONSTRUCTOR
49 
50  explicit UnscalingLayer(void);
51 
52  // UNSCALING NEURONS NUMBER CONSTRUCTOR
53 
54  explicit UnscalingLayer(const size_t&);
55 
56  // STATISTICS CONSTRUCTOR
57 
58  explicit UnscalingLayer(const Vector< Statistics<double> >&);
59 
60  // XML CONSTRUCTOR
61 
62  explicit UnscalingLayer(const tinyxml2::XMLDocument&);
63 
64  // COPY CONSTRUCTOR
65 
67 
68  // DESTRUCTOR
69 
70  virtual ~UnscalingLayer(void);
71 
72  // ASSIGNMENT OPERATOR
73 
75 
76  // EQUAL TO OPERATOR
77 
78  bool operator == (const UnscalingLayer&) const;
79 
80  // ENUMERATIONS
81 
83 
84  enum UnscalingMethod{NoUnscaling, MinimumMaximum, MeanStandardDeviation};
85 
86  // GET METHODS
87 
88  // Outputs number
89 
90  size_t get_unscaling_neurons_number(void) const;
91 
92  // Output variables statistics
93 
95 
97  Vector<double> arrange_minimums(void) const;
98  Vector<double> arrange_maximums(void) const;
99 
100  // Outputs unscaling method
101 
102  const UnscalingMethod& get_unscaling_method(void) const;
103 
104  std::string write_unscaling_method(void) const;
105  std::string write_unscaling_method_text(void) const;
106 
107  // Display messages
108 
109  const bool& get_display(void) const;
110 
111  // SET METHODS
112 
113  void set(void);
114  void set(const size_t&);
115  void set(const Vector< Statistics<double> >&);
116  void set(const tinyxml2::XMLDocument&);
117  void set(const UnscalingLayer&);
118 
119  virtual void set_default(void);
120 
121  // Output variables statistics
122 
123  void set_statistics(const Vector< Statistics<double> >&);
124  void set_item_statistics(const size_t&, const Statistics<double>&);
125 
126  void set_minimum(const size_t&, const double&);
127  void set_maximum(const size_t&, const double&);
128  void set_mean(const size_t&, const double&);
129  void set_standard_deviation(const size_t&, const double&);
130 
131  // Outputs unscaling method
132 
134  void set_unscaling_method(const std::string&);
135 
136  // Display messages
137 
138  void set_display(const bool&);
139 
140  // Pruning and growing
141 
142  void prune_unscaling_neuron(const size_t&);
143 
144  // Check methods
145 
146  bool is_empty(void) const;
147 
148  // UnscalingLayer and unscaling
149 
150  void initialize_random(void);
151 
155 
159 
163 
166 
167  void check_range(const Vector<double>&) const;
168 
169  // Serialization methods
170 
171  std::string to_string(void) const;
172 
173  tinyxml2::XMLDocument* to_XML(void) const;
174  void from_XML(const tinyxml2::XMLDocument&);
175 
176  // Expression methods
177 
178  std::string write_none_expression(const Vector<std::string>&, const Vector<std::string>&) const;
181 
182  std::string write_expression(const Vector<std::string>&, const Vector<std::string>&) const;
183 
184 protected:
185 
186  // MEMBERS
187 
189 
191 
193 
195 
197 
198  bool display;
199 };
200 
201 }
202 
203 #endif
204 
205 
206 // OpenNN: Open Neural Networks Library.
207 // Copyright (c) 2005-2015 Roberto Lopez.
208 //
209 // This library is free software; you can redistribute it and/or
210 // modify it under the terms of the GNU Lesser General Public
211 // License as published by the Free Software Foundation; either
212 // version 2.1 of the License, or any later version.
213 //
214 // This library is distributed in the hope that it will be useful,
215 // but WITHOUT ANY WARRANTY; without even the implied warranty of
216 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
217 // Lesser General Public License for more details.
218 
219 // You should have received a copy of the GNU Lesser General Public
220 // License along with this library; if not, write to the Free Software
221 
222 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
223 
void set_item_statistics(const size_t &, const Statistics< double > &)
Vector< double > calculate_mean_standard_deviation_outputs(const Vector< double > &) const
Matrix< double > arrange_Jacobian(const Vector< double > &) const
Arranges a "Jacobian" matrix from the vector of derivatives.
bool is_empty(void) const
Returns true if the number of unscaling neurons is zero, and false otherwise.
void set_unscaling_method(const UnscalingMethod &)
std::string write_unscaling_method_text(void) const
bool display
Display warning messages to screen.
Vector< double > calculate_mean_standard_deviation_derivatives(const Vector< double > &) const
Vector< double > arrange_minimums(void) const
void set_minimum(const size_t &, const double &)
virtual ~UnscalingLayer(void)
Destructor.
std::string to_string(void) const
Returns a string representation of the current unscaling layer object.
void set_maximum(const size_t &, const double &)
void prune_unscaling_neuron(const size_t &)
const bool & get_display(void) const
virtual void set_default(void)
Matrix< double > arrange_statistics(void) const
std::string write_unscaling_method(void) const
const UnscalingMethod & get_unscaling_method(void) const
void check_range(const Vector< double > &) const
Vector< double > calculate_second_derivatives(const Vector< double > &) const
Vector< double > calculate_derivatives(const Vector< double > &) const
Vector< double > calculate_mean_standard_deviation_second_derivatives(const Vector< double > &) const
UnscalingMethod unscaling_method
Unscaling method for the output variables.
UnscalingLayer(void)
Default constructor.
void set_mean(const size_t &, const double &)
UnscalingLayer & operator=(const UnscalingLayer &)
void set_statistics(const Vector< Statistics< double > > &)
Vector< Matrix< double > > arrange_Hessian_form(const Vector< double > &) const
Arranges a "Hessian form" vector of matrices from the vector of second derivatives.
std::string write_none_expression(const Vector< std::string > &, const Vector< std::string > &) const
void from_XML(const tinyxml2::XMLDocument &)
std::string write_expression(const Vector< std::string > &, const Vector< std::string > &) const
std::string write_minimum_maximum_expression(const Vector< std::string > &, const Vector< std::string > &) const
size_t get_unscaling_neurons_number(void) const
Returns the number of unscaling neurons in this layer.
Vector< double > calculate_outputs(const Vector< double > &) const
bool operator==(const UnscalingLayer &) const
Vector< Statistics< double > > get_statistics(void) const
Vector< double > calculate_minimum_maximum_second_derivatives(const Vector< double > &) const
Vector< double > calculate_minimum_maximum_outputs(const Vector< double > &) const
void set(void)
Sets the unscaling layer to be empty.
void set_standard_deviation(const size_t &, const double &)
void set_display(const bool &)
tinyxml2::XMLDocument * to_XML(void) const
Vector< double > arrange_maximums(void) const
Vector< Statistics< double > > statistics
Statistics of output variables.
std::string write_mean_stadard_deviation_expression(const Vector< std::string > &, const Vector< std::string > &) const
UnscalingMethod
Enumeration of available methods for input variables, output variables and independent parameters sca...
Vector< double > calculate_minimum_maximum_derivatives(const Vector< double > &) const