Struct CosineEmbeddingLossImpl#
Defined in File loss.h
Page Contents
Inheritance Relationships#
Base Type#
public torch::nn::Cloneable< CosineEmbeddingLossImpl >
(Template Class Cloneable)
Struct Documentation#
-
struct CosineEmbeddingLossImpl : public torch::nn::Cloneable<CosineEmbeddingLossImpl>#
Creates a criterion that measures the loss given input tensors
input1
,input2
, and aTensor
labeltarget
with 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. See https://pytorch.org/docs/main/nn.html#torch.nn.CosineEmbeddingLoss to learn about the exact behavior of this module.
See the documentation for
torch::nn::CosineEmbeddingLossOptions
class to learn what constructor arguments are supported for this module.Example:
CosineEmbeddingLoss model(CosineEmbeddingLossOptions().margin(0.5));
Public Functions
-
explicit CosineEmbeddingLossImpl(CosineEmbeddingLossOptions options_ = {})#
-
virtual void reset() override#
reset()
must perform initialization of all members with reference semantics, most importantly parameters, buffers and submodules.
-
virtual void pretty_print(std::ostream &stream) const override#
Pretty prints the
CosineEmbeddingLoss
module into the givenstream
.
-
Tensor forward(const Tensor &input1, const Tensor &input2, const Tensor &target)#
Public Members
-
CosineEmbeddingLossOptions options#
The options with which this
Module
was constructed.
-
explicit CosineEmbeddingLossImpl(CosineEmbeddingLossOptions options_ = {})#