mlpack
Public Member Functions | List of all members
mlpack::ann::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...

#include <triplet_margin_loss.hpp>

Public Member Functions

 TripletMarginLoss (const double margin=1.0)
 Create the TripletMarginLoss object. More...
 
template<typename PredictionType , typename TargetType >
PredictionType::elem_type Forward (const PredictionType &prediction, const TargetType &target)
 Computes the Triplet Margin Loss function. 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...
 
OutputDataType & OutputParameter () const
 Get the output parameter.
 
OutputDataType & OutputParameter ()
 Modify the output parameter.
 
double Margin () const
 Get the value of margin.
 
double & Margin ()
 Modify the value of margin.
 
template<typename Archive >
void serialize (Archive &ar, const unsigned int)
 Serialize the layer.
 

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).

Constructor & Destructor Documentation

◆ TripletMarginLoss()

template<typename InputDataType , typename OutputDataType >
mlpack::ann::TripletMarginLoss< InputDataType, OutputDataType >::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()

template<typename InputDataType , typename OutputDataType >
template<typename PredictionType , typename TargetType , typename LossType >
void mlpack::ann::TripletMarginLoss< InputDataType, OutputDataType >::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()

template<typename InputDataType , typename OutputDataType >
template<typename PredictionType , typename TargetType >
PredictionType::elem_type mlpack::ann::TripletMarginLoss< InputDataType, OutputDataType >::Forward ( const PredictionType &  prediction,
const TargetType &  target 
)

Computes the Triplet Margin Loss function.

Parameters
predictionConcatenated anchor and positive sample.
targetThe negative sample.

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