Computes the hinge loss between and . More...
Public Member Functions | |
HingeLoss (const bool reduction=true) | |
Create HingeLoss object. More... | |
template < typename PredictionType , typename TargetType , typename LossType > | |
void | Backward (const PredictionType &prediction, const TargetType &target, LossType &loss) |
Ordinary feed backward pass of a neural network. More... | |
template < typename PredictionType , typename TargetType > | |
PredictionType::elem_type | Forward (const PredictionType &prediction, const TargetType &target) |
Computes the Hinge loss function. More... | |
OutputDataType & | OutputParameter () const |
Get the output parameter. More... | |
OutputDataType & | OutputParameter () |
Modify the output parameter. More... | |
bool | Reduction () const |
Get the type of reduction used. More... | |
bool & | Reduction () |
Modify the type of reduction used. More... | |
template < typename Archive > | |
void | serialize (Archive &ar, const uint32_t) |
Serialize the layer. More... | |
Computes the hinge loss between and .
Expects to be either -1 or 1. If is either 0 or 1, a temporary conversion is made to calculate the loss. The hinge loss is defined as .
InputDataType | Type of the input data (arma::colvec, arma::mat, arma::sp_mat or arma::cube). |
OutputDataType | Type of the output data (arma::colvec, arma::mat, arma::sp_mat or arma::cube). |
Definition at line 37 of file hinge_loss.hpp.
HingeLoss | ( | const bool | reduction = true | ) |
Create HingeLoss object.
reduction | Specifies the reduction to apply to the output. If false, 'mean' reduction is used, where sum of the output will be divided by the number of elements in the output. If true, 'sum' reduction is used and the output will be summed. It is set to true by default. |
void Backward | ( | const PredictionType & | prediction, |
const TargetType & | target, | ||
LossType & | loss | ||
) |
Ordinary feed backward pass of a neural network.
prediction | Prediction used for evaluating the specified loss function. |
target | The target vector. |
loss | The calculated error. |
PredictionType::elem_type Forward | ( | const PredictionType & | prediction, |
const TargetType & | target | ||
) |
Computes the Hinge loss function.
prediction | Prediction used for evaluating the specified loss function. |
target | Target data to compare with. |
|
inline |
Get the output parameter.
Definition at line 76 of file hinge_loss.hpp.
|
inline |
Modify the output parameter.
Definition at line 78 of file hinge_loss.hpp.
|
inline |
Get the type of reduction used.
Definition at line 81 of file hinge_loss.hpp.
|
inline |
Modify the type of reduction used.
Definition at line 83 of file hinge_loss.hpp.
References HingeLoss< InputDataType, OutputDataType >::serialize().
void serialize | ( | Archive & | ar, |
const uint32_t | |||
) |
Serialize the layer.
Referenced by HingeLoss< InputDataType, OutputDataType >::Reduction().