KTA-tutorial.cpp
Go to the documentation of this file.
1 
6 
7 using namespace shark;
8 using namespace std;
9 
10 int main(int argc, char** argv)
11 {
12  // generate dataset
13  Chessboard problem; // artificial benchmark problem
15 
16  // define the family of kernel functions
17  double gamma = 0.5; // initial guess of the parameter value
18  GaussianRbfKernel<RealVector> kernel(gamma);
19 
20  // set up kernel target alignment as a function of the kernel parameters
21  // on the given data
22  KernelTargetAlignment<RealVector> kta(data,&kernel);
23 
24  // optimize parameters for best alignment
25  IRpropPlus rprop;
26  rprop.init(kta);
27  cout << "initial parameter: " << kernel.gamma() << endl;
28  for (size_t i=0; i<50; i++)
29  {
30  rprop.step(kta);
31  cout << "parameter after step " << (i+1) << ": " << kernel.gamma() << endl;
32  }
33  cout << "final parameter: " << kernel.gamma() << endl;
34 }