log_cosh_loss.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_METHODS_ANN_LOSS_FUNCTION_LOG_COSH_LOSS_HPP
14 #define MLPACK_METHODS_ANN_LOSS_FUNCTION_LOG_COSH_LOSS_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 
18 namespace mlpack {
19 namespace ann {
20 
31 template <
32  typename InputDataType = arma::mat,
33  typename OutputDataType = arma::mat
34 >
36 {
37  public:
49  LogCoshLoss(const double a = 1.0);
50 
58  template<typename PredictionType, typename TargetType>
59  typename PredictionType::elem_type Forward(const PredictionType& prediction,
60  const TargetType& target);
61 
70  template<typename PredictionType, typename TargetType, typename LossType>
71  void Backward(const PredictionType& prediction,
72  const TargetType& target,
73  LossType& loss);
74 
76  OutputDataType& OutputParameter() const { return outputParameter; }
78  OutputDataType& OutputParameter() { return outputParameter; }
79 
81  double A() const { return a; }
83  double& A() { return a; }
84 
88  template<typename Archive>
89  void serialize(Archive& ar, const uint32_t /* version */);
90 
91  private:
93  OutputDataType outputParameter;
94 
96  double a;
97 }; // class LogCoshLoss
98 
99 } // namespace ann
100 } // namespace mlpack
101 
102 // include implementation
103 #include "log_cosh_loss_impl.hpp"
104 
105 #endif
void serialize(Archive &ar, const uint32_t)
Serialize the loss function.
void Backward(const PredictionType &prediction, const TargetType &target, LossType &loss)
Ordinary feed backward pass of a neural network.
Linear algebra utility functions, generally performed on matrices or vectors.
OutputDataType & OutputParameter()
Modify the output parameter.
The core includes that mlpack expects; standard C++ includes and Armadillo.
LogCoshLoss(const double a=1.0)
Create the Log-Hyperbolic-Cosine object with the specified parameters.
OutputDataType & OutputParameter() const
Get the output parameter.
double & A()
Modify the value of hyperparameter a.
The Log-Hyperbolic-Cosine loss function is often used to improve variational auto encoder...
double A() const
Get the value of hyperparameter a.
PredictionType::elem_type Forward(const PredictionType &prediction, const TargetType &target)
Computes the Log-Hyperbolic-Cosine loss function.