Commit f52ef084 authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

ENH: move specific code for each DR algorithm

No related merge requests found
Showing with 23 additions and 39 deletions
+23 -39
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#define cbTrainAutoencoder_txx #define cbTrainAutoencoder_txx
#include "otbTrainDimensionalityReductionApplicationBase.h" #include "otbTrainDimensionalityReductionApplicationBase.h"
#include "otbAutoencoderModel.h"
namespace otb namespace otb
{ {
...@@ -106,7 +107,15 @@ void ...@@ -106,7 +107,15 @@ void
TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue>
::BeforeTrainAutoencoder(typename ListSampleType::Pointer trainingListSample, ::BeforeTrainAutoencoder(typename ListSampleType::Pointer trainingListSample,
std::string modelPath) std::string modelPath)
{ {
// typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType;
typedef shark::LogisticNeuron NeuronType;
typedef otb::AutoencoderModel<InputValueType, NeuronType> AutoencoderModelType;
/*
// typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType;
typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::TanhNeuron> TiedAutoencoderType;
typedef otb::AutoencoderModel<InputValueType, TiedAutoencoderType> TiedAutoencoderModelType;
*/
std::string TiedWeigth = GetParameterString("algorithm.autoencoder.istied"); std::string TiedWeigth = GetParameterString("algorithm.autoencoder.istied");
std::cout << TiedWeigth << std::endl; std::cout << TiedWeigth << std::endl;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#define cbTrainPCA_txx #define cbTrainPCA_txx
#include "otbTrainDimensionalityReductionApplicationBase.h" #include "otbTrainDimensionalityReductionApplicationBase.h"
#include "otbPCAModel.h"
namespace otb namespace otb
{ {
...@@ -37,6 +38,7 @@ template <class TInputValue, class TOutputValue> ...@@ -37,6 +38,7 @@ template <class TInputValue, class TOutputValue>
void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue>
::TrainPCA(typename ListSampleType::Pointer trainingListSample,std::string modelPath) ::TrainPCA(typename ListSampleType::Pointer trainingListSample,std::string modelPath)
{ {
typedef otb::PCAModel<InputValueType> PCAModelType;
typename PCAModelType::Pointer dimredTrainer = PCAModelType::New(); typename PCAModelType::Pointer dimredTrainer = PCAModelType::New();
dimredTrainer->SetDimension(GetParameterInt("algorithm.pca.dim")); dimredTrainer->SetDimension(GetParameterInt("algorithm.pca.dim"));
dimredTrainer->SetInputListSample(trainingListSample); dimredTrainer->SetInputListSample(trainingListSample);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#ifndef cbTrainSOM_txx #ifndef cbTrainSOM_txx
#define cbTrainSOM_txx #define cbTrainSOM_txx
#include "otbTrainDimensionalityReductionApplicationBase.h" #include "otbTrainDimensionalityReductionApplicationBase.h"
#include "otbSOMModel.h"
namespace otb namespace otb
{ {
...@@ -79,7 +80,16 @@ void ...@@ -79,7 +80,16 @@ void
TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue> TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue>
::BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, ::BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample,
std::string modelPath) std::string modelPath)
{ {
//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType;
//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> Map3DType;
//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 4> Map4DType;
//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType;
typedef otb::SOMModel<InputValueType, 2> SOM2DModelType;
typedef otb::SOMModel<InputValueType, 3> SOM3DModelType;
typedef otb::SOMModel<InputValueType, 4> SOM4DModelType;
typedef otb::SOMModel<InputValueType, 5> SOM5DModelType;
int SomDim = GetParameterInt("algorithm.som.dim"); int SomDim = GetParameterInt("algorithm.som.dim");
std::cout << SomDim << std::endl; std::cout << SomDim << std::endl;
......
...@@ -14,13 +14,6 @@ ...@@ -14,13 +14,6 @@
//Estimator //Estimator
#include "otbDimensionalityReductionModelFactory.h" #include "otbDimensionalityReductionModelFactory.h"
#include "otbSOMModel.h"
#ifdef OTB_USE_SHARK
#include "otbAutoencoderModel.h"
#include "otbPCAModel.h"
#endif
namespace otb namespace otb
{ {
namespace Wrapper namespace Wrapper
...@@ -84,34 +77,6 @@ public: ...@@ -84,34 +77,6 @@ public:
typedef typename ModelType::InputSampleType SampleType; typedef typename ModelType::InputSampleType SampleType;
typedef typename ModelType::InputListSampleType ListSampleType; typedef typename ModelType::InputListSampleType ListSampleType;
// Dimensionality reduction models
//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType;
typedef otb::SOMModel<InputValueType, 2> SOM2DModelType;
//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> Map3DType;
typedef otb::SOMModel<InputValueType, 3> SOM3DModelType;
//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 4> Map4DType;
typedef otb::SOMModel<InputValueType, 4> SOM4DModelType;
//typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType;
typedef otb::SOMModel<InputValueType, 5> SOM5DModelType;
#ifdef OTB_USE_SHARK
// typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType;
typedef shark::LogisticNeuron NeuronType;
typedef otb::AutoencoderModel<InputValueType, NeuronType> AutoencoderModelType;
/*
// typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron> TiedAutoencoderType;
typedef shark::TiedAutoencoder< shark::TanhNeuron, shark::TanhNeuron> TiedAutoencoderType;
typedef otb::AutoencoderModel<InputValueType, TiedAutoencoderType> TiedAutoencoderModelType;
*/
typedef otb::PCAModel<InputValueType> PCAModelType;
#endif
protected: protected:
TrainDimensionalityReductionApplicationBase(); TrainDimensionalityReductionApplicationBase();
...@@ -148,8 +113,6 @@ void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::st ...@@ -148,8 +113,6 @@ void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::st
void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath); void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath);
void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath); void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath);
#endif #endif
//@} //@}
}; };
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment