20 #ifndef otbAutoencoderModel_h
21 #define otbAutoencoderModel_h
28 #define BOOST_BIND_GLOBAL_PLACEHOLDERS
30 #if defined(__GNUC__) || defined(__clang__)
31 #pragma GCC diagnostic push
33 #if (defined (__GNUC__) && (__GNUC__ >= 9)) || (defined (__clang__) && (__clang_major__ >= 10))
34 #pragma GCC diagnostic ignored "-Wdeprecated-copy"
37 #pragma GCC diagnostic ignored "-Wshadow"
38 #pragma GCC diagnostic ignored "-Wunused-parameter"
39 #pragma GCC diagnostic ignored "-Woverloaded-virtual"
40 #pragma GCC diagnostic ignored "-Wsign-compare"
41 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
42 #if defined(__clang__)
43 #pragma clang diagnostic ignored "-Wheader-guard"
44 #pragma clang diagnostic ignored "-Wdivision-by-zero"
46 #if defined(__apple_build_version__)
48 #if __apple_build_version__ >= 9000000
49 #pragma clang diagnostic ignored "-Wexpansion-to-defined"
51 #elif __clang_major__ > 3
52 #pragma clang diagnostic ignored "-Wexpansion-to-defined"
56 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
59 #include "otb_shark.h"
60 #include <shark/Algorithms/StoppingCriteria/AbstractStoppingCriterion.h>
61 #include <shark/Models/LinearModel.h>
62 #include <shark/Models/ConcatenatedModel.h>
63 #include <shark/Models/NeuronLayers.h>
64 #if defined(__GNUC__) || defined(__clang__)
65 #pragma GCC diagnostic pop
77 template <
class TInputValue,
class NeuronType>
102 typedef shark::ConcatenatedModel<shark::RealVector>
ModelType;
103 typedef shark::LinearModel<shark::RealVector, NeuronType>
LayerType;
104 typedef shark::LinearModel<shark::RealVector, shark::LinearNeuron>
OutLayerType;
109 itkGetMacro(NumberOfHiddenNeurons, itk::Array<unsigned int>);
110 itkSetMacro(NumberOfHiddenNeurons, itk::Array<unsigned int>);
112 itkGetMacro(NumberOfIterations,
unsigned int);
113 itkSetMacro(NumberOfIterations,
unsigned int);
115 itkGetMacro(NumberOfIterationsFineTuning,
unsigned int);
116 itkSetMacro(NumberOfIterationsFineTuning,
unsigned int);
118 itkGetMacro(Epsilon,
double);
119 itkSetMacro(Epsilon,
double);
121 itkGetMacro(InitFactor,
double);
122 itkSetMacro(InitFactor,
double);
124 itkGetMacro(Regularization, itk::Array<double>);
125 itkSetMacro(Regularization, itk::Array<double>);
127 itkGetMacro(Noise, itk::Array<double>);
128 itkSetMacro(Noise, itk::Array<double>);
130 itkGetMacro(Rho, itk::Array<double>);
131 itkSetMacro(Rho, itk::Array<double>);
133 itkGetMacro(Beta, itk::Array<double>);
134 itkSetMacro(Beta, itk::Array<double>);
136 itkGetMacro(WriteLearningCurve,
bool);
137 itkSetMacro(WriteLearningCurve,
bool);
139 itkSetMacro(WriteWeights,
bool);
140 itkGetMacro(WriteWeights,
bool);
142 itkGetMacro(LearningCurveFileName, std::string);
143 itkSetMacro(LearningCurveFileName, std::string);
145 bool CanReadFile(
const std::string& filename)
override;
146 bool CanWriteFile(
const std::string& filename)
override;
148 void Save(
const std::string& filename,
const std::string& name =
"")
override;
149 void Load(
const std::string& filename,
const std::string& name =
"")
override;
151 void Train()
override;
154 void TrainOneLayer(shark::AbstractStoppingCriterion<T>& criterion,
unsigned int, shark::Data<shark::RealVector>&, std::ostream&);
157 void TrainOneSparseLayer(shark::AbstractStoppingCriterion<T>& criterion,
unsigned int, shark::Data<shark::RealVector>&, std::ostream&);
160 void TrainNetwork(shark::AbstractStoppingCriterion<T>& criterion, shark::Data<shark::RealVector>&, std::ostream&);
195 #ifndef OTB_MANUAL_INSTANTIATION