MarginRankingLoss< InputDataType, OutputDataType > Class Template Reference

Margin ranking loss measures the loss given inputs and a label vector with values of 1 or -1. More...

Public Member Functions

 MarginRankingLoss (const double margin=1.0)
 Create the MarginRankingLoss object with Hyperparameter margin. 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 Margin Ranking Loss function. More...

 
double Margin () const
 Get the margin parameter. More...

 
double & Margin ()
 Modify the margin parameter. More...

 
OutputDataType & OutputParameter () const
 Get the output parameter. More...

 
OutputDataType & OutputParameter ()
 Modify the output parameter. More...

 
template
<
typename
Archive
>
void serialize (Archive &ar, const uint32_t)
 Serialize the layer. More...

 

Detailed Description


template
<
typename
InputDataType
=
arma::mat
,
typename
OutputDataType
=
arma::mat
>

class mlpack::ann::MarginRankingLoss< InputDataType, OutputDataType >

Margin ranking loss measures the loss given inputs and a label vector with values of 1 or -1.

If the label is 1 then the first input should be ranked higher than the second input at a distance larger than a margin, and vice- versa if the label is -1.

Template Parameters
InputDataTypeType of the input data (arma::colvec, arma::mat, arma::sp_mat or arma::cube).
OutputDataTypeType of the output data (arma::colvec, arma::mat, arma::sp_mat or arma::cube).

Definition at line 35 of file margin_ranking_loss.hpp.

Constructor & Destructor Documentation

◆ MarginRankingLoss()

MarginRankingLoss ( const double  margin = 1.0)

Create the MarginRankingLoss object with Hyperparameter margin.

Hyperparameter margin defines a minimum distance between correctly ranked samples.

Member Function Documentation

◆ Backward()

void Backward ( const PredictionType &  prediction,
const TargetType &  target,
LossType &  loss 
)

Ordinary feed backward pass of a neural network.

Parameters
predictionPredictions used for evaluating the specified loss function.
targetThe label vector which contains -1 or 1 values.
lossThe calculated error.

◆ Forward()

PredictionType::elem_type Forward ( const PredictionType &  prediction,
const TargetType &  target 
)

Computes the Margin Ranking Loss function.

Parameters
predictionPredictions used for evaluating the specified loss function.
targetThe label vector which contains values of -1 or 1.

◆ Margin() [1/2]

double Margin ( ) const
inline

Get the margin parameter.

Definition at line 79 of file margin_ranking_loss.hpp.

◆ Margin() [2/2]

double& Margin ( )
inline

Modify the margin parameter.

Definition at line 81 of file margin_ranking_loss.hpp.

References MarginRankingLoss< InputDataType, OutputDataType >::serialize().

◆ OutputParameter() [1/2]

OutputDataType& OutputParameter ( ) const
inline

Get the output parameter.

Definition at line 74 of file margin_ranking_loss.hpp.

◆ OutputParameter() [2/2]

OutputDataType& OutputParameter ( )
inline

Modify the output parameter.

Definition at line 76 of file margin_ranking_loss.hpp.

◆ serialize()

void serialize ( Archive &  ar,
const uint32_t   
)

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