13 #ifndef MLPACK_METHODS_ANN_LOSS_FUNCTION_SIGMOID_CROSS_ENTROPY_ERROR_IMPL_HPP 14 #define MLPACK_METHODS_ANN_LOSS_FUNCTION_SIGMOID_CROSS_ENTROPY_ERROR_IMPL_HPP 23 template<
typename InputDataType,
typename OutputDataType>
30 template<
typename InputDataType,
typename OutputDataType>
31 template<
typename PredictionType,
typename TargetType>
32 inline typename PredictionType::elem_type
34 const PredictionType& prediction,
35 const TargetType& target)
37 typedef typename PredictionType::elem_type ElemType;
39 for (
size_t i = 0; i < prediction.n_elem; ++i)
41 maximum += std::max(prediction[i], 0.0) +
42 std::log(1 + std::exp(-std::abs(prediction[i])));
45 return maximum - arma::accu(prediction % target);
48 template<
typename InputDataType,
typename OutputDataType>
49 template<
typename PredictionType,
typename TargetType,
typename LossType>
51 const PredictionType& prediction,
52 const TargetType& target,
55 loss = 1.0 / (1.0 + arma::exp(-prediction)) - target;
58 template<
typename InputDataType,
typename OutputDataType>
59 template<
typename Archive>
SigmoidCrossEntropyError()
Create the SigmoidCrossEntropyError object.
Definition: sigmoid_cross_entropy_error_impl.hpp:25
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: sigmoid_cross_entropy_error_impl.hpp:50
PredictionType::elem_type Forward(const PredictionType &prediction, const TargetType &target)
Computes the Sigmoid CrossEntropy Error functions.
Definition: sigmoid_cross_entropy_error_impl.hpp:33
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: sigmoid_cross_entropy_error_impl.hpp:60