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;
CosineEmbeddingLoss(const double margin=0.0, const bool similarity=true, const bool takeMean=false)
Create the CosineEmbeddingLoss object.
Definition: cosine_embedding_loss_impl.hpp:22
double Margin() const
Get the value of margin.
Definition: cosine_embedding_loss.hpp:102
OutputDataType & Delta() const
Get the delta.
Definition: cosine_embedding_loss.hpp:92
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: cosine_embedding_loss_impl.hpp:69
OutputDataType & OutputParameter() const
Get the output parameter.
Definition: cosine_embedding_loss.hpp:87
The core includes that mlpack expects; standard C++ includes and Armadillo.
InputDataType & InputParameter()
Modify the input parameter.
Definition: cosine_embedding_loss.hpp:84
bool & Similarity()
Modify the value of takeMean.
Definition: cosine_embedding_loss.hpp:109
void serialize(Archive &ar, const uint32_t)
Serialize the layer.
Definition: cosine_embedding_loss_impl.hpp:107
bool Similarity() const
Get the value of similarity hyperparameter.
Definition: cosine_embedding_loss.hpp:107
bool & TakeMean()
Modify the value of takeMean.
Definition: cosine_embedding_loss.hpp:99
InputDataType & InputParameter() const
Get the input parameter.
Definition: cosine_embedding_loss.hpp:82
PredictionType::elem_type Forward(const PredictionType &prediction, const TargetType &target)
Ordinary feed forward pass of a neural network.
Definition: cosine_embedding_loss_impl.hpp:32
double & Margin()
Modify the value of takeMean.
Definition: cosine_embedding_loss.hpp:104
Cosine Embedding Loss function is used for measuring whether two inputs are similar or dissimilar...
Definition: cosine_embedding_loss.hpp:39
OutputDataType & Delta()
Modify the delta.
Definition: cosine_embedding_loss.hpp:94
OutputDataType & OutputParameter()
Modify the output parameter.
Definition: cosine_embedding_loss.hpp:89
bool TakeMean() const
Get the value of takeMean.
Definition: cosine_embedding_loss.hpp:97