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 InputType, typename TargetType>
53  typename InputType::elem_type Forward(const InputType& input,
54  const TargetType& target);
55 
63  template <
64  typename InputType,
65  typename TargetType,
66  typename OutputType
67  >
68  void Backward(const InputType& input,
69  const TargetType& target,
70  OutputType& output);
71 
73  OutputDataType& OutputParameter() const { return outputParameter; }
75  OutputDataType& OutputParameter() { return outputParameter; }
76 
78  double Margin() const { return margin; }
80  double& Margin() { return margin; }
81 
85  template<typename Archive>
86  void serialize(Archive& ar, const unsigned int /* version */);
87 
88  private:
90  OutputDataType outputParameter;
91 
93  double margin;
94 }; // class MarginRankingLoss
95 
96 } // namespace ann
97 } // namespace mlpack
98 
99 // include implementation.
100 #include "margin_ranking_loss_impl.hpp"
101 
102 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: add_to_po.hpp:21
double & Margin()
Modify the margin parameter.
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType & OutputParameter() const
Get the output parameter.
void Backward(const InputType &input, const TargetType &target, OutputType &output)
Ordinary feed backward pass of a neural network.
MarginRankingLoss(const double margin=1.0)
Create the MarginRankingLoss object with Hyperparameter margin.
void serialize(Archive &ar, const unsigned int)
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.
InputType::elem_type Forward(const InputType &input, const TargetType &target)
Computes the Margin Ranking Loss function.
OutputDataType & OutputParameter()
Modify the output parameter.