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