12 #ifndef MLPACK_METHODS_ANN_LOSS_FUNCTION_MEAN_SQUARED_ERROR_IMPL_HPP 13 #define MLPACK_METHODS_ANN_LOSS_FUNCTION_MEAN_SQUARED_ERROR_IMPL_HPP 21 template<
typename InputDataType,
typename OutputDataType>
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)
34 return arma::accu(arma::square(prediction - target)) / target.n_cols;
37 template<
typename InputDataType,
typename OutputDataType>
38 template<
typename PredictionType,
typename TargetType,
typename LossType>
40 const PredictionType& prediction,
41 const TargetType& target,
44 loss = 2 * (prediction - target) / target.n_cols;
47 template<
typename InputDataType,
typename OutputDataType>
48 template<
typename Archive>
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: mean_squared_error_impl.hpp:39
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: mean_squared_error_impl.hpp:49
MeanSquaredError()
Create the MeanSquaredError object.
Definition: mean_squared_error_impl.hpp:22
PredictionType::elem_type Forward(const PredictionType &prediction, const TargetType &target)
Computes the mean squared error function.
Definition: mean_squared_error_impl.hpp:30