13 #ifndef MLPACK_METHODS_ANN_LOSS_FUNCTION_LOG_COSH_LOSS_IMPL_HPP 14 #define MLPACK_METHODS_ANN_LOSS_FUNCTION_LOG_COSH_LOSS_IMPL_HPP 22 template<
typename InputDataType,
typename OutputDataType>
26 Log::Assert(a > 0,
"Hyper-Parameter \'a\' must be positive");
29 template<
typename InputDataType,
typename OutputDataType>
30 template<
typename PredictionType,
typename TargetType>
31 typename PredictionType::elem_type
33 const PredictionType& prediction,
34 const TargetType& target)
36 return arma::accu(arma::log(arma::cosh(a * (target - prediction)))) / a;
39 template<
typename InputDataType,
typename OutputDataType>
40 template<
typename PredictionType,
typename TargetType,
typename LossType>
42 const PredictionType& prediction,
43 const TargetType& target,
46 loss = arma::tanh(a * (target - prediction));
49 template<
typename InputDataType,
typename OutputDataType>
50 template<
typename Archive>
void serialize(Archive &ar, const uint32_t)
Serialize the loss function.
Definition: log_cosh_loss_impl.hpp:51
PredictionType::elem_type Forward(const PredictionType &prediction, const TargetType &target)
Computes the Log-Hyperbolic-Cosine loss function.
Definition: log_cosh_loss_impl.hpp:32
LogCoshLoss(const double a=1.0)
Create the Log-Hyperbolic-Cosine object with the specified parameters.
Definition: log_cosh_loss_impl.hpp:23
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
void Backward(const PredictionType &prediction, const TargetType &target, LossType &loss)
Ordinary feed backward pass of a neural network.
Definition: log_cosh_loss_impl.hpp:41
static void Assert(bool condition, const std::string &message="Assert Failed.")
Checks if the specified condition is true.
Definition: log.cpp:38