mlpack 3.4.2
l1_loss.hpp
Go to the documentation of this file.
1
12#ifndef MLPACK_METHODS_ANN_LOSS_FUNCTION_L1_LOSS_HPP
13#define MLPACK_METHODS_ANN_LOSS_FUNCTION_L1_LOSS_HPP
14
15#include <mlpack/prereqs.hpp>
16
17namespace mlpack {
18namespace ann {
19
29template <
30 typename InputDataType = arma::mat,
31 typename OutputDataType = arma::mat
32>
33class L1Loss
34{
35 public:
42 L1Loss(const bool mean = true);
43
50 template<typename InputType, typename TargetType>
51 typename InputType::elem_type Forward(const InputType& input,
52 const TargetType& target);
53
61 template<typename InputType, typename TargetType, typename OutputType>
62 void Backward(const InputType& input,
63 const TargetType& target,
64 OutputType& output);
65
67 OutputDataType& OutputParameter() const { return outputParameter; }
69 OutputDataType& OutputParameter() { return outputParameter; }
70
72 bool Mean() const { return mean; }
74 bool& Mean() { return mean; }
75
79 template<typename Archive>
80 void serialize(Archive& ar, const unsigned int /* version */);
81
82 private:
84 OutputDataType outputParameter;
85
87 bool mean;
88}; // class L1Loss
89
90} // namespace ann
91} // namespace mlpack
92
93// Include implementation.
94#include "l1_loss_impl.hpp"
95
96#endif
The L1 loss is a loss function that measures the mean absolute error (MAE) between each element in th...
Definition: l1_loss.hpp:34
bool & Mean()
Set the value of reduction type.
Definition: l1_loss.hpp:74
OutputDataType & OutputParameter() const
Get the output parameter.
Definition: l1_loss.hpp:67
void Backward(const InputType &input, const TargetType &target, OutputType &output)
Ordinary feed backward pass of a neural network.
L1Loss(const bool mean=true)
Create the L1Loss object.
InputType::elem_type Forward(const InputType &input, const TargetType &target)
Computes the L1 Loss function.
bool Mean() const
Get the value of reduction type.
Definition: l1_loss.hpp:72
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: l1_loss.hpp:69
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.