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 
17 namespace mlpack {
18 namespace ann {
19 
29 template <
30  typename InputDataType = arma::mat,
31  typename OutputDataType = arma::mat
32 >
33 class L1Loss
34 {
35  public:
42  L1Loss(const bool mean = true);
43 
51  template<typename PredictionType, typename TargetType>
52  typename PredictionType::elem_type Forward(const PredictionType& prediction,
53  const TargetType& target);
54 
63  template<typename PredictionType, typename TargetType, typename LossType>
64  void Backward(const PredictionType& prediction,
65  const TargetType& target,
66  LossType& loss);
67 
69  OutputDataType& OutputParameter() const { return outputParameter; }
71  OutputDataType& OutputParameter() { return outputParameter; }
72 
74  bool Mean() const { return mean; }
76  bool& Mean() { return mean; }
77 
81  template<typename Archive>
82  void serialize(Archive& ar, const uint32_t /* version */);
83 
84  private:
86  OutputDataType outputParameter;
87 
89  bool mean;
90 }; // class L1Loss
91 
92 } // namespace ann
93 } // namespace mlpack
94 
95 // Include implementation.
96 #include "l1_loss_impl.hpp"
97 
98 #endif
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
PredictionType::elem_type Forward(const PredictionType &prediction, const TargetType &target)
Computes the L1 Loss function.
Linear algebra utility functions, generally performed on matrices or vectors.
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: l1_loss.hpp:71
The core includes that mlpack expects; standard C++ includes and Armadillo.
OutputDataType & OutputParameter() const
Get the output parameter.
Definition: l1_loss.hpp:69
void Backward(const PredictionType &prediction, const TargetType &target, LossType &loss)
Ordinary feed backward pass of a neural network.
bool & Mean()
Set the value of reduction type.
Definition: l1_loss.hpp:76
bool Mean() const
Get the value of reduction type.
Definition: l1_loss.hpp:74
L1Loss(const bool mean=true)
Create the L1Loss object.
The L1 loss is a loss function that measures the mean absolute error (MAE) between each element in th...
Definition: l1_loss.hpp:33