diff --git a/Code/Learning/otbSVMModel.h b/Code/Learning/otbSVMModel.h index 0e795e49727676a1445756abc2c062c8e6e83cbb..74acc7dc9bcd717f7e83815a9f4cd18908dc2d4c 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 e5001110f78cc43f3e5fa2ab64924e9a0bdc0c5e..e31d721fb6326c9b1d9ef6774a6f9de4c4370b73 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++)