GenSVM
Macros | Functions
gensvm_optimize.c File Reference

Main functions for training the GenSVM solution. More...

#include "gensvm_optimize.h"
Include dependency graph for gensvm_optimize.c:

Go to the source code of this file.

Macros

#define GENSVM_PRINT_ITER   100
 

Functions

void gensvm_optimize (struct GenModel *model, struct GenData *data)
 The main training loop for GenSVM. More...
 
double gensvm_get_loss (struct GenModel *model, struct GenData *data, struct GenWork *work)
 Calculate the current value of the loss function. More...
 
void gensvm_step_doubling (struct GenModel *model)
 Use step doubling. More...
 
void gensvm_calculate_huber (struct GenModel *model)
 Calculate the Huber hinge errors. More...
 
void gensvm_calculate_errors (struct GenModel *model, struct GenData *data, double *ZV)
 Calculate the scalar errors. More...
 

Detailed Description

Main functions for training the GenSVM solution.

Author
G.J.J. van den Burg
Date
2013-08-09

Contains update and loss functions used to actually find the optimal V.

This file is part of GenSVM.

GenSVM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

GenSVM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GenSVM. If not, see http://www.gnu.org/licenses/.

Definition in file gensvm_optimize.c.

Macro Definition Documentation

◆ GENSVM_PRINT_ITER

#define GENSVM_PRINT_ITER   100

Iteration frequency with which to print to stdout

Definition at line 37 of file gensvm_optimize.c.

Function Documentation

◆ gensvm_calculate_errors()

void gensvm_calculate_errors ( struct GenModel model,
struct GenData data,
double *  ZV 
)

Calculate the scalar errors.

Calculate the scalar errors q based on the current estimate of V, and store these in Q. It is assumed that the memory for Q has already been allocated. In addition, the matrix ZV is calculated here. It is assigned to a pre-allocated block of memory, which is passed to this function.

Parameters
[in,out]modelthe corresponding GenModel
[in]datathe corresponding GenData
[in,out]ZVa pointer to a memory block for ZV. On exit this block is updated with the new ZV matrix calculated with GenModel::V

Definition at line 277 of file gensvm_optimize.c.

Here is the call graph for this function:

◆ gensvm_calculate_huber()

void gensvm_calculate_huber ( struct GenModel model)

Calculate the Huber hinge errors.

For each of the scalar errors in Q the Huber hinge errors are calculated. The Huber hinge is here defined as

\[ h(q) = \begin{dcases} 1 - q - \frac{\kappa + 1}{2} & \text{if } q \leq -\kappa \\ \frac{1}{2(\kappa + 1)} ( 1 - q)^2 & \text{if } q \in (-\kappa, 1] \\ 0 & \text{if } q > 1 \end{dcases} \]

Parameters
[in,out]modelthe corresponding GenModel

Definition at line 242 of file gensvm_optimize.c.

◆ gensvm_get_loss()

double gensvm_get_loss ( struct GenModel model,
struct GenData data,
struct GenWork work 
)

Calculate the current value of the loss function.

The current loss function value is calculated based on the matrix V in the given model. Note that the matrix ZV is passed explicitly to avoid having to reallocate memory at every step.

Parameters
[in]modelGenModel structure which holds the current estimate V
[in]dataGenData structure
[in]workallocated workspace with the ZV matrix to use
Returns
the current value of the loss function

Definition at line 155 of file gensvm_optimize.c.

Here is the call graph for this function:

◆ gensvm_optimize()

void gensvm_optimize ( struct GenModel model,
struct GenData data 
)

The main training loop for GenSVM.

This function is the main training function. This function handles the optimization of the model with the given model parameters, with the data given. On return the matrix GenModel::V contains the optimal weight matrix.

In this function, step doubling is used in the majorization algorithm after a burn-in of 50 iterations.

Parameters
[in,out]modelthe GenModel to be trained. Contains optimal V on exit.
[in]datathe GenData to train the model with.

Definition at line 56 of file gensvm_optimize.c.

Here is the call graph for this function:

◆ gensvm_step_doubling()

void gensvm_step_doubling ( struct GenModel model)

Use step doubling.

Step doubling can be used to speed up the maorization algorithm. Instead of using the value at the minimimum of the majorization function, the value ``opposite'' the majorization point is used. This can essentially cut the number of iterations necessary to reach the minimum in half.

Parameters
[in]modelGenModel containing the augmented parameters

Definition at line 206 of file gensvm_optimize.c.