mlpack
reconstruction_loss_impl.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_ANN_LOSS_FUNCTION_RECONSTRUCTION_LOSS_IMPL_HPP
13 #define MLPACK_METHODS_ANN_LOSS_FUNCTION_RECONSTRUCTION_LOSS_IMPL_HPP
14 
15 // In case it hasn't yet been included.
16 #include "reconstruction_loss.hpp"
17 
18 namespace mlpack {
19 namespace ann {
20 
21 template<typename InputDataType, typename OutputDataType, typename DistType>
22 ReconstructionLoss<
23  InputDataType,
24  OutputDataType,
25  DistType
27 {
28  // Nothing to do here.
29 }
30 
31 template<typename InputDataType, typename OutputDataType, typename DistType>
32 template<typename PredictionType, typename TargetType>
33 typename PredictionType::elem_type
35  const PredictionType& prediction, const TargetType& target)
36 {
37  dist = DistType(prediction);
38  return -dist.LogProbability(target);
39 }
40 
41 template<typename InputDataType, typename OutputDataType, typename DistType>
42 template<typename PredictionType, typename TargetType, typename LossType>
44  const PredictionType& /* prediction */,
45  const TargetType& target,
46  LossType& loss)
47 {
48  dist.LogProbBackward(target, loss);
49  loss *= -1;
50 }
51 
52 template<typename InputDataType, typename OutputDataType, typename DistType>
53 template<typename Archive>
55  Archive& /* ar */,
56  const uint32_t /* version */)
57 {
58  // Nothing to do here.
59 }
60 
61 } // namespace ann
62 } // namespace mlpack
63 
64 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: reconstruction_loss_impl.hpp:54
The reconstruction loss performance function measures the network&#39;s performance equal to the negative...
Definition: reconstruction_loss.hpp:37
PredictionType::elem_type Forward(const PredictionType &prediction, const TargetType &target)
Computes the reconstruction loss.
Definition: reconstruction_loss_impl.hpp:34
void Backward(const PredictionType &prediction, const TargetType &target, LossType &loss)
Ordinary feed backward pass of a neural network.
Definition: reconstruction_loss_impl.hpp:43