SquaredError Class Reference

Calculates the sum-of-squares error. More...

#include <SquaredError.h>

Inheritance diagram for SquaredError:
ErrorFunction

List of all members.

Public Member Functions

double error (Model &model, const Array< double > &in, const Array< double > &out)
 Calculates the squared error between the output and the target vector.
double errorDerivative (Model &model, const Array< double > &in, const Array< double > &out, Array< double > &derivative)
 Calculates the derivatives of the squared error with respect to the parameters ModelInterface::w.

Detailed Description

Calculates the sum-of-squares error.

These methods can be used as error measure model for the learning process.

Author:
C. Igel
Date:
1999
Changes:
none
Status:
stable

Definition at line 72 of file SquaredError.h.


Member Function Documentation

double SquaredError::error ( Model model,
const Array< double > &  in,
const Array< double > &  out 
) [inline, virtual]

Calculates the squared error between the output and the target vector.

Measures the euklidian distance between the model output model(in), calculated from the input vector in, and the target vector out. Consider the case of a N-dimensional output vector, i.e. a neural network with N output neurons, and a set of P patterns. In this case the function calculates

\[E = \sum_{p=1}^P\sum_{i=1}^N(model(in)_{ip} - out_{ip})^{2}\]

Parameters:
in Input vector for the model.
out Target vector.
Returns:
The squared error E.
Author:
C. Igel
Date:
1999
Changes
none
Status
stable

Implements ErrorFunction.

Definition at line 102 of file SquaredError.h.

References Model::model().

double SquaredError::errorDerivative ( Model model,
const Array< double > &  in,
const Array< double > &  out,
Array< double > &  derivative 
) [inline, virtual]

Calculates the derivatives of the squared error with respect to the parameters ModelInterface::w.

According to the equation in the description for the function error the derivatives of the squared error can be calculated with

\[ \frac{E}{w_j} = 2 \sum_{p=1}^P \sum_{i=1}^N (model(in)_{ip} - out_{ip}) \frac{model(in)_{ip}}{w_j} \]

The results are written to the vector ModelInterface::dedw.

Usually, as a byproduct of the calculation of the derivative one gets the the error $E$ itself very efficiently. Therefore, the method error gives back this value. This additional effect can be switched of by means of the third parameter (returnError = false).

Parameters:
in Input vector for the model.
out The target vector.
returnError Determines whether or not to calculate the error itself. By default the error is calculated.
Returns:
The error E if returnError is set to "true", "-1" otherwise.
Author:
C. Igel
Date:
1999
Changes
none
Status
stable

Reimplemented from ErrorFunction.

Definition at line 166 of file SquaredError.h.

References Model::getParameterDimension(), i, and Model::modelDerivative().


The documentation for this class was generated from the following file: