Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Main Repositories
otb
Commits
a30fb6f2
Commit
a30fb6f2
authored
Jun 20, 2017
by
Cédric Traizet
Browse files
som is now a machine learning model, ae and pca have been deactiveted
parent
b108c5b3
Changes
9
Hide whitespace changes
Inline
Side-by-side
app/cbDimensionalityReductionTrainer.cxx
View file @
a30fb6f2
...
...
@@ -9,7 +9,7 @@
#include
"otbShiftScaleSampleListFilter.h"
#include
"otbStatisticsXMLFileReader.h"
#include
"otbSharkUtils.h"
//
#include "otbSharkUtils.h"
#include
<fstream>
// write the model file
...
...
include/AutoencoderModel.txx
View file @
a30fb6f2
#ifndef AutoencoderModel_txx
#define AutoencoderModel_txx
...
...
include/DimensionalityReductionModelFactory.h
View file @
a30fb6f2
...
...
@@ -20,7 +20,7 @@
#include
"DimensionalityReductionModel.h"
#include
"otbMachineLearningModelFactoryBase.h"
namespace
otb
{
/** \class MachineLearningModelFactory
...
...
include/DimensionalityReductionModelFactory.txx
View file @
a30fb6f2
...
...
@@ -22,25 +22,25 @@
#include "otbConfigure.h"
#include "SOMModelFactory.h"
/*
#ifdef OTB_USE_SHARK
#include "AutoencoderModelFactory.h"
#include "PCAModelFactory.h"
#endif
*/
#include "itkMutexLockHolder.h"
namespace otb
{
/*
template <class TInputValue, class TTargetValue>
using AutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::Autoencoder<shark::TanhNeuron, shark::LinearNeuron>> ;
template <class TInputValue, class TTargetValue>
using TiedAutoencoderModelFactory = AutoencoderModelFactoryBase<TInputValue, TTargetValue, shark::TiedAutoencoder< shark::TanhNeuron, shark::LinearNeuron>> ;
*/
template <class TInputValue, class TTargetValue>
using SOM2DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 2> ;
...
...
@@ -115,13 +115,13 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue>
RegisterFactory(SOM3DModelFactory<TInputValue,TOutputValue>::New());
RegisterFactory(SOM4DModelFactory<TInputValue,TOutputValue>::New());
RegisterFactory(SOM5DModelFactory<TInputValue,TOutputValue>::New());
/*
#ifdef OTB_USE_SHARK
RegisterFactory(PCAModelFactory<TInputValue,TOutputValue>::New());
RegisterFactory(AutoencoderModelFactory<TInputValue,TOutputValue>::New());
RegisterFactory(TiedAutoencoderModelFactory<TInputValue,TOutputValue>::New());
#endif
*/
}
template <class TInputValue, class TOutputValue>
...
...
@@ -182,6 +182,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue>
itk::ObjectFactoryBase::UnRegisterFactory(som2dFactory);
continue;
}
/*
#ifdef OTB_USE_SHARK
// Autoencoder
...
...
@@ -210,7 +211,7 @@ DimensionalityReductionModelFactory<TInputValue,TOutputValue>
continue;
}
#endif
*/
}
}
...
...
include/SOMModel.h
View file @
a30fb6f2
#ifndef SOMModel_h
#define SOMModel_h
#include
"DimensionalityReductionModel.h"
//
#include "DimensionalityReductionModel.h"
#include
"otbSOMMap.h"
#include
"otbSOM.h"
...
...
@@ -11,38 +11,45 @@
#include
"otbCzihoSOMLearningBehaviorFunctor.h"
#include
"otbCzihoSOMNeighborhoodBehaviorFunctor.h"
#include
"otbMachineLearningModelTraits.h"
#include
"otbMachineLearningModel.h"
namespace
otb
{
template
<
class
TInputValue
,
unsigned
int
MapDimension
>
class
ITK_EXPORT
SOMModel
:
public
DimensionalityReductionModel
<
TInputValue
,
TInputValue
>
class
ITK_EXPORT
SOMModel
:
public
MachineLearningModel
<
itk
::
VariableLengthVector
<
TInputValue
>
,
itk
::
VariableLengthVector
<
TInputValue
>
>
{
public:
typedef
SOMModel
Self
;
typedef
DimensionalityReductionModel
<
TInputValue
,
TInputValue
>
Superclass
;
typedef
MachineLearningModel
<
itk
::
VariableLengthVector
<
TInputValue
>
,
itk
::
VariableLengthVector
<
TInputValue
>
>
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
typedef
typename
Superclass
::
InputValueType
InputValueType
;
typedef
typename
Superclass
::
InputSampleType
InputSampleType
;
typedef
typename
Superclass
::
InputListSampleType
InputListSampleType
;
typedef
typename
InputListSampleType
::
Pointer
ListSamplePointerType
;
typedef
typename
Superclass
::
TargetValueType
TargetValueType
;
typedef
typename
Superclass
::
TargetSampleType
TargetSampleType
;
typedef
typename
Superclass
::
TargetListSampleType
TargetListSampleType
;
typedef
typename
Superclass
::
InputValueType
InputValueType
;
typedef
typename
Superclass
::
InputSampleType
InputSampleType
;
typedef
typename
Superclass
::
InputListSampleType
InputListSampleType
;
typedef
typename
InputListSampleType
::
Pointer
ListSamplePointerType
;
typedef
typename
Superclass
::
TargetValueType
TargetValueType
;
typedef
typename
Superclass
::
TargetSampleType
TargetSampleType
;
typedef
typename
Superclass
::
TargetListSampleType
TargetListSampleType
;
typedef
SOMMap
<
itk
::
VariableLengthVector
<
TInputValue
>
,
itk
::
Statistics
::
EuclideanDistanceMetric
<
itk
::
VariableLengthVector
<
TInputValue
>>
,
MapDimension
>
MapType
;
typedef
typename
MapType
::
SizeType
SizeType
;
typedef
typename
MapType
::
SpacingType
SpacingType
;
/// Confidence map related typedefs
typedef
otb
::
SOM
<
InputListSampleType
,
MapType
>
EstimatorType
;
typedef
typename
Superclass
::
ConfidenceValueType
ConfidenceValueType
;
typedef
typename
Superclass
::
ConfidenceSampleType
ConfidenceSampleType
;
typedef
typename
Superclass
::
ConfidenceListSampleType
ConfidenceListSampleType
;
typedef
Functor
::
CzihoSOMLearningBehaviorFunctor
SOMLearningBehaviorFunctorType
;
typedef
Functor
::
CzihoSOMNeighborhoodBehaviorFunctor
SOMNeighborhoodBehaviorFunctorType
;
typedef
SOMMap
<
itk
::
VariableLengthVector
<
TInputValue
>
,
itk
::
Statistics
::
EuclideanDistanceMetric
<
itk
::
VariableLengthVector
<
TInputValue
>>
,
MapDimension
>
MapType
;
typedef
typename
MapType
::
SizeType
SizeType
;
typedef
typename
MapType
::
SpacingType
SpacingType
;
typedef
otb
::
SOM
<
InputListSampleType
,
MapType
>
EstimatorType
;
typedef
Functor
::
CzihoSOMLearningBehaviorFunctor
SOMLearningBehaviorFunctorType
;
typedef
Functor
::
CzihoSOMNeighborhoodBehaviorFunctor
SOMNeighborhoodBehaviorFunctorType
;
itkNewMacro
(
Self
);
itkTypeMacro
(
SOMModel
,
DimensionalityReductionModel
);
...
...
@@ -72,8 +79,8 @@ public:
bool
CanReadFile
(
const
std
::
string
&
filename
);
bool
CanWriteFile
(
const
std
::
string
&
filename
);
void
Save
(
const
std
::
string
&
filename
,
const
std
::
string
&
name
=
""
)
ITK_OVERRIDE
;
void
Load
(
const
std
::
string
&
filename
,
const
std
::
string
&
name
=
""
)
ITK_OVERRIDE
;
void
Save
(
const
std
::
string
&
filename
,
const
std
::
string
&
name
=
""
)
;
void
Load
(
const
std
::
string
&
filename
,
const
std
::
string
&
name
=
""
)
;
void
Train
()
ITK_OVERRIDE
;
//void Dimensionality_reduction() {}; // Dimensionality reduction is done by DoPredict
...
...
@@ -83,11 +90,10 @@ protected:
SOMModel
();
~
SOMModel
()
ITK_OVERRIDE
;
virtual
TargetSampleType
DoPredict
(
const
InputSampleType
&
input
)
const
ITK_OVERRIDE
;
private:
typename
MapType
::
Pointer
m_SOMMap
;
virtual
TargetSampleType
DoPredict
(
const
InputSampleType
&
input
,
ConfidenceValueType
*
quality
=
ITK_NULLPTR
)
const
;
/** Map Parameters used for training */
...
...
include/SOMModel.txx
View file @
a30fb6f2
#ifndef SOMModel_txx
#define SOMModel_txx
...
...
@@ -177,7 +176,7 @@ void SOMModel<TInputValue, MapDimension>::Load(const std::string & filename, con
template <class TInputValue, unsigned int MapDimension>
typename SOMModel<TInputValue, MapDimension>::TargetSampleType
SOMModel<TInputValue, MapDimension>::DoPredict(const InputSampleType & value) const
SOMModel<TInputValue, MapDimension>::DoPredict(const InputSampleType & value
, ConfidenceValueType * quality
) const
{
unsigned int dimension =MapType::ImageDimension;
TargetSampleType target;
...
...
include/cbLearningApplicationBaseDR.h
View file @
a30fb6f2
...
...
@@ -15,12 +15,12 @@
#include
"DimensionalityReductionModelFactory.h"
#include
"SOMModel.h"
/*
#ifdef OTB_USE_SHARK
#include "AutoencoderModel.h"
#include "PCAModel.h"
#endif
*/
namespace
otb
{
namespace
Wrapper
...
...
@@ -99,7 +99,7 @@ public:
typedef
SOMMap
<
itk
::
VariableLengthVector
<
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 otb::AutoencoderModel<InputValueType, AutoencoderType> AutoencoderModelType;
...
...
@@ -109,7 +109,7 @@ public:
typedef otb::PCAModel<InputValueType> PCAModelType;
#endif
*/
protected:
cbLearningApplicationBaseDR
();
...
...
@@ -131,11 +131,15 @@ private:
/** Specific Init and Train methods for each machine learning model */
//@{
void
InitSOMParams
();
template
<
class
somchoice
>
void
TrainSOM
(
typename
ListSampleType
::
Pointer
trainingListSample
,
std
::
string
modelPath
);
void
BeforeTrainSOM
(
typename
ListSampleType
::
Pointer
trainingListSample
,
std
::
string
modelPath
);
/*
#ifdef OTB_USE_SHARK
void InitAutoencoderParams();
void InitPCAParams();
void
InitSOMParams
();
void BeforeTrainAutoencoder(typename ListSampleType::Pointer trainingListSample, std::string modelPath);
template <class autoencoderchoice>
...
...
@@ -143,10 +147,8 @@ private:
void TrainPCA(typename ListSampleType::Pointer trainingListSample, std::string modelPath);
template
<
class
somchoice
>
void
TrainSOM
(
typename
ListSampleType
::
Pointer
trainingListSample
,
std
::
string
modelPath
);
void
BeforeTrainSOM
(
typename
ListSampleType
::
Pointer
trainingListSample
,
std
::
string
modelPath
);
#endif
#endif */
//@}
};
...
...
@@ -156,10 +158,11 @@ private:
#ifndef OTB_MANUAL_INSTANTIATION
#include
"cbLearningApplicationBaseDR.txx"
#include
"cbTrainSOM.txx"
/*
#ifdef OTB_USE_SHARK
#include "cbTrainAutoencoder.txx"
#include "cbTrainPCA.txx"
#endif
#endif
*/
#endif
#endif
include/cbLearningApplicationBaseDR.txx
View file @
a30fb6f2
...
...
@@ -50,11 +50,12 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue>
InitSOMParams();
/*
#ifdef OTB_USE_SHARK
InitAutoencoderParams();
InitPCAParams();
#endif
*/
}
template <class TInputValue, class TOutputValue>
...
...
@@ -79,7 +80,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue>
{
BeforeTrainSOM(trainingListSample,modelPath);
}
/*
if(modelName == "autoencoder")
{
#ifdef OTB_USE_SHARK
...
...
@@ -104,7 +105,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue>
#else
otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration.");
#endif
}
}
*/
}
}
...
...
otb-module.cmake
View file @
a30fb6f2
...
...
@@ -6,9 +6,9 @@ otb_module(CbDimensionalityReduction
OTBITK
OTBShark
OTBBoost
OTBSupervised
OTBAppClassification
OTBSOM
OTBLearningBase
DESCRIPTION
"
${
DOCUMENTATION
}
"
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment