Struct CosineEmbeddingLossImpl#
Defined inFile loss.h
Inheritance Relationships#
Base Type#
publictorch::nn::Cloneable<CosineEmbeddingLossImpl>(Template Class Cloneable)
Struct Documentation#
- structCosineEmbeddingLossImpl:publictorch::nn::Cloneable<CosineEmbeddingLossImpl>#
Creates a criterion that measures the loss given input tensors
input1,input2, and aTensorlabeltargetwith values 1 or -1.This 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. Seehttps://pytorch.org/docs/main/nn.html#torch.nn.CosineEmbeddingLoss to learn about the exact behavior of this module.
See the documentation for
torch::nn::CosineEmbeddingLossOptionsclass to learn what constructor arguments are supported for this module.Example:
CosineEmbeddingLossmodel(CosineEmbeddingLossOptions().margin(0.5));
Public Functions
- explicitCosineEmbeddingLossImpl(CosineEmbeddingLossOptionsoptions_={})#
- virtualvoidreset()override#
reset()must perform initialization of all members with reference semantics, most importantly parameters, buffers and submodules.
- virtualvoidpretty_print(std::ostream&stream)constoverride#
Pretty prints the
CosineEmbeddingLossmodule into the givenstream.
- Tensorforward(constTensor&input1,constTensor&input2,constTensor&target)#
Public Members
- CosineEmbeddingLossOptionsoptions#
The options with which this
Modulewas constructed.
- explicitCosineEmbeddingLossImpl(CosineEmbeddingLossOptionsoptions_={})#