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...
|
| CosineEmbeddingLoss (const double margin=0.0, const bool similarity=true, const bool takeMean=false) |
| Create the CosineEmbeddingLoss object. More...
|
|
template<typename PredictionType , typename TargetType > |
PredictionType::elem_type | Forward (const PredictionType &prediction, const TargetType &target) |
| Ordinary feed forward pass of a neural network. More...
|
|
template<typename PredictionType , typename TargetType , typename LossType > |
void | Backward (const PredictionType &prediction, const TargetType &target, LossType &loss) |
| Ordinary feed backward pass of a neural network. More...
|
|
InputDataType & | InputParameter () const |
| Get the input parameter.
|
|
InputDataType & | InputParameter () |
| Modify the input parameter.
|
|
OutputDataType & | OutputParameter () const |
| Get the output parameter.
|
|
OutputDataType & | OutputParameter () |
| Modify the output parameter.
|
|
OutputDataType & | Delta () const |
| Get the delta.
|
|
OutputDataType & | Delta () |
| Modify the delta.
|
|
bool | TakeMean () const |
| Get the value of takeMean.
|
|
bool & | TakeMean () |
| Modify the value of takeMean.
|
|
double | Margin () const |
| Get the value of margin.
|
|
double & | Margin () |
| Modify the value of takeMean.
|
|
bool | Similarity () const |
| Get the value of similarity hyperparameter.
|
|
bool & | Similarity () |
| Modify the value of takeMean.
|
|
template<typename Archive > |
void | serialize (Archive &ar, const uint32_t) |
| Serialize the layer.
|
|
template<typename InputDataType = arma::mat, typename OutputDataType = arma::mat>
class mlpack::ann::CosineEmbeddingLoss< InputDataType, OutputDataType >
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.
\begin{eqnarray*} f(x) = 1 - cos(x1, x2) , for y = 1 f(x) = max(0, cos(x1, x2) - margin) , for y = -1 \end{eqnarray*}
- Template Parameters
-
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). |