GenSVM
|
Header file for gensvm_optimize.c. More...
#include "gensvm_sv.h"
#include "gensvm_simplex.h"
#include "gensvm_update.h"
#include "gensvm_zv.h"
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... | |
Header file for gensvm_optimize.c.
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.
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.
[in,out] | model | the corresponding GenModel |
[in] | data | the corresponding GenData |
[in,out] | ZV | a 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.
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
[in,out] | model | the corresponding GenModel |
Definition at line 242 of file gensvm_optimize.c.
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.
[in] | model | a GenModel instance holding the model |
[in] | data | a GenData instance with the data |
[out] | ZV | a pre-allocated matrix of appropriate dimensions |
Definition at line 108 of file gensvm_zv.c.
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.
[in] | model | a GenModel instance holding the model |
[in] | data | a GenData instance with the data |
[out] | ZV | a pre-allocated matrix of appropriate dimensions |
Definition at line 70 of file gensvm_zv.c.
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.
[in] | model | GenModel structure which holds the current estimate V |
[in] | data | GenData structure |
[in] | work | allocated workspace with the ZV matrix to use |
Definition at line 155 of file gensvm_optimize.c.
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.
[in,out] | model | the GenModel to be trained. Contains optimal V on exit. |
[in] | data | the GenData to train the model with. |
Definition at line 56 of file gensvm_optimize.c.
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.
[in] | model | GenModel containing the augmented parameters |
Definition at line 206 of file gensvm_optimize.c.