#include <superviseddescent.hpp>
Public Member Functions | |
SupervisedDescentOptimiser ()=default | |
SupervisedDescentOptimiser (std::vector< RegressorType > regressors, NormalisationStrategy normalisation=NoNormalisation()) | |
template<class ProjectionFunction > | |
void | train (cv::Mat parameters, cv::Mat initialisations, cv::Mat templates, ProjectionFunction projection) |
template<class ProjectionFunction , class OnTrainingEpochCallback > | |
void | train (cv::Mat parameters, cv::Mat initialisations, cv::Mat templates, ProjectionFunction projection, OnTrainingEpochCallback on_training_epoch_callback) |
template<class ProjectionFunction > | |
cv::Mat | test (cv::Mat initialisations, cv::Mat templates, ProjectionFunction projection) |
template<class ProjectionFunction , class OnRegressorIterationCallback > | |
cv::Mat | test (cv::Mat initialisations, cv::Mat templates, ProjectionFunction projection, OnRegressorIterationCallback on_regressor_iteration_callback) |
template<class ProjectionFunction > | |
cv::Mat | predict (cv::Mat initialisations, cv::Mat templates, ProjectionFunction projection) |
Friends | |
class | cereal::access |
The heart of the library: The main class that performs learning of the gradient, testing and predicting of values.
The class takes a RegressorType
as template parameter to specify a learning algorithm to use. As an example, use a LinearRegressor from regressors.hpp. To use your own learning algorithm, implement the functions of the abstract class Regressor.
|
default |
Construct an empty optimiser, with no regressors.
We allow to create an empty SupervisedDescentOptimiser to facilitate serialisation.
|
inline |
Construct an optimiser with one or several regressors in series.
[in] | regressors | One or several regressors. |
[in] | normalisation | Normalisation strategy for the data during optimisation. |
|
inline |
Predicts the result value for a single example, using the learned regressors.
The input matrices should only contain one row (i.e. one training example).
y
can either be given or set to empty (=cv::Mat()
), according to what was learned during training.
For a detailed explanation of the parameters, see train(cv::Mat parameters, cv::Mat initialisations, cv::Mat templates, ProjectionFunction projection).
[in] | initialisations | Initialisation values for the parameters. Constant in case 1) and variable in case 2). |
[in] | templates | An optional matrix of template values. See description above. |
[in] | projection | The projection function that projects the given parameter values to the space of the template values. Could be a simple function like sin(x), a projection from 3D to 2D space, or a HoG feature transform. |
|
inline |
Tests the learned regressor model with the given test data.
The test data should be specified as one row per example.
y
can either be given or set to empty (=cv::Mat()
), according to what was learned during training.
For a detailed explanation of the parameters, see train(cv::Mat parameters, cv::Mat initialisations, cv::Mat templates, ProjectionFunction projection).
Calls the testing with a default (no-op) callback function. To specify a callback function, see the overload test(cv::Mat initialisations, cv::Mat templates, ProjectionFunction projection, OnRegressorIterationCallback onRegressorIterationCallback).
[in] | initialisations | Initialisation values for the parameters. Constant in case 1) and variable in case 2). |
[in] | templates | An optional matrix of template values. See description above. |
[in] | projection | The projection function that projects the given parameter values to the space of the template values. Could be a simple function like sin(x), a projection from 3D to 2D space, or a HoG feature transform. |
|
inline |
Identical to test(cv::Mat initialisations, cv::Mat templates, ProjectionFunction projection), but allows to specify a callback function that gets called with the current prediction after applying each regressor.
The signature of the callback function must take a cv::Mat with the current predictions and can capture any additional variables from the surrounding context. For example, to print the normalised least squares residual between groundtruth
and the current predictions:
Tests the learned regressor model with the given test data.
The test data should be specified as one row per example.
y
can either be given or set to empty (=cv::Mat()
), according to what was learned during training.
For a detailed explanation of the parameters, see train(cv::Mat parameters, cv::Mat initialisations, cv::Mat templates, ProjectionFunction projection).
Calls the testing with a default (no-op) callback function. To specify a callback function, see the overload test(cv::Mat initialisations, cv::Mat templates, ProjectionFunction projection, OnRegressorIterationCallback onRegressorIterationCallback).
[in] | initialisations | Initialisation values for the parameters. Constant in case 1) and variable in case 2). |
[in] | templates | An optional matrix of template values. See description above. |
[in] | projection | The projection function that projects the given parameter values to the space of the template values. Could be a simple function like sin(x), a projection from 3D to 2D space, or a HoG feature transform. |
[in] | on_regressor_iteration_callback | A callback function that gets called after each applied regressor, with the current prediction result. |
|
inline |
Train the regressor model from the given training data.
The function takes as input a set of ground truth parameters (parameters
), initialisation values for these parameters (initialisations
), an optional set of templates (templates
) (see description below) and a function projection
that is applied to the parameters.
In [1], the parameters
are called \( x \), the initialisations
are \( x_0 \), the templates
\( y \) and the projection
function is denoted as \( h \).
The templates
y can either be given or set to empty (=cv::Mat()
); There are two cases:
Example cases:
projection
is a function that takes one training sample (a cv::Mat
row vector) and returns a cv::Mat
row-vector.
This function calls a default (no-op) callback function after training of each regressor. To specify a callback function, see the overload train(cv::Mat parameters, cv::Mat initialisations, cv::Mat templates, ProjectionFunction projection, OnTrainingEpochCallback onTrainingEpochCallback).
[in] | parameters | A matrix of ground truth values of parameters, with each row being one training example. These are the parameters we want to learn. |
[in] | initialisations | Initialisation values for the parameters. Constant in case 1) and variable in case 2). |
[in] | templates | An optional matrix of template values. See description above. |
[in] | projection | The projection function that projects the given parameter values to the space of the template values. Could be a simple function like sin(x), a projection from 3D to 2D space, or a HoG feature transform. |
|
inline |
Identical to train(cv::Mat parameters, cv::Mat initialisations, cv::Mat templates, ProjectionFunction projection), but allows to specify a callback function that gets called with the current prediction after every regressor.
The signature of the callback function must take a cv::Mat
with the current predictions and can capture any additional variables from the surrounding context. For example, to print the normalised least squares residual between groundtruth
and the current predictions:
Train the regressor model from the given training data.
The function takes as input a set of ground truth parameters (parameters
), initialisation values for these parameters (initialisations
), an optional set of templates (templates
) (see description below) and a function projection
that is applied to the parameters.
In [1], the parameters
are called \( x \), the initialisations
are \( x_0 \), the templates
\( y \) and the projection
function is denoted as \( h \).
The templates
y can either be given or set to empty (=cv::Mat()
); There are two cases:
Example cases:
projection
is a function that takes one training sample (a cv::Mat
row vector) and returns a cv::Mat
row-vector.
This function calls a default (no-op) callback function after training of each regressor. To specify a callback function, see the overload train(cv::Mat parameters, cv::Mat initialisations, cv::Mat templates, ProjectionFunction projection, OnTrainingEpochCallback onTrainingEpochCallback).
[in] | parameters | A matrix of ground truth values of parameters, with each row being one training example. These are the parameters we want to learn. |
[in] | initialisations | Initialisation values for the parameters. Constant in case 1) and variable in case 2). |
[in] | templates | An optional matrix of template values. See description above. |
[in] | projection | The projection function that projects the given parameter values to the space of the template values. Could be a simple function like sin(x), a projection from 3D to 2D space, or a HoG feature transform. |
[in] | on_training_epoch_callback | A callback function that gets called after the training of each individual regressor. |