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" 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.
InputDataType & InputParameter() const
Get the input parameter.
The core includes that mlpack expects; standard C++ includes and Armadillo.
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.
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 InputType &input, const TargetType &target, OutputType &output)
Ordinary feed backward pass of a neural network.