GenSVM
Functions
gensvm_optimize.h File Reference

Header file for gensvm_optimize.c. More...

#include "gensvm_sv.h"
#include "gensvm_simplex.h"
#include "gensvm_update.h"
#include "gensvm_zv.h"
Include dependency graph for gensvm_optimize.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

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_calculate_errors (struct GenModel *model, struct GenData *data, double *ZV)
 Calculate the scalar errors. More...
 
void gensvm_calculate_ZV_dense (struct GenModel *model, struct GenData *data, double *ZV)
 Compute the product Z*V for when Z is a dense matrix. More...
 
void gensvm_calculate_ZV_sparse (struct GenModel *model, struct GenData *data, double *ZV)
 Compute the product Z*V for when Z is a sparse matrix. More...
 
void gensvm_calculate_huber (struct GenModel *model)
 Calculate the Huber hinge errors. More...
 
void gensvm_step_doubling (struct GenModel *model)
 Use step doubling. More...
 

Detailed Description

Header file for gensvm_optimize.c.

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

Contains function declarations for functions used to train a single GenModel.

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.h.

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_calculate_ZV_dense()

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

Compute the product Z*V for when Z is a dense matrix.

This function uses cblas_dgemm() to compute the matrix product between Z and V.

Parameters
[in]modela GenModel instance holding the model
[in]dataa GenData instance with the data
[out]ZVa pre-allocated matrix of appropriate dimensions

Definition at line 108 of file gensvm_zv.c.

◆ gensvm_calculate_ZV_sparse()

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

Compute the product Z*V for when Z is a sparse matrix.

This is a simple sparse-dense matrix multiplication, which uses cblas_daxpy() for each nonzero element of Z, to compute Z*V.

Parameters
[in]modela GenModel instance holding the model
[in]dataa GenData instance with the data
[out]ZVa pre-allocated matrix of appropriate dimensions

Definition at line 70 of file gensvm_zv.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.