mlpack
|
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. | |
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.
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). |
mlpack::ann::TripletMarginLoss< InputDataType, OutputDataType >::TripletMarginLoss | ( | const double | margin = 1.0 | ) |
Create the TripletMarginLoss object.
margin | The minimum value by which the distance between Anchor and Negative sample exceeds the distance between Anchor and Positive sample. |
void mlpack::ann::TripletMarginLoss< InputDataType, OutputDataType >::Backward | ( | const PredictionType & | prediction, |
const TargetType & | target, | ||
LossType & | loss | ||
) |
Ordinary feed backward pass of a neural network.
prediction | Concatenated anchor and positive sample. |
target | The negative sample. |
loss | The calculated error. |
PredictionType::elem_type mlpack::ann::TripletMarginLoss< InputDataType, OutputDataType >::Forward | ( | const PredictionType & | prediction, |
const TargetType & | target | ||
) |
Computes the Triplet Margin Loss function.
prediction | Concatenated anchor and positive sample. |
target | The negative sample. |