SVM Dataset. More...
Typedefs | |
typedef OPAQUE | VlSvmDataset |
SVM dataset object. More... | |
SVM callbacks | |
typedef void(* | VlSvmDiagnosticFunction) (struct VlSvm_ *svm, void *data) |
SVM diagnostic function pointer. More... | |
typedef double(* | VlSvmLossFunction) (double inner, double label) |
SVM loss function pointer. More... | |
typedef double(* | VlSvmDcaUpdateFunction) (double alpha, double inner, double norm2, double label) |
SVM SDCA update function pointer. More... | |
typedef double(* | VlSvmInnerProductFunction) (const void *data, vl_uindex element, double *model) |
Pointer to a function that defines the inner product between the data point at position element and the SVM model. | |
typedef void(* | VlSvmAccumulateFunction) (const void *data, vl_uindex element, double *model, double multiplier) |
Pointer to a function that adds to model the data point at position element multiplied by the constant multiplier. | |
Functions | |
Create and destroy | |
VlSvmDataset * | vl_svmdataset_new (vl_type dataType, void *data, vl_size dimension, vl_size numData) |
Create a new object wrapping a dataset. More... | |
void | vl_svmdataset_delete (VlSvmDataset *dataset) |
Delete the object. More... | |
Set parameters | |
void | vl_svmdataset_set_homogeneous_kernel_map (VlSvmDataset *self, VlHomogeneousKernelMap *hom) |
Set the homogeneous kernel map object. More... | |
Get data and parameters | |
void * | vl_svmdataset_get_data (VlSvmDataset const *self) |
Get the wrapped data. More... | |
vl_size | vl_svmdataset_get_num_data (VlSvmDataset const *self) |
Get the number of wrapped data elements. More... | |
vl_size | vl_svmdataset_get_dimension (VlSvmDataset const *self) |
Get the dimension of the wrapped data. More... | |
void * | vl_svmdataset_get_map (VlSvmDataset const *self) |
vl_size | vl_svmdataset_get_mapDim (VlSvmDataset const *self) |
VlSvmAccumulateFunction | vl_svmdataset_get_accumulate_function (VlSvmDataset const *self) |
Get the accumulate function. More... | |
VlSvmInnerProductFunction | vl_svmdataset_get_inner_product_function (VlSvmDataset const *self) |
Get the inner product function. More... | |
VlHomogeneousKernelMap * | vl_svmdataset_get_homogeneous_kernel_map (VlSvmDataset const *self) |
Get the homogeneous kernel map object. More... | |
Detailed Description
The SVM solver object VlSvm, supporting SVM learning in VLFeat, uses an abstraction mechanism to work on arbitrary data types. This module provides an helper object, VlSvmDataset, that simplify taking advantage of this functionality, supporting for example different data types and the computation of feature maps out of the box.
Getting started
As discussed in Advanced SVM topics, most linear SVM solvers, such as the ones implemented in VLFeat in Support Vector Machines (SVM), require only two operations to be defined on the data:
- Inner product between a data point \(\bx\) and the model vector \(\bw\). This is implemented by a function of type VlSvmInnerProductFunction.
- Accumulation of a dataobint \(\bx\) to the model vector \(\bw\): \(\bw \leftarrow \bw + \alpha \bx\). This is implemented by a function of the type VlSvmAccumulateFunction .
The SVM solver needs to know nothing about the data once these two operations are defined. These functions can do any number of things, such as supporting different formats for the data (dense or sparse, float or double), computing feature maps, or expanding compressed representations such as Product Quantization.
VLFeat provides the helper object VlSvmDataset to support some of these functionalities out of the box (it is important to remark that its use with the SVM solver VlSvm is entirely optional).
Presently, VlSvmDataset supports:
float
anddouble
dense arrays.- The on-the-fly application of the homogeneous kernel map to implement additive non-linear kernels (see Homogeneous kernel map).
For example, to learn a linear SVM on SINGLE data:
Typedef Documentation
◆ VlSvmDataset
This objects contain a training set to be used in combination with the SVM solver object VlSvm. Its main purpose is to implement the two basic operations inner product (VlSvmInnerProductFunction) and accumulation (VlSvmAccumulateFunction).
See Support Vector Machines (SVM) and Advanced SVM topics for further information.
◆ VlSvmDcaUpdateFunction
VlSvmDcaUpdateFunction |
- Parameters
-
alpha current value of the dual variable. inner inner product \(\bw^\top \bx\) of the sample with the SVM model. norm2 normalization factor \(\|\bx\|^2/\lambda n\). label label \(y\) of the sample.
- Returns
- incremental update \(\Delta\alpha\) of the dual variable.
◆ VlSvmDiagnosticFunction
VlSvmDiagnosticFunction |
- Parameters
-
svm is an instance of VlSvm .
◆ VlSvmLossFunction
VlSvmLossFunction |
- Parameters
-
inner inner product between sample and model \(\bw^\top \bx\). label sample label \(y\).
- Returns
- value of the loss.
The interface is the same for a loss function, its derivative, or the conjugate loss.
- See also
- SVM fundamentals
Function Documentation
◆ vl_svmdataset_delete()
void vl_svmdataset_delete | ( | VlSvmDataset * | self | ) |
- Parameters
-
self object to delete.
The function frees the resources allocated by vl_svmdataset_new(). Notice that the wrapped data will not be freed as it is not owned by the object.
◆ vl_svmdataset_get_accumulate_function()
VlSvmAccumulateFunction vl_svmdataset_get_accumulate_function | ( | VlSvmDataset const * | self | ) |
- Parameters
-
self object.
- Returns
- a pointer to the accumulate function to use with this data.
◆ vl_svmdataset_get_data()
void* vl_svmdataset_get_data | ( | VlSvmDataset const * | self | ) |
- Parameters
-
self object.
- Returns
- a pointer to the wrapped data.
◆ vl_svmdataset_get_dimension()
vl_size vl_svmdataset_get_dimension | ( | VlSvmDataset const * | self | ) |
- Parameters
-
self object.
- Returns
- dimension of the wrapped data.
◆ vl_svmdataset_get_homogeneous_kernel_map()
VlHomogeneousKernelMap* vl_svmdataset_get_homogeneous_kernel_map | ( | VlSvmDataset const * | self | ) |
- Parameters
-
self object.
- Returns
- homogenoeus kernel map object (or
NULL
if any).
◆ vl_svmdataset_get_inner_product_function()
VlSvmInnerProductFunction vl_svmdataset_get_inner_product_function | ( | VlSvmDataset const * | self | ) |
- Parameters
-
self object.
- Returns
- a pointer to the inner product function to use with this data.
◆ vl_svmdataset_get_num_data()
vl_size vl_svmdataset_get_num_data | ( | VlSvmDataset const * | self | ) |
- Parameters
-
self object.
- Returns
- number of wrapped data elements.
◆ vl_svmdataset_new()
VlSvmDataset* vl_svmdataset_new | ( | vl_type | dataType, |
void * | data, | ||
vl_size | dimension, | ||
vl_size | numData | ||
) |
- Parameters
-
dataType of data ( float
anddouble
supported).data pointer to the data. dimension the dimension of a data vector. numData number of wrapped data vectors.
- Returns
- new object.
The function allocates and returns a new SVM dataset object wrapping the data pointed by data. Note that no copy is made of data, so the caller should keep the data allocated as the object exists.
- See also
- vl_svmdataset_delete
◆ vl_svmdataset_set_homogeneous_kernel_map()
void vl_svmdataset_set_homogeneous_kernel_map | ( | VlSvmDataset * | self, |
VlHomogeneousKernelMap * | hom | ||
) |
- Parameters
-
self object. hom homogeneous kernel map object to use.
After changing the kernel map, the inner product and accumulator function should be queried again (vl_svmdataset_get_inner_product_function adn vl_svmdataset_get_accumulate_function).
Set this to NULL
to avoid using a kernel map.
Note that this does not transfer the ownership of the object to the function. Furthermore, VlSvmDataset holds to the object until it is destroyed or the object is replaced or removed by calling this function again.