From f68bd295ecf064c3c42b024398d0a4e9390a0e80 Mon Sep 17 00:00:00 2001 From: Cyrille Valladeau <cyrille.valladeau@c-s.fr> Date: Wed, 30 Apr 2008 13:28:38 +0000 Subject: [PATCH] Modif sur otbModel --- Code/Learning/otbSVMModel.h | 2 +- Code/Learning/otbSVMModel.txx | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Code/Learning/otbSVMModel.h b/Code/Learning/otbSVMModel.h index 0e795e4972..74acc7dc9b 100644 --- a/Code/Learning/otbSVMModel.h +++ b/Code/Learning/otbSVMModel.h @@ -435,7 +435,7 @@ public: return m_Model->sv_coef; } /** Set the alphas values (SV Coef) */ - void SetAlpha( double ** alpha ); + void SetAlpha( double ** alpha, int nbOfSupportVector ); /** Return the labels lists */ int * GetLabels(){ return m_Model->label; }; diff --git a/Code/Learning/otbSVMModel.txx b/Code/Learning/otbSVMModel.txx index e5001110f7..e31d721fb6 100644 --- a/Code/Learning/otbSVMModel.txx +++ b/Code/Learning/otbSVMModel.txx @@ -243,7 +243,6 @@ SVMModel<TInputPixel, TLabel> // Compute the total number of SV elements. unsigned int elements = 0; - // std::cout<<nbOfSupportVector<<std::endl; for (int p=0; p<nbOfSupportVector; p++) { std::cout<<p<<" "; @@ -251,13 +250,11 @@ SVMModel<TInputPixel, TLabel> std::cout<<p<<" "; while(tempNode->index != -1) { - //std::cout<<tempNode->value<<std::endl; tempNode++; elements++; } elements++;// for -1 values } - std::cout<<std::endl; if(m_Model->l>0) { @@ -287,11 +284,10 @@ SVMModel<TInputPixel, TLabel> this->Modified(); } -// BEFORE CALLING THE METHOD, CHANGE l VALUE template <class TInputPixel, class TLabel > void SVMModel<TInputPixel, TLabel> -::SetAlpha( double ** alpha ) +::SetAlpha( double ** alpha, int nbOfSupportVector ) { // Erase the old sv_coef for(int i=0; i<m_Model->nr_class-1; i++) @@ -300,6 +296,8 @@ SVMModel<TInputPixel, TLabel> } delete [] m_Model->sv_coef; + this->SetNumberOfSupportVectors(nbOfSupportVector); + // copy new sv_coef values m_Model->sv_coef = Malloc(double *,m_Model->nr_class-1); for(int i=0; i<m_Model->nr_class-1; i++) -- GitLab