Skip to content
Snippets Groups Projects
Commit ea53b867 authored by Cédric Traizet's avatar Cédric Traizet
Browse files

DR is now based on Machine Learning Models, it is now possible to reduce de...

DR is now based on Machine Learning Models, it is now possible to reduce de dimension of the pca model (it has to be changed in PCAModel.txx for now
parent a30fb6f2
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "itkListSample.h" #include "itkListSample.h"
#include "otbShiftScaleSampleListFilter.h" #include "otbShiftScaleSampleListFilter.h"
#include "DimensionalityReductionModelFactory.h" #include "DimensionalityReductionModelFactory.h"
#include "DimensionalityReductionModel.h" //#include "DimensionalityReductionModel.h"
#include <time.h> #include <time.h>
namespace otb namespace otb
...@@ -57,16 +57,16 @@ class CbDimensionalityReductionVector : public Application ...@@ -57,16 +57,16 @@ class CbDimensionalityReductionVector : public Application
/** Filters typedef */ /** Filters typedef */
typedef double ValueType; typedef double ValueType;
typedef DimensionalityReductionModel<ValueType,ValueType> DimensionalityReductionModelType; typedef itk::VariableLengthVector<ValueType> InputSampleType;
typedef DimensionalityReductionModelFactory<ValueType, ValueType> DimensionalityReductionModelFactoryType; typedef itk::Statistics::ListSample<InputSampleType> ListSampleType;
typedef DimensionalityReductionModelType::Pointer ModelPointerType; typedef MachineLearningModel<itk::VariableLengthVector<ValueType>, itk::VariableLengthVector<ValueType>> DimensionalityReductionModelType;
typedef DimensionalityReductionModelFactory<ValueType,ValueType> DimensionalityReductionModelFactoryType;
typedef DimensionalityReductionModelType::Pointer ModelPointerType;
/** Statistics Filters typedef */ /** Statistics Filters typedef */
typedef itk::VariableLengthVector<ValueType> MeasurementType; typedef itk::VariableLengthVector<ValueType> MeasurementType;
typedef otb::StatisticsXMLFileReader<MeasurementType> StatisticsReader; typedef otb::StatisticsXMLFileReader<MeasurementType> StatisticsReader;
typedef itk::VariableLengthVector<ValueType> InputSampleType;
typedef itk::Statistics::ListSample<InputSampleType> ListSampleType;
typedef otb::Statistics::ShiftScaleSampleListFilter<ListSampleType, ListSampleType> ShiftScaleFilterType; typedef otb::Statistics::ShiftScaleSampleListFilter<ListSampleType, ListSampleType> ShiftScaleFilterType;
~CbDimensionalityReductionVector() ITK_OVERRIDE ~CbDimensionalityReductionVector() ITK_OVERRIDE
{ {
...@@ -211,7 +211,7 @@ class CbDimensionalityReductionVector : public Application ...@@ -211,7 +211,7 @@ class CbDimensionalityReductionVector : public Application
/** Read the model */ /** Read the model */
std::cout << "create the fact ?" << std::endl;
m_Model = DimensionalityReductionModelFactoryType::CreateDimensionalityReductionModel(GetParameterString("model"), m_Model = DimensionalityReductionModelFactoryType::CreateDimensionalityReductionModel(GetParameterString("model"),
DimensionalityReductionModelFactoryType::ReadMode); DimensionalityReductionModelFactoryType::ReadMode);
if (m_Model.IsNull()) if (m_Model.IsNull())
......
...@@ -6,23 +6,31 @@ ...@@ -6,23 +6,31 @@
namespace otb namespace otb
{ {
template <class TInputValue, class AutoencoderType> template <class TInputValue, class AutoencoderType>
class ITK_EXPORT AutoencoderModel: public DimensionalityReductionModel<TInputValue,TInputValue> class ITK_EXPORT AutoencoderModel: public MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>>
{ {
public: public:
typedef AutoencoderModel Self; typedef AutoencoderModel Self;
typedef DimensionalityReductionModel<TInputValue,TInputValue> Superclass; typedef MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> Superclass;
typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer; typedef itk::SmartPointer<const Self> ConstPointer;
typedef typename Superclass::InputValueType InputValueType; typedef typename Superclass::InputValueType InputValueType;
typedef typename Superclass::InputSampleType InputSampleType; typedef typename Superclass::InputSampleType InputSampleType;
typedef typename Superclass::InputListSampleType InputListSampleType; typedef typename Superclass::InputListSampleType InputListSampleType;
typedef typename Superclass::TargetValueType TargetValueType; typedef typename InputListSampleType::Pointer ListSamplePointerType;
typedef typename Superclass::TargetSampleType TargetSampleType; typedef typename Superclass::TargetValueType TargetValueType;
typedef typename Superclass::TargetListSampleType TargetListSampleType; typedef typename Superclass::TargetSampleType TargetSampleType;
typedef typename Superclass::TargetListSampleType TargetListSampleType;
/// Confidence map related typedefs
typedef typename Superclass::ConfidenceValueType ConfidenceValueType;
typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType;
typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType;
itkNewMacro(Self); itkNewMacro(Self);
itkTypeMacro(AutoencoderModel, DimensionalityReductionModel); itkTypeMacro(AutoencoderModel, DimensionalityReductionModel);
...@@ -59,8 +67,9 @@ protected: ...@@ -59,8 +67,9 @@ protected:
AutoencoderModel(); AutoencoderModel();
~AutoencoderModel() ITK_OVERRIDE; ~AutoencoderModel() ITK_OVERRIDE;
virtual TargetSampleType DoPredict(const InputSampleType& input) const ITK_OVERRIDE; virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType * quality = ITK_NULLPTR) const;
virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *) const ITK_OVERRIDE;
virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * quality = ITK_NULLPTR) const;
private: private:
......
...@@ -171,7 +171,7 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Load(const std::string & fil ...@@ -171,7 +171,7 @@ void AutoencoderModel<TInputValue,AutoencoderType>::Load(const std::string & fil
template <class TInputValue, class AutoencoderType> template <class TInputValue, class AutoencoderType>
typename AutoencoderModel<TInputValue,AutoencoderType>::TargetSampleType typename AutoencoderModel<TInputValue,AutoencoderType>::TargetSampleType
AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & value) const AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & value, ConfidenceValueType * quality) const
{ {
shark::RealVector samples(value.Size()); shark::RealVector samples(value.Size());
for(size_t i = 0; i < value.Size();i++) for(size_t i = 0; i < value.Size();i++)
...@@ -200,7 +200,7 @@ AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType & ...@@ -200,7 +200,7 @@ AutoencoderModel<TInputValue,AutoencoderType>::DoPredict(const InputSampleType &
template <class TInputValue, class AutoencoderType> template <class TInputValue, class AutoencoderType>
void AutoencoderModel<TInputValue,AutoencoderType> void AutoencoderModel<TInputValue,AutoencoderType>
::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets) const ::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const
{ {
std::vector<shark::RealVector> features; std::vector<shark::RealVector> features;
Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); Shark::ListSampleRangeToSharkVector(input, features,startIndex,size);
......
...@@ -18,9 +18,11 @@ ...@@ -18,9 +18,11 @@
#ifndef DimensionalityReductionModelFactory_h #ifndef DimensionalityReductionModelFactory_h
#define DimensionalityReductionModelFactory_h #define DimensionalityReductionModelFactory_h
#include "DimensionalityReductionModel.h" //#include "DimensionalityReductionModel.h"
#include "otbMachineLearningModelFactoryBase.h" #include "otbMachineLearningModelFactoryBase.h"
#include "otbMachineLearningModel.h"
namespace otb namespace otb
{ {
/** \class MachineLearningModelFactory /** \class MachineLearningModelFactory
...@@ -44,7 +46,7 @@ public: ...@@ -44,7 +46,7 @@ public:
itkTypeMacro(DimensionalityReductionModelFactory, itk::Object); itkTypeMacro(DimensionalityReductionModelFactory, itk::Object);
/** Convenient typedefs. */ /** Convenient typedefs. */
typedef otb::DimensionalityReductionModel<TInputValue,TOutputValue> DimensionalityReductionModelType; typedef otb::MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TOutputValue>> DimensionalityReductionModelType;
typedef typename DimensionalityReductionModelType::Pointer DimensionalityReductionModelTypePointer; typedef typename DimensionalityReductionModelType::Pointer DimensionalityReductionModelTypePointer;
/** Mode in which the files is intended to be used */ /** Mode in which the files is intended to be used */
......
...@@ -22,25 +22,25 @@ ...@@ -22,25 +22,25 @@
#include "otbConfigure.h" #include "otbConfigure.h"
#include "SOMModelFactory.h" #include "SOMModelFactory.h"
/*
#ifdef OTB_USE_SHARK #ifdef OTB_USE_SHARK
#include "AutoencoderModelFactory.h" #include "AutoencoderModelFactory.h"
#include "PCAModelFactory.h" #include "PCAModelFactory.h"
#endif #endif
*/
#include "itkMutexLockHolder.h" #include "itkMutexLockHolder.h"
namespace otb namespace otb
{ {
/*
template <class TInputValue, class TTargetValue> template <class TInputValue, class TTargetValue>
using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::LinearNeuron>> ; using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::LinearNeuron>> ;
template <class TInputValue, class TTargetValue> template <class TInputValue, class TTargetValue>
using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ; using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ;
*/
template <class TInputValue, class TTargetValue> template <class TInputValue, class TTargetValue>
using SOM2DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 2> ; using SOM2DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 2> ;
...@@ -56,7 +56,7 @@ using SOM5DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 5> ; ...@@ -56,7 +56,7 @@ using SOM5DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 5> ;
template <class TInputValue, class TOutputValue> template <class TInputValue, class TOutputValue>
typename DimensionalityReductionModel<TInputValue,TOutputValue>::Pointer typename MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TOutputValue>>::Pointer
DimensionalityReductionModelFactory<TInputValue,TOutputValue> DimensionalityReductionModelFactory<TInputValue,TOutputValue>
::CreateDimensionalityReductionModel(const std::string& path, FileModeType mode) ::CreateDimensionalityReductionModel(const std::string& path, FileModeType mode)
{ {
...@@ -65,26 +65,30 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> ...@@ -65,26 +65,30 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue>
std::list<DimensionalityReductionModelTypePointer> possibleDimensionalityReductionModel; std::list<DimensionalityReductionModelTypePointer> possibleDimensionalityReductionModel;
std::list<LightObject::Pointer> allobjects = std::list<LightObject::Pointer> allobjects =
itk::ObjectFactoryBase::CreateAllInstance("DimensionalityReductionModel"); itk::ObjectFactoryBase::CreateAllInstance("DimensionalityReductionModel");
for(std::list<LightObject::Pointer>::iterator i = allobjects.begin(); for(std::list<LightObject::Pointer>::iterator i = allobjects.begin();
i != allobjects.end(); ++i) i != allobjects.end(); ++i)
{ {
DimensionalityReductionModel<TInputValue,TOutputValue> * io = dynamic_cast<DimensionalityReductionModel<TInputValue,TOutputValue>*>(i->GetPointer()); MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TOutputValue>> * io = dynamic_cast<MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TOutputValue>>*>(i->GetPointer());
if(io) if(io)
{ {
possibleDimensionalityReductionModel.push_back(io); possibleDimensionalityReductionModel.push_back(io);
} }
else else
{ {
std::cerr << "Error DimensionalityReductionModel Factory did not return an DimensionalityReductionModel: " std::cerr << "Error DimensionalityReductionModel Factory did not return an DimensionalityReductionModel: "
<< (*i)->GetNameOfClass() << (*i)->GetNameOfClass()
<< std::endl; << std::endl;
} }
} }
for(typename std::list<DimensionalityReductionModelTypePointer>::iterator k = possibleDimensionalityReductionModel.begin(); for(typename std::list<DimensionalityReductionModelTypePointer>::iterator k = possibleDimensionalityReductionModel.begin();
k != possibleDimensionalityReductionModel.end(); ++k) k != possibleDimensionalityReductionModel.end(); ++k)
{ {
if( mode == ReadMode ) if( mode == ReadMode )
{ {
if((*k)->CanReadFile(path)) if((*k)->CanReadFile(path))
{ {
return *k; return *k;
...@@ -115,13 +119,13 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> ...@@ -115,13 +119,13 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue>
RegisterFactory(SOM3DModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(SOM3DModelFactory<TInputValue,TOutputValue>::New());
RegisterFactory(SOM4DModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(SOM4DModelFactory<TInputValue,TOutputValue>::New());
RegisterFactory(SOM5DModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(SOM5DModelFactory<TInputValue,TOutputValue>::New());
/*
#ifdef OTB_USE_SHARK #ifdef OTB_USE_SHARK
RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New());
RegisterFactory(AutoencoderModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(AutoencoderModelFactory<TInputValue,TOutputValue>::New());
RegisterFactory(TiedAutoencoderModelFactory<TInputValue,TOutputValue>::New()); RegisterFactory(TiedAutoencoderModelFactory<TInputValue,TOutputValue>::New());
#endif #endif
*/
} }
template <class TInputValue, class TOutputValue> template <class TInputValue, class TOutputValue>
...@@ -182,7 +186,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> ...@@ -182,7 +186,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue>
itk::ObjectFactoryBase::UnRegisterFactory(som2dFactory); itk::ObjectFactoryBase::UnRegisterFactory(som2dFactory);
continue; continue;
} }
/*
#ifdef OTB_USE_SHARK #ifdef OTB_USE_SHARK
// Autoencoder // Autoencoder
...@@ -211,7 +215,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue> ...@@ -211,7 +215,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue>
continue; continue;
} }
#endif #endif
*/
} }
} }
......
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
#define ImageDimensionalityReduction_h #define ImageDimensionalityReduction_h
#include "itkImageToImageFilter.h" #include "itkImageToImageFilter.h"
#include "DimensionalityReductionModel.h" //#include "DimensionalityReductionModel.h"
#include "otbMachineLearningModel.h"
#include "otbImage.h" #include "otbImage.h"
namespace otb namespace otb
...@@ -66,7 +67,7 @@ public: ...@@ -66,7 +67,7 @@ public:
typedef typename OutputImageType::RegionType OutputImageRegionType; typedef typename OutputImageType::RegionType OutputImageRegionType;
typedef typename OutputImageType::InternalPixelType LabelType; typedef typename OutputImageType::InternalPixelType LabelType;
typedef DimensionalityReductionModel<ValueType, LabelType> ModelType; typedef MachineLearningModel<itk::VariableLengthVector<ValueType>, itk::VariableLengthVector<LabelType>> ModelType;
typedef typename ModelType::Pointer ModelPointerType; typedef typename ModelType::Pointer ModelPointerType;
typedef otb::Image<double> ConfidenceImageType; typedef otb::Image<double> ConfidenceImageType;
......
...@@ -7,29 +7,39 @@ ...@@ -7,29 +7,39 @@
namespace otb namespace otb
{ {
template <class TInputValue> template <class TInputValue>
class ITK_EXPORT PCAModel: public DimensionalityReductionModel<TInputValue,TInputValue> class ITK_EXPORT PCAModel: public MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>>
{ {
public: public:
typedef PCAModel Self; typedef PCAModel Self;
typedef DimensionalityReductionModel<TInputValue,TInputValue> Superclass; typedef MachineLearningModel<itk::VariableLengthVector< TInputValue> , itk::VariableLengthVector< TInputValue>> Superclass;
typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer; typedef itk::SmartPointer<const Self> ConstPointer;
typedef typename Superclass::InputValueType InputValueType; typedef typename Superclass::InputValueType InputValueType;
typedef typename Superclass::InputSampleType InputSampleType; typedef typename Superclass::InputSampleType InputSampleType;
typedef typename Superclass::InputListSampleType InputListSampleType; typedef typename Superclass::InputListSampleType InputListSampleType;
typedef typename Superclass::TargetValueType TargetValueType; typedef typename InputListSampleType::Pointer ListSamplePointerType;
typedef typename Superclass::TargetSampleType TargetSampleType; typedef typename Superclass::TargetValueType TargetValueType;
typedef typename Superclass::TargetListSampleType TargetListSampleType; typedef typename Superclass::TargetSampleType TargetSampleType;
typedef typename Superclass::TargetListSampleType TargetListSampleType;
/// Confidence map related typedefs
typedef typename Superclass::ConfidenceValueType ConfidenceValueType;
typedef typename Superclass::ConfidenceSampleType ConfidenceSampleType;
typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType;
itkNewMacro(Self); itkNewMacro(Self);
itkTypeMacro(PCAModel, DimensionalityReductionModel); itkTypeMacro(PCAModel, DimensionalityReductionModel);
unsigned int GetDimension() {return m_Dimension;}; unsigned int GetDimension() {return m_Dimension;};
itkSetMacro(Dimension,unsigned int); itkSetMacro(Dimension,unsigned int);
itkSetMacro(Do_resize_flag,bool);
bool CanReadFile(const std::string & filename); bool CanReadFile(const std::string & filename);
bool CanWriteFile(const std::string & filename); bool CanWriteFile(const std::string & filename);
...@@ -44,15 +54,16 @@ protected: ...@@ -44,15 +54,16 @@ protected:
PCAModel(); PCAModel();
~PCAModel() ITK_OVERRIDE; ~PCAModel() ITK_OVERRIDE;
virtual TargetSampleType DoPredict(const InputSampleType& input) const ITK_OVERRIDE; virtual TargetSampleType DoPredict(const InputSampleType& input, ConfidenceValueType * quality = ITK_NULLPTR) const;
virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *) const ITK_OVERRIDE;
virtual void DoPredictBatch(const InputListSampleType *, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType *, ConfidenceListSampleType * quality = ITK_NULLPTR) const ITK_OVERRIDE;
private: private:
shark::LinearModel<> m_encoder; shark::LinearModel<> m_encoder;
shark::LinearModel<> m_decoder; shark::LinearModel<> m_decoder;
shark::PCA m_pca; shark::PCA m_pca;
unsigned int m_Dimension; unsigned int m_Dimension;
bool m_Do_resize_flag;
}; };
} // end namespace otb } // end namespace otb
......
...@@ -40,6 +40,7 @@ void PCAModel<TInputValue>::Train() ...@@ -40,6 +40,7 @@ void PCAModel<TInputValue>::Train()
shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features ); shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features );
m_pca.setData(inputSamples); m_pca.setData(inputSamples);
m_pca.encoder(m_encoder, m_Dimension); m_pca.encoder(m_encoder, m_Dimension);
std::cout << m_encoder.matrix() << std::endl;
m_pca.decoder(m_decoder, m_Dimension); m_pca.decoder(m_decoder, m_Dimension);
} }
...@@ -94,13 +95,17 @@ void PCAModel<TInputValue>::Load(const std::string & filename, const std::string ...@@ -94,13 +95,17 @@ void PCAModel<TInputValue>::Load(const std::string & filename, const std::string
m_encoder.read(ia); m_encoder.read(ia);
ifs.close(); ifs.close();
m_Dimension = m_encoder.outputSize(); m_Dimension = m_encoder.outputSize();
auto eigenvectors = m_encoder.matrix();
eigenvectors.resize(2,m_encoder.inputSize());
m_encoder.setStructure(eigenvectors, m_encoder.offset() );
std::cout << m_encoder.matrix() << std::endl;
//this->m_Size = m_NumberOfHiddenNeurons; //this->m_Size = m_NumberOfHiddenNeurons;
} }
template <class TInputValue> template <class TInputValue>
typename PCAModel<TInputValue>::TargetSampleType typename PCAModel<TInputValue>::TargetSampleType
PCAModel<TInputValue>::DoPredict(const InputSampleType & value) const PCAModel<TInputValue>::DoPredict(const InputSampleType & value, ConfidenceValueType * quality) const
{ {
shark::RealVector samples(value.Size()); shark::RealVector samples(value.Size());
for(size_t i = 0; i < value.Size();i++) for(size_t i = 0; i < value.Size();i++)
...@@ -126,7 +131,7 @@ PCAModel<TInputValue>::DoPredict(const InputSampleType & value) const ...@@ -126,7 +131,7 @@ PCAModel<TInputValue>::DoPredict(const InputSampleType & value) const
template <class TInputValue> template <class TInputValue>
void PCAModel<TInputValue> void PCAModel<TInputValue>
::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets) const ::DoPredictBatch(const InputListSampleType *input, const unsigned int & startIndex, const unsigned int & size, TargetListSampleType * targets, ConfidenceListSampleType * quality) const
{ {
std::vector<shark::RealVector> features; std::vector<shark::RealVector> features;
......
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
#include "DimensionalityReductionModelFactory.h" #include "DimensionalityReductionModelFactory.h"
#include "SOMModel.h" #include "SOMModel.h"
/*
#ifdef OTB_USE_SHARK #ifdef OTB_USE_SHARK
#include "AutoencoderModel.h" #include "AutoencoderModel.h"
#include "PCAModel.h" #include "PCAModel.h"
#endif #endif
*/
namespace otb namespace otb
{ {
namespace Wrapper namespace Wrapper
...@@ -99,7 +99,7 @@ public: ...@@ -99,7 +99,7 @@ public:
typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType; typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType;
typedef otb::SOMModel<InputValueType, 5> SOM5DModelType; typedef otb::SOMModel<InputValueType, 5> SOM5DModelType;
/*
#ifdef OTB_USE_SHARK #ifdef OTB_USE_SHARK
typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType; typedef shark::Autoencoder< shark::TanhNeuron, shark::LinearNeuron> AutoencoderType;
typedef otb::AutoencoderModel<InputValueType, AutoencoderType> AutoencoderModelType; typedef otb::AutoencoderModel<InputValueType, AutoencoderType> AutoencoderModelType;
...@@ -109,7 +109,7 @@ public: ...@@ -109,7 +109,7 @@ public:
typedef otb::PCAModel<InputValueType> PCAModelType; typedef otb::PCAModel<InputValueType> PCAModelType;
#endif #endif
*/
protected: protected:
cbLearningApplicationBaseDR(); cbLearningApplicationBaseDR();
...@@ -136,7 +136,7 @@ private: ...@@ -136,7 +136,7 @@ private:
template <class somchoice> template <class somchoice>
void TrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); void TrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath);
void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath); void BeforeTrainSOM(typename ListSampleType::Pointer trainingListSample, std::string modelPath);
/*
#ifdef OTB_USE_SHARK #ifdef OTB_USE_SHARK
void InitAutoencoderParams(); void InitAutoencoderParams();
void InitPCAParams(); void InitPCAParams();
...@@ -148,7 +148,7 @@ private: ...@@ -148,7 +148,7 @@ private:
void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath); void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath);
#endif */ #endif
//@} //@}
}; };
...@@ -158,11 +158,11 @@ private: ...@@ -158,11 +158,11 @@ private:
#ifndef OTB_MANUAL_INSTANTIATION #ifndef OTB_MANUAL_INSTANTIATION
#include "cbLearningApplicationBaseDR.txx" #include "cbLearningApplicationBaseDR.txx"
#include "cbTrainSOM.txx" #include "cbTrainSOM.txx"
/*
#ifdef OTB_USE_SHARK #ifdef OTB_USE_SHARK
#include "cbTrainAutoencoder.txx" #include "cbTrainAutoencoder.txx"
#include "cbTrainPCA.txx" #include "cbTrainPCA.txx"
#endif*/ #endif
#endif #endif
#endif #endif
...@@ -50,12 +50,12 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> ...@@ -50,12 +50,12 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue>
InitSOMParams(); InitSOMParams();
/*
#ifdef OTB_USE_SHARK #ifdef OTB_USE_SHARK
InitAutoencoderParams(); InitAutoencoderParams();
InitPCAParams(); InitPCAParams();
#endif #endif
*/
} }
template <class TInputValue, class TOutputValue> template <class TInputValue, class TOutputValue>
...@@ -80,7 +80,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> ...@@ -80,7 +80,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue>
{ {
BeforeTrainSOM(trainingListSample,modelPath); BeforeTrainSOM(trainingListSample,modelPath);
} }
/*
if(modelName == "autoencoder") if(modelName == "autoencoder")
{ {
#ifdef OTB_USE_SHARK #ifdef OTB_USE_SHARK
...@@ -105,7 +105,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue> ...@@ -105,7 +105,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue>
#else #else
otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration."); otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration.");
#endif #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