mlpack 3.4.2
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
17namespace mlpack {
18namespace ann {
19
31template <
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
Margin ranking loss measures the loss given inputs and a label vector with values of 1 or -1.
MarginRankingLoss(const double margin=1.0)
Create the MarginRankingLoss object with Hyperparameter margin.
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.
double & Margin()
Modify the margin parameter.
InputType::elem_type Forward(const InputType &input, const TargetType &target)
Computes the Margin Ranking Loss function.
double Margin() const
Get the margin parameter.
OutputDataType & OutputParameter()
Modify the output parameter.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
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.