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... | |
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). |
Definition at line 48 of file triplet_margin_loss.hpp.
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 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 Forward | ( | const PredictionType & | prediction, |
const TargetType & | target | ||
) |
Computes the Triplet Margin Loss function.
prediction | Concatenated anchor and positive sample. |
target | The negative sample. |
|
inline |
Get the value of margin.
Definition at line 87 of file triplet_margin_loss.hpp.
|
inline |
Modify the value of margin.
Definition at line 89 of file triplet_margin_loss.hpp.
References TripletMarginLoss< InputDataType, OutputDataType >::serialize().
|
inline |
Get the output parameter.
Definition at line 82 of file triplet_margin_loss.hpp.
|
inline |
Modify the output parameter.
Definition at line 84 of file triplet_margin_loss.hpp.
void serialize | ( | Archive & | ar, |
const unsigned | int | ||
) |
Serialize the layer.
Referenced by TripletMarginLoss< InputDataType, OutputDataType >::Margin().