triplet_margin_loss.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_ANN_LOSS_FUNCTION_TRIPLET_MARGIN_LOSS_HPP
14 #define MLPACK_ANN_LOSS_FUNCTION_TRIPLET_MARGIN_LOSS_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace ann {
20 
44 template <
45  typename InputDataType = arma::mat,
46  typename OutputDataType = arma::mat
47 >
49 {
50  public:
58  TripletMarginLoss(const double margin = 1.0);
59 
66  template<typename PredictionType, typename TargetType>
67  typename PredictionType::elem_type Forward(const PredictionType& prediction,
68  const TargetType& target);
76  template<typename PredictionType, typename TargetType, typename LossType>
77  void Backward(const PredictionType& prediction,
78  const TargetType& target,
79  LossType& loss);
80 
82  OutputDataType& OutputParameter() const { return outputParameter; }
84  OutputDataType& OutputParameter() { return outputParameter; }
85 
87  double Margin() const { return margin; }
89  double& Margin() { return margin; }
90 
94  template<typename Archive>
95  void serialize(Archive& ar, const unsigned int /* version */);
96 
97  private:
99  OutputDataType outputParameter;
100 
102  double margin;
103 }; // class TripletLossMargin
104 
105 } // namespace ann
106 } // namespace mlpack
107 
108 // include implementation.
109 #include "triplet_margin_loss_impl.hpp"
110 
111 #endif
double Margin() const
Get the value of margin.
void Backward(const PredictionType &prediction, const TargetType &target, LossType &loss)
Ordinary feed backward pass of a neural network.
Linear algebra utility functions, generally performed on matrices or vectors.
double & Margin()
Modify the value of margin.
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType & OutputParameter() const
Get the output parameter.
PredictionType::elem_type Forward(const PredictionType &prediction, const TargetType &target)
Computes the Triplet Margin Loss function.
OutputDataType & OutputParameter()
Modify the output parameter.
TripletMarginLoss(const double margin=1.0)
Create the TripletMarginLoss object.
The Triplet Margin Loss performance function measures the network&#39;s performance according to the rela...
void serialize(Archive &ar, const unsigned int)
Serialize the layer.