Cosine Embedding Loss function is used for measuring whether two inputs are similar or dissimilar, using the cosine distance, and is typically used for learning nonlinear embeddings or semi-supervised learning. More...
Public Member Functions | |
| CosineEmbeddingLoss (const double margin=0.0, const bool similarity=true, const bool takeMean=false) | |
| Create the CosineEmbeddingLoss object. More... | |
template < typename InputType , typename TargetType , typename OutputType > | |
| void | Backward (const InputType &input, const TargetType &target, OutputType &output) |
| Ordinary feed backward pass of a neural network. More... | |
| OutputDataType & | Delta () const |
| Get the delta. More... | |
| OutputDataType & | Delta () |
| Modify the delta. More... | |
template < typename InputType , typename TargetType > | |
| InputType::elem_type | Forward (const InputType &input, const TargetType &target) |
| Ordinary feed forward pass of a neural network. More... | |
| InputDataType & | InputParameter () const |
| Get the input parameter. More... | |
| InputDataType & | InputParameter () |
| Modify the input parameter. More... | |
| double | Margin () const |
| Get the value of margin. More... | |
| double & | Margin () |
| Modify the value of takeMean. More... | |
| OutputDataType & | OutputParameter () const |
| Get the output parameter. More... | |
| OutputDataType & | OutputParameter () |
| Modify the output parameter. More... | |
template < typename Archive > | |
| void | serialize (Archive &ar, const unsigned int) |
| Serialize the layer. More... | |
| bool | Similarity () const |
| Get the value of similarity hyperparameter. More... | |
| bool & | Similarity () |
| Modify the value of takeMean. More... | |
| bool | TakeMean () const |
| Get the value of takeMean. More... | |
| bool & | TakeMean () |
| Modify the value of takeMean. More... | |
Cosine Embedding Loss function is used for measuring whether two inputs are similar or dissimilar, using the cosine distance, and is typically used for learning nonlinear embeddings or semi-supervised learning.
| InputDataType | Type of the input data (arma::colvec, arma::mat, arma::sp_mat or arma::cube). |
| OutputDataType | Type of the output data (arma::colvec, arma::mat, arma::sp_mat or arma::cube). |
Definition at line 39 of file cosine_embedding_loss.hpp.
| CosineEmbeddingLoss | ( | const double | margin = 0.0, |
| const bool | similarity = true, |
||
| const bool | takeMean = false |
||
| ) |
Create the CosineEmbeddingLoss object.
| margin | Increases cosine distance in case of dissimilarity. Refer definition of cosine-embedding-loss above. |
| similarity | Determines whether to use similarity or dissimilarity for comparision. |
| takeMean | Boolean variable to specify whether to take mean or not. Specifies reduction method i.e. sum or mean corresponding to 0 and 1 respectively. Default value = 0. |
| void Backward | ( | const InputType & | input, |
| const TargetType & | target, | ||
| OutputType & | output | ||
| ) |
Ordinary feed backward pass of a neural network.
| input | The propagated input activation. |
| target | The target vector. |
| output | The calculated error. |
|
inline |
Get the delta.
Definition at line 90 of file cosine_embedding_loss.hpp.
|
inline |
Modify the delta.
Definition at line 92 of file cosine_embedding_loss.hpp.
| InputType::elem_type Forward | ( | const InputType & | input, |
| const TargetType & | target | ||
| ) |
Ordinary feed forward pass of a neural network.
| input | Input data used for evaluating the specified function. |
| target | The target vector. |
|
inline |
Get the input parameter.
Definition at line 80 of file cosine_embedding_loss.hpp.
|
inline |
Modify the input parameter.
Definition at line 82 of file cosine_embedding_loss.hpp.
|
inline |
Get the value of margin.
Definition at line 100 of file cosine_embedding_loss.hpp.
|
inline |
Modify the value of takeMean.
Definition at line 102 of file cosine_embedding_loss.hpp.
|
inline |
Get the output parameter.
Definition at line 85 of file cosine_embedding_loss.hpp.
|
inline |
Modify the output parameter.
Definition at line 87 of file cosine_embedding_loss.hpp.
| void serialize | ( | Archive & | ar, |
| const unsigned | int | ||
| ) |
Serialize the layer.
Referenced by CosineEmbeddingLoss< InputDataType, OutputDataType >::Similarity().
|
inline |
Get the value of similarity hyperparameter.
Definition at line 105 of file cosine_embedding_loss.hpp.
|
inline |
Modify the value of takeMean.
Definition at line 107 of file cosine_embedding_loss.hpp.
References CosineEmbeddingLoss< InputDataType, OutputDataType >::serialize().
|
inline |
Get the value of takeMean.
Definition at line 95 of file cosine_embedding_loss.hpp.
|
inline |
Modify the value of takeMean.
Definition at line 97 of file cosine_embedding_loss.hpp.