PEGASOS (PEGASOS SVM solver) More...
#include "svmdataset.h"
Data Structures | |
struct | VlSvmObjective |
Binary Svm Objective Function. More... | |
struct | VlSvmPegasos |
Pegasos Svm Solver. More... |
Typedefs | |
typedef void(* | VlSvmDiagnostics )(void *svm) |
Pointer to a function called at each iteration for diagnostics purpose. |
Functions | |
vl_size | vl_svmpegasos_get_permutationsize (VlSvmPegasos const *self) |
Get permutation size. | |
Create and destroy | |
VlSvmPegasos * | vl_svmpegasos_new (vl_size dimension, double lambda) |
Create a new VlSvmPegasos structure. | |
void | vl_svmpegasos_delete (VlSvmPegasos *svm, vl_bool freeModel) |
Delete a VlSvmPegasos structure. | |
Training Fuctions | |
void | vl_svmpegasos_train (VlSvmPegasos *svm, void *data, vl_size numSamples, VlSvmDatasetInnerProduct innerProduct, VlSvmDatasetAccumulator accumulator, vl_int8 const *labels) |
void | vl_svmpegasos_train_validation_data (VlSvmPegasos *svm, void *data, vl_size numSamples, VlSvmDatasetInnerProduct innerProduct, VlSvmDatasetAccumulator accumulator, vl_int8 const *labels, void *validation, vl_size validationNumSamples, vl_int8 const *validationLabels) |
Retrieve data and parameters | |
double * | vl_svmpegasos_get_model (VlSvmPegasos const *self) |
Get svm model. | |
double | vl_svmpegasos_get_bias (VlSvmPegasos const *self) |
Get bias. | |
vl_size | vl_svmpegasos_get_dimension (VlSvmPegasos const *self) |
Get model dimension. | |
vl_size | vl_svmpegasos_get_iterations (VlSvmPegasos const *self) |
Get number of Iterations performed so far. | |
vl_size | vl_svmpegasos_get_maxiterations (VlSvmPegasos const *self) |
Get maximum number of iterations. | |
double | vl_svmpegasos_get_epsilon (VlSvmPegasos const *self) |
Get stopping criterion threshold. | |
double | vl_svmpegasos_get_lambda (VlSvmPegasos const *self) |
Get regularization parameter lambda. | |
double | vl_svmpegasos_get_bias_multiplier (VlSvmPegasos const *self) |
Get bias multiplier. | |
double | vl_svmpegasos_get_elapsed_time (VlSvmPegasos const *self) |
Get the execution time in seconds. | |
vl_size | vl_svmpegasos_get_energy_frequency (VlSvmPegasos const *self) |
Get how frequent the full energy is computed. | |
double | vl_svmpegasos_get_bias_learningrate (VlSvmPegasos const *self) |
Get bias learning rate. | |
VlSvmObjective * | vl_svmpegasos_get_objective (VlSvmPegasos const *self) |
Get svm objective energy. | |
VlRand * | vl_svmpegasos_get_random_generator (VlSvmPegasos const *self) |
Get random generator. | |
vl_uint32 * | vl_svmpegasos_get_permutation (VlSvmPegasos const *self) |
Get permutation. | |
vl_size | vl_svmpegasos_get_permutation_size (VlSvmPegasos const *self) |
VlSvmDiagnostics | vl_svmpegasos_get_diagnostic (VlSvmPegasos const *self) |
Get Diagnostic Function. | |
void * | vl_svmpegasos_get_diagnostic_caller_ref (VlSvmPegasos const *self) |
Get Diagnostic Function Caller Reference Object. | |
Set parameters | |
void | vl_svmpegasos_set_model (VlSvmPegasos *self, double *m) |
Set pegasos model. | |
void | vl_svmpegasos_set_bias (VlSvmPegasos *self, double b) |
Set pegasos bias. | |
void | vl_svmpegasos_set_maxiterations (VlSvmPegasos *self, vl_size i) |
Set pegasos max iterations. | |
void | vl_svmpegasos_set_iterations (VlSvmPegasos *self, vl_size i) |
Set pegasos performed iterations. | |
void | vl_svmpegasos_set_epsilon (VlSvmPegasos *self, double e) |
Set pegasos stopping criterion threshold. | |
void | vl_svmpegasos_set_lambda (VlSvmPegasos *self, double l) |
Set lambda. | |
void | vl_svmpegasos_set_bias_multiplier (VlSvmPegasos *self, double b) |
Set bias multiplier. | |
void | vl_svmpegasos_set_energy_frequency (VlSvmPegasos *self, vl_size e) |
Set how frequent the full energy is computed. | |
void | vl_svmpegasos_set_bias_learningrate (VlSvmPegasos *self, double blr) |
Set bias learning rate. | |
void | vl_svmpegasos_set_random_generator (VlSvmPegasos *self, VlRand *r) |
Set random generator. | |
void | vl_svmpegasos_set_permutation (VlSvmPegasos *self, vl_uint32 *p, vl_size psize) |
Set permutation. | |
void | vl_svmpegasos_set_diagnostic (VlSvmPegasos *self, VlSvmDiagnostics d, void *cr) |
Set Diagnostic Function. |
Detailed Description
Typedef Documentation
VlSvmDiagnostics |
This type defines a function will be called at each iteration of the algorithm. The parameter svm is an instance of the Svm Status VlSvmPegasos.
Function Documentation
void vl_svmpegasos_delete | ( | VlSvmPegasos * | svm, |
vl_bool | freeModel | ||
) |
- Parameters:
-
@ref VlSvmPegasos structure.
The function frees the resources allocated by vl_svmpegasos_new().
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- bias value.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- bias learning rate.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- bias multiplier.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- pointer to diagnostic function.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- pointer to diagnostic function caller reference object.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- model dimension without considering the bias value.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- elapsed time.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- energy computation frequency.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- stopping criterion threshold.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- number of iterations performed so far.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- lambda.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- maximum number of iterations.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- pointer to model.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- objective energy.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- permutation.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- permutation size.
|
inline |
- Parameters:
-
self Pegasos Svm Solver.
- Returns:
- random generator.
VlSvmPegasos* vl_svmpegasos_new | ( | vl_size | dimension, |
double | lambda | ||
) |
- Parameters:
-
dimension svm model dimension. lambda pegasos regularization parameter.
This function allocates and returns a new VlSvmPegasos structure.
- Returns:
- the new VlSvmPegasos structure.
- See also:
- vl_svmpegasos_delete
|
inline |
- Parameters:
-
self Pegasos Svm Solver. b bias.
|
inline |
- Parameters:
-
self Pegasos Svm Solver. blr bias learning rate.
|
inline |
- Parameters:
-
self Pegasos Svm Solver. b bias multiplier.
|
inline |
- Parameters:
-
self Pegasos Svm Solver. d Diagnostic Function. cr Diagnostic Function Caller Reference.
|
inline |
- Parameters:
-
self Pegasos Svm Solver. e energy compuation frequency.
|
inline |
- Parameters:
-
self Pegasos Svm Solver. e stopping criterion threshold.
|
inline |
- Parameters:
-
self Pegasos Svm Solver. i pegasos performed iterations.
|
inline |
- Parameters:
-
self Pegasos Svm Solver. l lambda.
|
inline |
- Parameters:
-
self Pegasos Svm Solver. i pegasos max iterations.
|
inline |
- Parameters:
-
self Pegasos Svm Solver. m svm model.
If there is a model already allocated, this method frees it before substituting it with the new one.
|
inline |
- Parameters:
-
self Pegasos Svm Solver. p permutation. psize permutation size.
|
inline |
- Parameters:
-
self Pegasos Svm Solver. r random generator.
vl_svmpegasos_train | ( | VlSvmPegasos * | svm, |
void * | data, | ||
vl_size | numSamples, | ||
VlSvmDatasetInnerProduct | innerProduct, | ||
VlSvmDatasetAccumulator | accumulator, | ||
vl_int8 const * | labels | ||
) |
- Parameters:
-
svm (in & out) svm status. data training vectors. numSamples number of training data vectors. innerProduct function defining the innerProduct between the model and a data point. accumulator function definint the sum between the model and a data point. labels labels of the training vectors.
The function runs PEGASOS on the specified data. The structure svm should be initialized using vl_svmpegasos_new. The vector svm->model must have the dimension equal to svm->dimension. if a bias is used, svm->biasMultiplier must be non-zero, and the output value will be saved in svm->bias.
The function runs PEGASOS for iterations t in the interval [svm->iterations, svm->maxIterations]. If the intial status is initializied using vl_svmpegasos_new svm->iterations is equal to zero.
PEGASOS select the next point for computing the gradient at random. If svm->randomGenerator is NULL
, the default random generator (as returned by vl_get_rand()) is used.
Alternatively, if svm->permutation is not NULL
, then points are sampled in the order specified by this vector of indexes (this is cycled through). In this way It is an error to set both svm->randomGenerator and svm->permutation to non-null values.
See the Overview overview for details.
vl_svmpegasos_train_validation_data | ( | VlSvmPegasos * | svm, |
void * | data, | ||
vl_size | numSamples, | ||
VlSvmDatasetInnerProduct | innerProduct, | ||
VlSvmDatasetAccumulator | accumulator, | ||
vl_int8 const * | labels, | ||
void * | validation, | ||
vl_size | validationNumSamples, | ||
vl_int8 const * | validationLabels | ||
) |
- Parameters:
-
svm (in & out) svm status. data training vectors. numSamples number of training data vectors. innerProduct function defining the innerProduct between the model and a data point. accumulator function definint the sum between the model and a data point. labels labels of the training vectors. validation validation data. validationNumSamples number of validation data vectors. validationLabels labels of the validation data.
The function is the same algorithm of vl_svmpegasos_train, but computes the objective function statistics on a validation dataset, instead of using the training dataset also for this purpose.
- See also:
- vl_svmpegasos_train