Typedefs
svmdataset.h File Reference

SVM Dataset. More...

#include "generic.h"
#include "homkermap.h"
Include dependency graph for svmdataset.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct VlSvmDataset_ VlSvmDataset
 SVM dataset object.
SVM callbacks
typedef void(* VlSvmDiagnosticFunction )(struct VlSvm_ *svm, void *data)
 SVM diagnostic function pointer.
typedef double(* VlSvmLossFunction )(double inner, double label)
 SVM loss function pointer.
typedef double(* VlSvmDcaUpdateFunction )(double alpha, double inner, double norm2, double label)
 SVM SDCA update function pointer.
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
VL_EXPORT VlSvmDatasetvl_svmdataset_new (vl_type dataType, void *data, vl_size dimension, vl_size numData)
 Create a new object wrapping a dataset.
VL_EXPORT void vl_svmdataset_delete (VlSvmDataset *dataset)
 Delete the object.
Set parameters
VL_EXPORT void vl_svmdataset_set_homogeneous_kernel_map (VlSvmDataset *self, VlHomogeneousKernelMap *hom)
 Set the homogeneous kernel map object.
Get data and parameters
VL_EXPORT voidvl_svmdataset_get_data (VlSvmDataset const *self)
 Get the wrapped data.
VL_EXPORT vl_size vl_svmdataset_get_num_data (VlSvmDataset const *self)
 Get the number of wrapped data elements.
VL_EXPORT vl_size vl_svmdataset_get_dimension (VlSvmDataset const *self)
 Get the dimension of the wrapped data.
VL_EXPORT voidvl_svmdataset_get_map (VlSvmDataset const *self)
VL_EXPORT vl_size vl_svmdataset_get_mapDim (VlSvmDataset const *self)
VL_EXPORT VlSvmAccumulateFunction vl_svmdataset_get_accumulate_function (VlSvmDataset const *self)
 Get the accumulate function.
VL_EXPORT VlSvmInnerProductFunction vl_svmdataset_get_inner_product_function (VlSvmDataset const *self)
 Get the inner product function.
VL_EXPORT VlHomogeneousKernelMapvl_svmdataset_get_homogeneous_kernel_map (VlSvmDataset const *self)
 Get the homogeneous kernel map object.

Detailed Description

SVM Dataset.

Author:
Daniele Perrone
Andrea Vedaldi

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:

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:

For example, to learn a linear SVM on SINGLE data:

int main()
{
  vl_size const numData = 4 ;
  vl_size const dimension = 2 ;
  single x [dimension * numData] = {
    0.0, -0.5,
    0.6, -0.3,
    0.0,  0.5,
    0.6,  0.0} ;
  double y [numData] = {1, 1, -1, 1} ;
  double lambda = 0.01;
  double * const model ;
  double bias ;

  VlSvmDataset * dataset = vl_svmdataset_new (VL_TYPE_SINGLE, x, dimension, numData) ;
  VlSvm * svm = vl_svm_new_with_dataset (VlSvmSolverSgd, dataset, y, lambda) ;

  vl_svm_train(svm) ;

  model = vl_svm_get_model(svm) ;
  bias = vl_svm_get_bias(svm) ;

  printf("model w = [ %f , %f ] , bias b = %f \n",
         model[0],
         model[1],
         bias);

  vl_svm_delete(svm) ;
  vl_svmdataset_delete(dataset) ;
  return 0;
}
Author:
Daniele Perrone
Andrea Vedaldi

Definition in file svmdataset.h.


Typedef Documentation

Pointer to a function that adds to model the data point at position element multiplied by the constant multiplier.

Definition at line 48 of file svmdataset.h.

SVM dataset object.

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.

Definition at line 37 of file svmdataset.h.

SVM SDCA update function pointer.

Parameters:
alphacurrent value of the dual variable.
innerinner product $^ $ of the sample with the SVM model.
norm2normalization factor $\|\|^2/ n$.
labellabel $y$ of the sample.
Returns:
incremental update $$ of the dual variable.
See also:
Stochastic Dual Coordinate Ascent

Definition at line 46 of file svmdataset.h.

SVM diagnostic function pointer.

Parameters:
svmis an instance of VlSvm .

Definition at line 44 of file svmdataset.h.

Pointer to a function that defines the inner product between the data point at position element and the SVM model.

Definition at line 47 of file svmdataset.h.

SVM loss function pointer.

Parameters:
innerinner product between sample and model $^ $.
labelsample 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

Definition at line 45 of file svmdataset.h.


Function Documentation

VL_EXPORT void vl_svmdataset_delete ( VlSvmDataset self)

Delete the object.

Parameters:
selfobject 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.

Definition at line 164 of file svmdataset.c.

Get the accumulate function.

Parameters:
selfobject.
Returns:
a pointer to the accumulate function to use with this data.

Definition at line 260 of file svmdataset.c.

VL_EXPORT void* vl_svmdataset_get_data ( VlSvmDataset const *  self)

Get the wrapped data.

Parameters:
selfobject.
Returns:
a pointer to the wrapped data.

Definition at line 179 of file svmdataset.c.

VL_EXPORT vl_size vl_svmdataset_get_dimension ( VlSvmDataset const *  self)

Get the dimension of the wrapped data.

Parameters:
selfobject.
Returns:
dimension of the wrapped data.

Definition at line 201 of file svmdataset.c.

Get the homogeneous kernel map object.

Parameters:
selfobject.
Returns:
homogenoeus kernel map object (or NULL if any).

Definition at line 215 of file svmdataset.c.

Get the inner product function.

Parameters:
selfobject.
Returns:
a pointer to the inner product function to use with this data.

Definition at line 291 of file svmdataset.c.

VL_EXPORT void* vl_svmdataset_get_map ( VlSvmDataset const *  self)
VL_EXPORT vl_size vl_svmdataset_get_mapDim ( VlSvmDataset const *  self)
VL_EXPORT vl_size vl_svmdataset_get_num_data ( VlSvmDataset const *  self)

Get the number of wrapped data elements.

Parameters:
selfobject.
Returns:
number of wrapped data elements.

Definition at line 190 of file svmdataset.c.

VL_EXPORT VlSvmDataset* vl_svmdataset_new ( vl_type  dataType,
void data,
vl_size  dimension,
vl_size  numData 
)

Create a new object wrapping a dataset.

Parameters:
dataTypeof data (float and double supported).
datapointer to the data.
dimensionthe dimension of a data vector.
numDatanumber 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

Definition at line 138 of file svmdataset.c.

Set the homogeneous kernel map object.

Parameters:
selfobject.
homhomogeneous 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.

Definition at line 238 of file svmdataset.c.



libvlfeat
Author(s): Andrea Vedaldi
autogenerated on Thu Jun 6 2019 20:25:52