OpenNN  2.2
Open Neural Networks Library
outputs.h
1 /****************************************************************************************************************/
2 /* */
3 /* OpenNN: Open Neural Networks Library */
4 /* www.artelnics.com/opennn */
5 /* */
6 /* O U T P U T S 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 __OUTPUTS_H__
15 #define __OUTPUTS_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 
41 class Outputs
42 {
43 
44 public:
45 
46  // DEFAULT CONSTRUCTOR
47 
48  explicit Outputs(void);
49 
50 
51  // OUTPUTS NUMBER CONSTRUCTOR
52 
53  explicit Outputs(const size_t&);
54 
55 
56  // XML CONSTRUCTOR
57 
58  explicit Outputs(const tinyxml2::XMLDocument&);
59 
60 
61  // COPY CONSTRUCTOR
62 
63  Outputs(const Outputs&);
64 
65  // DESTRUCTOR
66 
67  virtual ~Outputs(void);
68 
69  // ASSIGNMENT OPERATOR
70 
71  Outputs& operator = (const Outputs&);
72 
73  // EQUAL TO OPERATOR
74 
75  bool operator == (const Outputs&) const;
76 
80 
81  struct Item
82  {
84 
85  std::string name;
86 
88 
89  std::string units;
90 
92 
93  std::string description;
94 
96 
97  Item(void) {}
98 
99  };
100 
101  // METHODS
102 
103  bool is_empty(void) const;
104 
106 
107  inline size_t get_outputs_number(void) const
108  {
109  return(items.size());
110  }
111 
112  // Output variables information
113 
115  const std::string& get_name(const size_t&) const;
116 
118  const std::string& get_unit(const size_t&) const;
119 
121  const std::string& get_description(const size_t&) const;
122 
123  // Variables
124 
126 
127  // Display messages
128 
129  const bool& get_display(void) const;
130 
131  // SET METHODS
132 
133  void set(void);
134  void set(const size_t&);
135  void set(const Vector<Item>&);
136  void set(const Outputs&);
137 
138  void set_outputs_number(const size_t&);
139 
140  virtual void set_default(void);
141 
142  // Output variables information
143 
144  void set_names(const Vector<std::string>&);
145  void set_name(const size_t&, const std::string&);
146 
147  void set_units(const Vector<std::string>&);
148  void set_unit(const size_t&, const std::string&);
149 
151  void set_description(const size_t&, const std::string&);
152 
153  // Variables
154 
156 
157  void set_display(const bool&);
158 
159  // Growing and pruning
160 
161  void grow_output(void);
162 
163  void prune_output(const size_t&);
164 
165  // Default names
166 
168 
169  // Serialization methods
170 
171  std::string to_string(void) const;
172 
173  virtual tinyxml2::XMLDocument* to_XML(void) const;
174  virtual void from_XML(const tinyxml2::XMLDocument&);
175 
176 protected:
177 
178  // MEMBERS
179 
181 
183 
185 
187 
189 
191 
193 
194  bool display;
195 };
196 
197 }
198 
199 #endif
200 
201 
202 // OpenNN: Open Neural Networks Library.
203 // Copyright (c) 2005-2015 Roberto Lopez.
204 //
205 // This library is free software; you can redistribute it and/or
206 // modify it under the terms of the GNU Lesser General Public
207 // License as published by the Free Software Foundation; either
208 // version 2.1 of the License, or any later version.
209 //
210 // This library is distributed in the hope that it will be useful,
211 // but WITHOUT ANY WARRANTY; without even the implied warranty of
212 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
213 // Lesser General Public License for more details.
214 
215 // You should have received a copy of the GNU Lesser General Public
216 // License along with this library; if not, write to the Free Software
217 
218 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
219 
Vector< std::string > arrange_names(void) const
Definition: outputs.cpp:147
std::string description
Description of neural network output.
Definition: outputs.h:93
const bool & get_display(void) const
Definition: outputs.cpp:306
void grow_output(void)
Appends a new item to the outputs.
Definition: outputs.cpp:661
Vector< std::string > arrange_descriptions(void) const
Definition: outputs.cpp:198
void set_display(const bool &)
Definition: outputs.cpp:651
void set_name(const size_t &, const std::string &)
Definition: outputs.cpp:443
void set_unit(const size_t &, const std::string &)
Definition: outputs.cpp:512
std::string to_string(void) const
Returns a string representation of the current outputs object.
Definition: outputs.cpp:733
Vector< std::string > arrange_units(void) const
Definition: outputs.cpp:240
void set_descriptions(const Vector< std::string > &)
Definition: outputs.cpp:550
Outputs & operator=(const Outputs &)
Definition: outputs.cpp:84
bool display
Display messages to screen.
Definition: outputs.h:194
std::string units
Units of neural network output.
Definition: outputs.h:89
void set_information(const Matrix< std::string > &)
Definition: outputs.cpp:629
virtual tinyxml2::XMLDocument * to_XML(void) const
Definition: outputs.cpp:760
const std::string & get_description(const size_t &) const
Definition: outputs.cpp:210
virtual void from_XML(const tinyxml2::XMLDocument &)
Definition: outputs.cpp:839
bool operator==(const Outputs &) const
Definition: outputs.cpp:109
bool is_empty(void) const
Returns true if both the number of outputs is zero, and false otherwise.
Definition: outputs.cpp:127
virtual void set_default(void)
Sets the members of this object to their default values.
Definition: outputs.cpp:378
Vector< std::string > write_default_names(void) const
Definition: outputs.cpp:708
Vector< std::string > units
Units of output variables.
Definition: outputs.h:186
void set(void)
Definition: outputs.cpp:317
Vector< std::string > descriptions
Description of output variables.
Definition: outputs.h:190
const std::string & get_unit(const size_t &) const
Definition: outputs.cpp:252
void set_description(const size_t &, const std::string &)
Definition: outputs.cpp:586
void set_outputs_number(const size_t &)
Definition: outputs.cpp:368
Matrix< std::string > arrange_information(void) const
Definition: outputs.cpp:284
void prune_output(const size_t &)
Definition: outputs.cpp:674
Vector< Item > items
Name of output variables.
Definition: outputs.h:182
Item(void)
Default constructor.
Definition: outputs.h:97
void set_units(const Vector< std::string > &)
Definition: outputs.cpp:476
void set_names(const Vector< std::string > &)
Definition: outputs.cpp:404
virtual ~Outputs(void)
Destructor.
Definition: outputs.cpp:73
const std::string & get_name(const size_t &) const
Definition: outputs.cpp:168
std::string name
Name of neural network output.
Definition: outputs.h:85
size_t get_outputs_number(void) const
Returns the number of outputs neurons in the neural network.
Definition: outputs.h:107