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

SOM can now output the trained map in a txt file

parent ad08b84f
No related branches found
No related tags found
No related merge requests found
......@@ -60,6 +60,8 @@ public:
itkGetMacro(NumberOfIterations, unsigned int);
itkSetMacro(BetaInit, double);
itkGetMacro(BetaInit, double);
itkSetMacro(WriteMap, bool);
itkGetMacro(WriteMap, bool);
itkSetMacro(BetaEnd, double);
itkGetMacro(BetaEnd, double);
itkSetMacro(MinWeight, InputValueType);
......@@ -121,7 +123,8 @@ private:
SOMLearningBehaviorFunctorType m_BetaFunctor;
/** Behavior of the Neighborhood extent */
SOMNeighborhoodBehaviorFunctorType m_NeighborhoodSizeFunctor;
/** Write the SOM Map vectors in a txt file */
bool m_WriteMap;
};
......
......@@ -112,6 +112,24 @@ void SOMModel<TInputValue, MapDimension>::Save(const std::string & filename, con
++inputIterator;
}
ofs.close();
if (this->m_WriteMap == true) // output the map vectors in a txt file
{
std::ofstream otxt(filename+".txt");
inputIterator.GoToBegin();
while(!inputIterator.IsAtEnd())
{
InputSampleType vect = inputIterator.Get();
for (size_t i=0;i<vect.GetNumberOfElements();i++)
{
otxt << vect[i] << " ";
}
otxt << std::endl;
++inputIterator;
}
otxt.close();
}
}
template <class TInputValue, unsigned int MapDimension>
......
......@@ -120,6 +120,7 @@ void cbLearningApplicationBaseDR<TInputValue,TOutputValue>
std::cout << dim << std::endl;
dimredTrainer->SetNumberOfIterations(GetParameterInt("model.som.ni"));
dimredTrainer->SetBetaInit(GetParameterFloat("model.som.bi"));
dimredTrainer->SetWriteMap(true);
dimredTrainer->SetBetaEnd(GetParameterFloat("model.som.bf"));
dimredTrainer->SetMaxWeight(GetParameterFloat("model.som.iv"));
typename TemplateEstimatorType::SizeType size;
......
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