Skip to content
Snippets Groups Projects
Commit f52ef084 authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

ENH: move specific code for each DR algorithm

parent 8397fec0
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
#define cbTrainAutoencoder_txx
#include "otbTrainDimensionalityReductionApplicationBase.h"
#include "otbAutoencoderModel.h"
namespace otb
{
......@@ -106,7 +107,15 @@ void
TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue>
::BeforeTrainAutoencoder(typename ListSampleType::Pointer trainingListSample,
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::cout << TiedWeigth << std::endl;
......
......@@ -3,6 +3,7 @@
#define cbTrainPCA_txx
#include "otbTrainDimensionalityReductionApplicationBase.h"
#include "otbPCAModel.h"
namespace otb
{
......@@ -37,6 +38,7 @@ template <class TInputValue, class TOutputValue>
void TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue>
::TrainPCA(typename ListSampleType::Pointer trainingListSample,std::string modelPath)
{
typedef otb::PCAModel<InputValueType> PCAModelType;
typename PCAModelType::Pointer dimredTrainer = PCAModelType::New();
dimredTrainer->SetDimension(GetParameterInt("algorithm.pca.dim"));
dimredTrainer->SetInputListSample(trainingListSample);
......
......@@ -2,6 +2,7 @@
#ifndef cbTrainSOM_txx
#define cbTrainSOM_txx
#include "otbTrainDimensionalityReductionApplicationBase.h"
#include "otbSOMModel.h"
namespace otb
{
......@@ -79,7 +80,16 @@ void
TrainDimensionalityReductionApplicationBase<TInputValue,TOutputValue>
::BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample,
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");
std::cout << SomDim << std::endl;
......
......@@ -14,13 +14,6 @@
//Estimator
#include "otbDimensionalityReductionModelFactory.h"
#include "otbSOMModel.h"
#ifdef OTB_USE_SHARK
#include "otbAutoencoderModel.h"
#include "otbPCAModel.h"
#endif
namespace otb
{
namespace Wrapper
......@@ -84,34 +77,6 @@ public:
typedef typename ModelType::InputSampleType SampleType;
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:
TrainDimensionalityReductionApplicationBase();
......@@ -148,8 +113,6 @@ void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::st
void TrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath);
void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath);
#endif
//@}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment