mlpack
margin_ranking_loss.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_ANN_LOSS_FUNCTION_MARGIN_RANKING_LOSS_HPP
13 #define MLPACK_ANN_LOSS_FUNCTION_MARGIN_RANKING_LOSS_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 
17 namespace mlpack {
18 namespace ann {
19 
31 template <
32  typename InputDataType = arma::mat,
33  typename OutputDataType = arma::mat
34 >
36 {
37  public:
43  MarginRankingLoss(const double margin = 1.0);
44 
52  template<typename PredictionType, typename TargetType>
53  typename PredictionType::elem_type Forward(const PredictionType& prediction,
54  const TargetType& target);
55 
64  template <
65  typename PredictionType,
66  typename TargetType,
67  typename LossType
68  >
69  void Backward(const PredictionType& prediction,
70  const TargetType& target,
71  LossType& loss);
72 
74  OutputDataType& OutputParameter() const { return outputParameter; }
76  OutputDataType& OutputParameter() { return outputParameter; }
77 
79  double Margin() const { return margin; }
81  double& Margin() { return margin; }
82 
86  template<typename Archive>
87  void serialize(Archive& ar, const uint32_t /* version */);
88 
89  private:
91  OutputDataType outputParameter;
92 
94  double margin;
95 }; // class MarginRankingLoss
96 
97 } // namespace ann
98 } // namespace mlpack
99 
100 // include implementation.
102 
103 #endif
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: margin_ranking_loss_impl.hpp:68
OutputDataType & OutputParameter() const
Get the output parameter.
Definition: margin_ranking_loss.hpp:74
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.
double Margin() const
Get the margin parameter.
Definition: margin_ranking_loss.hpp:79
MarginRankingLoss(const double margin=1.0)
Create the MarginRankingLoss object with Hyperparameter margin.
Definition: margin_ranking_loss_impl.hpp:22
void Backward(const PredictionType &prediction, const TargetType &target, LossType &loss)
Ordinary feed backward pass of a neural network.
Definition: margin_ranking_loss_impl.hpp:50
PredictionType::elem_type Forward(const PredictionType &prediction, const TargetType &target)
Computes the Margin Ranking Loss function.
Definition: margin_ranking_loss_impl.hpp:31
double & Margin()
Modify the margin parameter.
Definition: margin_ranking_loss.hpp:81
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: margin_ranking_loss.hpp:76
Margin ranking loss measures the loss given inputs and a label vector with values of 1 or -1...
Definition: margin_ranking_loss.hpp:35