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