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