Commit 98e98ec2 authored by Cyrille Valladeau's avatar Cyrille Valladeau

Modification de svm : ajout des tests.

parent a6b48b15
......@@ -93,7 +93,19 @@ ADD_TEST(utTvSvmGenericKernelBasicOperationsTest ${UTILITIES_TESTS}
)
ADD_TEST(utTvSvmComposedKernelFunctorTest ${UTILITIES_TESTS}
--compare-n-ascii ${TOL} 3
${BASELINE_FILES}/utTvSVMComposedKernelFunctorResTest.txt
${TEMP}/SVMComposedKernelFunctorTestRes.txt
${BASELINE_FILES}/utTvSVMComposedKernelFunctorTest.txt
${TEMP}/SVMComposedKernelFunctorTestOutputBis.txt
${BASELINE_FILES}/utTvSVMComposedKernelFunctorTest.txt
${TEMP}/SVMComposedKernelFunctorTestOutputBis.txt
otbSVMComposedKernelFunctorTest
${TEMP}/SVMComposedKernelFunctorTestRes.txt
${TEMP}/SVMComposedKernelFunctorTestOutput.txt
${TEMP}/SVMComposedKernelFunctorTestOutputBis.txt
)
# ------- lib otb6S ------------------------------
......
......@@ -23,6 +23,7 @@
#include "itkExceptionObject.h"
#include "otbImage.h"
#include <iostream>
#include <fstream>
#include "otbSVMModel.h"
#include "otbSVMKernels.h"
......@@ -114,33 +115,49 @@ int otbSVMComposedKernelFunctorTest( int argc, char* argv[] )
y[1].value = 10000;
double resAdd =0.;
double resMul =0.;
double res1 = 0.;
double res2 = 0.;
std::ofstream file;
file.open(argv[1]);
file<<"Inputs Values: 10, 5, Inputs Ponderation: 1.5, 2"<<std::endl;
file<<std::endl;
file<<"Functor Results:"<<std::endl;
res1 = customFunctor(SVx[0], SVy[0], model->param);
std::cout<<"customFunctor : "<<res1<<std::endl;
file<<"Custom Functor only: "<<res1<<std::endl;
//std::cout<<"customFunctor : "<<res1<<std::endl;
res2 = SAMFunctor(SVx[0], SVy[0], model->param);
std::cout<<"SAMFunctor : "<<res2<<std::endl;
file<<"SAM Functor only: "<<res2<<std::endl;
//std::cout<<"SAMFunctor : "<<res2<<std::endl;
file<<"Composed Functor: "<<std::endl;
resAdd = (*(svmModel->GetModel()->param.kernel_composed))(SVx[0], SVy[0], svmModel->GetModel()->param);
std::cout<<"composed : "<<resAdd<<std::endl;
//std::cout<<"composed : "<<resAdd<<std::endl;
svmModel->GetModel()->param.kernel_composed->SetMultiplyKernelFunctor(true);
resAdd = (*(svmModel->GetModel()->param.kernel_composed))(SVx[0], SVy[0], svmModel->GetModel()->param);
resMul = (*(svmModel->GetModel()->param.kernel_composed))(SVx[0], SVy[0], svmModel->GetModel()->param);
//std::cout<<"composed : "<<resAdd<<std::endl;
file<<"Addition: "<<resAdd<<", "<<"Multiplication: "<<resMul<<std::endl;
std::cout<<"composed : "<<resAdd<<std::endl;
file.close();
svmModel->GetModel()->param.kernel_composed->print_parameters();
//svmModel->GetModel()->param.kernel_composed->print_parameters();
svmModel->SaveModel("test.txt");
svmModel->SaveModel(argv[2]);
ModelType::Pointer svmModelBis = ModelType::New();
svmModelBis->LoadModel("test.txt");
svmModelBis->LoadModel(argv[2]);
svmModelBis->GetModel()->param.kernel_composed->print_parameters();
//svmModelBis->GetModel()->param.kernel_composed->print_parameters();
svmModelBis->SaveModel("testBis.txt");
svmModelBis->SaveModel(argv[3]);
return EXIT_SUCCESS;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment