unscaling_layer.h
1// @todo Test this method
2// OpenNN: Open Neural Networks Library
3// www.opennn.net
4//
5// 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
6//
7// Artificial Intelligence Techniques SL
8// artelnics@artelnics.com
9
10#ifndef UNSCALINGLAYER_H
11#define UNSCALINGLAYER_H
12
13// System includes
14
15#include <cmath>
16#include <cstdlib>
17#include <fstream>
18#include <iostream>
19#include <string>
20#include <sstream>
21
22// OpenNN includes
23
24#include "config.h"
25#include "layer.h"
26#include "statistics.h"
27#include "opennn_strings.h"
28
29
30namespace OpenNN
31{
32
34
38
39class UnscalingLayer : public Layer
40{
41
42public:
43
44 // Constructors
45
46 explicit UnscalingLayer();
47
48 explicit UnscalingLayer(const Index&);
49
50 explicit UnscalingLayer(const Tensor<Descriptives, 1>&);
51
52 // Destructor
53
54 virtual ~UnscalingLayer();
55
56 // Get methods
57
58 Index get_inputs_number() const;
59 Index get_neurons_number() const;
60
61 Tensor<Descriptives, 1> get_descriptives() const;
62
63
64 Tensor<type, 1> get_minimums() const;
65 Tensor<type, 1> get_maximums() const;
66
67 const Tensor<Scaler, 1> get_unscaling_method() const;
68
69 Tensor<string, 1> write_unscaling_methods() const;
70 Tensor<string, 1> write_unscaling_method_text() const;
71
72 const bool& get_display() const;
73
74 // Set methods
75
76 void set();
77 void set(const Index&);
78 void set(const Tensor<Descriptives, 1>&);
79 void set(const Tensor<Descriptives, 1>&, const Tensor<Scaler, 1>&);
80 void set(const tinyxml2::XMLDocument&);
81 void set(const UnscalingLayer&);
82
83 void set_inputs_number(const Index&);
84 void set_neurons_number(const Index&);
85
86 virtual void set_default();
87
88 // Output variables descriptives
89
90 void set_descriptives(const Tensor<Descriptives, 1>&);
91
92 void set_item_descriptives(const Index&, const Descriptives&);
93
94 void set_minimum(const Index&, const type&);
95 void set_maximum(const Index&, const type&);
96 void set_mean(const Index&, const type&);
97 void set_standard_deviation(const Index&, const type&);
98
99 void set_min_max_range(const type min, const type max);
100
101 // Outputs unscaling method
102
103 void set_scalers(const Tensor<Scaler,1>&);
104 void set_scalers(const string&);
105 void set_scalers(const Tensor<string, 1>&);
106 void set_scalers(const Scaler&);
107
108 // Display messages
109
110 void set_display(const bool&);
111
112 // Check methods
113
114 bool is_empty() const;
115
116 Tensor<type, 2> calculate_outputs(const Tensor<type, 2>&);
117
118 void check_range(const Tensor<type, 1>&) const;
119
120 // Serialization methods
121
122 void from_XML(const tinyxml2::XMLDocument&);
123
124 void write_XML(tinyxml2::XMLPrinter&) const;
125
126 // Expression methods
127
128 string write_expression(const Tensor<string, 1>&, const Tensor<string, 1>&) const;
129
130 string write_expression_c() const;
131 string write_expression_python() const;
132
133
134protected:
135
136 // MEMBERS
137
139
140 Tensor<Descriptives, 1> descriptives;
141
143
144 Tensor<Scaler, 1> scalers;
145
147
149 type max_range;
150
152
153 bool display = true;
154};
155
156}
157
158#endif
159
160
161// OpenNN: Open Neural Networks Library.
162// Copyright(C) 2005-2021 Artificial Intelligence Techniques, SL.
163//
164// This library is free software; you can redistribute it and/or
165// modify it under the terms of the GNU Lesser General Public
166// License as published by the Free Software Foundation; either
167// version 2.1 of the License, or any later version.
168//
169// This library is distributed in the hope that it will be useful,
170// but WITHOUT ANY WARRANTY; without even the implied warranty of
171// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
172// Lesser General Public License for more details.
173
174// You should have received a copy of the GNU Lesser General Public
175// License along with this library; if not, write to the Free Software
176
177// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
This abstract class represents the concept of a layer of neurons in OpenNN.
Definition: layer.h:53
This class represents a layer of unscaling neurons.
string write_expression_c() const
void set_maximum(const Index &, const type &)
void set_descriptives(const Tensor< Descriptives, 1 > &)
void set_item_descriptives(const Index &, const Descriptives &)
void set_minimum(const Index &, const type &)
const bool & get_display() const
void set_standard_deviation(const Index &, const type &)
Index get_inputs_number() const
Returns the number of inputs.
string write_expression(const Tensor< string, 1 > &, const Tensor< string, 1 > &) const
Returns a string with the expression of the inputs scaling process.
void from_XML(const tinyxml2::XMLDocument &)
const Tensor< Scaler, 1 > get_unscaling_method() const
string write_expression_python() const
Tensor< Scaler, 1 > scalers
Unscaling method for the output variables.
void check_range(const Tensor< type, 1 > &) const
bool display
Display warning messages to screen.
bool is_empty() const
Returns true if the number of unscaling neurons is zero, and false otherwise.
void set()
Sets the unscaling layer to be empty.
Tensor< type, 1 > get_minimums() const
Tensor< type, 1 > get_maximums() const
virtual ~UnscalingLayer()
Destructor.
Tensor< string, 1 > write_unscaling_method_text() const
void set_scalers(const Tensor< Scaler, 1 > &)
Tensor< type, 2 > calculate_outputs(const Tensor< type, 2 > &)
Index get_neurons_number() const
Returns the number of unscaling neurons in this layer.
Tensor< Descriptives, 1 > get_descriptives() const
UnscalingLayer()
Default constructor.
type min_range
min and max range for unscaling
Tensor< Descriptives, 1 > descriptives
Descriptives of output variables.
void set_display(const bool &)
void write_XML(tinyxml2::XMLPrinter &) const
void set_mean(const Index &, const type &)
void set_min_max_range(const type min, const type max)
Tensor< string, 1 > write_unscaling_methods() const
Returns a vector of strings with the name of the method used for each unscaling neuron.
This structure contains the simplest Descriptives for a set, variable, etc.
Definition: statistics.h:40