mlpack 3.4.2
huber_loss.hpp
Go to the documentation of this file.
1
12#ifndef MLPACK_METHODS_ANN_LOSS_FUNCTION_HUBER_LOSS_HPP
13#define MLPACK_METHODS_ANN_LOSS_FUNCTION_HUBER_LOSS_HPP
14
15#include <mlpack/prereqs.hpp>
16
17namespace mlpack {
18namespace ann {
19
32template <
33 typename InputDataType = arma::mat,
34 typename OutputDataType = arma::mat
35>
37{
38 public:
46 HuberLoss(const double delta = 1.0, const bool mean = true);
47
54 template<typename InputType, typename TargetType>
55 typename InputType::elem_type Forward(const InputType& input,
56 const TargetType& target);
57
65 template<typename InputType, typename TargetType, typename OutputType>
66 void Backward(const InputType& input,
67 const TargetType& target,
68 OutputType& output);
69
71 OutputDataType& OutputParameter() const { return outputParameter; }
73 OutputDataType& OutputParameter() { return outputParameter; }
74
76 double Delta() const { return delta; }
78 double& Delta() { return delta; }
79
81 bool Mean() const { return mean; }
83 bool& Mean() { return mean; }
84
88 template<typename Archive>
89 void serialize(Archive& ar, const unsigned int /* version */);
90
91 private:
93 OutputDataType outputParameter;
94
96 double delta;
97
99 bool mean;
100}; // class HuberLoss
101
102} // namespace ann
103} // namespace mlpack
104
105// Include implementation.
106#include "huber_loss_impl.hpp"
107
108#endif
The Huber loss is a loss function used in robust regression, that is less sensitive to outliers in da...
Definition: huber_loss.hpp:37
bool & Mean()
Set the value of reduction type.
Definition: huber_loss.hpp:83
OutputDataType & OutputParameter() const
Get the output parameter.
Definition: huber_loss.hpp:71
double & Delta()
Set the value of delta.
Definition: huber_loss.hpp:78
void Backward(const InputType &input, const TargetType &target, OutputType &output)
Ordinary feed backward pass of a neural network.
InputType::elem_type Forward(const InputType &input, const TargetType &target)
Computes the Huber Loss function.
bool Mean() const
Get the value of reduction type.
Definition: huber_loss.hpp:81
double Delta() const
Get the value of delta.
Definition: huber_loss.hpp:76
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: huber_loss.hpp:73
HuberLoss(const double delta=1.0, const bool mean=true)
Create the HuberLoss object.
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.