TripletMarginLoss< InputDataType, OutputDataType > Class Template Reference

The Triplet Margin Loss performance function measures the network's performance according to the relative distance from the anchor input of the positive (truthy) and negative (falsy) inputs. More...

Public Member Functions

 TripletMarginLoss (const double margin=1.0)
 Create the TripletMarginLoss 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 Triplet Margin Loss function. More...

 
double Margin () const
 Get the value of margin. More...

 
double & Margin ()
 Modify the value of margin. More...

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

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

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

 

Detailed Description


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

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

The Triplet Margin Loss performance function measures the network's performance according to the relative distance from the anchor input of the positive (truthy) and negative (falsy) inputs.

The distance between two samples A and B is defined as square of L2 norm of A-B.

For more information, refer the following paper.

@article{Schroff2015,
author = {Florian Schroff, Dmitry Kalenichenko, James Philbin},
title = {FaceNet: A Unified Embedding for Face Recognition and Clustering},
year = {2015},
url = {https://arxiv.org/abs/1503.03832},
}
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 48 of file triplet_margin_loss.hpp.

Constructor & Destructor Documentation

◆ TripletMarginLoss()

TripletMarginLoss ( const double  margin = 1.0)

Create the TripletMarginLoss object.

Parameters
marginThe minimum value by which the distance between Anchor and Negative sample exceeds the distance between Anchor and Positive sample.

Member Function Documentation

◆ Backward()

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

Ordinary feed backward pass of a neural network.

Parameters
predictionConcatenated anchor and positive sample.
targetThe negative sample.
lossThe calculated error.

◆ Forward()

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

Computes the Triplet Margin Loss function.

Parameters
predictionConcatenated anchor and positive sample.
targetThe negative sample.

◆ Margin() [1/2]

double Margin ( ) const
inline

Get the value of margin.

Definition at line 87 of file triplet_margin_loss.hpp.

◆ Margin() [2/2]

double& Margin ( )
inline

Modify the value of margin.

Definition at line 89 of file triplet_margin_loss.hpp.

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

◆ OutputParameter() [1/2]

OutputDataType& OutputParameter ( ) const
inline

Get the output parameter.

Definition at line 82 of file triplet_margin_loss.hpp.

◆ OutputParameter() [2/2]

OutputDataType& OutputParameter ( )
inline

Modify the output parameter.

Definition at line 84 of file triplet_margin_loss.hpp.

◆ serialize()

void serialize ( Archive &  ar,
const unsigned  int 
)

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