12 #ifndef MLPACK_METHODS_ANN_LOSS_FUNCTION_COSINE_EMBEDDING_HPP 13 #define MLPACK_METHODS_ANN_LOSS_FUNCTION_COSINE_EMBEDDING_HPP 36 typename InputDataType = arma::mat,
37 typename OutputDataType = arma::mat
54 const bool similarity =
true,
55 const bool takeMean =
false);
64 template <
typename PredictionType,
typename TargetType>
65 typename PredictionType::elem_type
Forward(
const PredictionType& prediction,
66 const TargetType& target);
76 template<
typename PredictionType,
typename TargetType,
typename LossType>
77 void Backward(
const PredictionType& prediction,
78 const TargetType& target,
92 OutputDataType&
Delta()
const {
return delta; }
94 OutputDataType&
Delta() {
return delta; }
114 template<
typename Archive>
115 void serialize(Archive& ar,
const uint32_t );
119 OutputDataType delta;
122 InputDataType inputParameter;
125 OutputDataType outputParameter;
141 #include "cosine_embedding_loss_impl.hpp" bool & Similarity()
Modify the value of takeMean.
Linear algebra utility functions, generally performed on matrices or vectors.
OutputDataType & OutputParameter()
Modify the output parameter.
OutputDataType & OutputParameter() const
Get the output parameter.
CosineEmbeddingLoss(const double margin=0.0, const bool similarity=true, const bool takeMean=false)
Create the CosineEmbeddingLoss object.
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
InputDataType & InputParameter() const
Get the input parameter.
The core includes that mlpack expects; standard C++ includes and Armadillo.
PredictionType::elem_type Forward(const PredictionType &prediction, const TargetType &target)
Ordinary feed forward pass of a neural network.
OutputDataType & Delta()
Modify the delta.
bool & TakeMean()
Modify the value of takeMean.
double Margin() const
Get the value of margin.
InputDataType & InputParameter()
Modify the input parameter.
OutputDataType & Delta() const
Get the delta.
double & Margin()
Modify the value of takeMean.
bool TakeMean() const
Get the value of takeMean.
bool Similarity() const
Get the value of similarity hyperparameter.
Cosine Embedding Loss function is used for measuring whether two inputs are similar or dissimilar...
void Backward(const PredictionType &prediction, const TargetType &target, LossType &loss)
Ordinary feed backward pass of a neural network.