13 #ifndef MLPACK_METHODS_ANN_LOSS_FUNCTION_HINGE_EMBEDDING_LOSS_IMPL_HPP 14 #define MLPACK_METHODS_ANN_LOSS_FUNCTION_HINGE_EMBEDDING_LOSS_IMPL_HPP 22 template<
typename InputDataType,
typename OutputDataType>
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)
35 TargetType temp = target - (target == 0);
36 return (arma::accu(arma::max(1 - prediction % temp, 0.))) / target.n_elem;
39 template<
typename InputDataType,
typename OutputDataType>
40 template<
typename PredictionType,
typename TargetType,
typename LossType>
42 const PredictionType& prediction,
43 const TargetType& target,
46 TargetType temp = target - (target == 0);
47 loss = (prediction < 1 / temp) % -temp;
50 template<
typename InputDataType,
typename OutputDataType>
51 template<
typename Archive>
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
HingeEmbeddingLoss()
Create the Hinge Embedding object.
Definition: hinge_embedding_loss_impl.hpp:23
void serialize(Archive &ar, const uint32_t)
Serialize the loss function.
Definition: hinge_embedding_loss_impl.hpp:52
PredictionType::elem_type Forward(const PredictionType &prediction, const TargetType &target)
Computes the Hinge Embedding loss function.
Definition: hinge_embedding_loss_impl.hpp:31
void Backward(const PredictionType &prediction, const TargetType &target, LossType &loss)
Ordinary feed backward pass of a neural network.
Definition: hinge_embedding_loss_impl.hpp:41