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.
101 #include "margin_ranking_loss_impl.hpp"
102 
103 #endif
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 margin parameter.
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 Margin Ranking Loss function.
MarginRankingLoss(const double margin=1.0)
Create the MarginRankingLoss object with Hyperparameter margin.
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Margin ranking loss measures the loss given inputs and a label vector with values of 1 or -1...
double Margin() const
Get the margin parameter.
OutputDataType & OutputParameter()
Modify the output parameter.