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);
63 template <
typename InputType,
typename TargetType>
64 typename InputType::elem_type
Forward(
const InputType& input,
65 const TargetType& target);
74 template<
typename InputType,
typename TargetType,
typename OutputType>
75 void Backward(
const InputType& input,
76 const TargetType& target,
90 OutputDataType&
Delta()
const {
return delta; }
92 OutputDataType&
Delta() {
return delta; }
112 template<
typename Archive>
113 void serialize(Archive& ar,
const unsigned int );
117 OutputDataType delta;
120 InputDataType inputParameter;
123 OutputDataType outputParameter;
139 #include "cosine_embedding_loss_impl.hpp"
OutputDataType & OutputParameter() const
Get the output parameter.
bool & Similarity()
Modify the value of takeMean.
OutputDataType & OutputParameter()
Modify the output parameter.
CosineEmbeddingLoss(const double margin=0.0, const bool similarity=true, const bool takeMean=false)
Create the CosineEmbeddingLoss object.
The core includes that mlpack expects; standard C++ includes and Armadillo.
InputDataType & InputParameter() const
Get the input parameter.
bool Similarity() const
Get the value of similarity hyperparameter.
OutputDataType & Delta()
Modify the delta.
void serialize(Archive &ar, const unsigned int)
Serialize the layer.
bool & TakeMean()
Modify the value of takeMean.
double Margin() const
Get the value of margin.
InputType::elem_type Forward(const InputType &input, const TargetType &target)
Ordinary feed forward pass of a neural network.
InputDataType & InputParameter()
Modify the input parameter.
bool TakeMean() const
Get the value of takeMean.
double & Margin()
Modify the value of takeMean.
OutputDataType & Delta() const
Get the delta.
Cosine Embedding Loss function is used for measuring whether two inputs are similar or dissimilar...
void Backward(const InputType &input, const TargetType &target, OutputType &output)
Ordinary feed backward pass of a neural network.