Struct TripletMarginLossImpl#
- Defined in File loss.h 
Page Contents
Inheritance Relationships#
Base Type#
- public torch::nn::Cloneable< TripletMarginLossImpl >(Template Class Cloneable)
Struct Documentation#
- 
struct TripletMarginLossImpl : public torch::nn::Cloneable<TripletMarginLossImpl>#
- Creates a criterion that measures the triplet loss given an input tensors :math: - x1, :math:- x2, :math:- x3and a margin with a value greater than :math:- 0.- This is used for measuring a relative similarity between samples. A triplet is composed by - a,- pand- n(i.e.,- anchor,- positive examplesand- negative examplesrespectively). The shapes of all input tensors should be :math:- (N, D). See https://pytorch.org/docs/main/nn.html#torch.nn.TripletMarginLoss to learn about the exact behavior of this module.- See the documentation for - torch::nn::TripletMarginLossOptionsclass to learn what constructor arguments are supported for this module.- Example: - TripletMarginLoss model(TripletMarginLossOptions().margin(3).p(2).eps(1e-06).swap(false)); - Public Functions - 
explicit TripletMarginLossImpl(TripletMarginLossOptions 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 - TripletMarginLossmodule into the given- stream.
 - 
Tensor forward(const Tensor &anchor, const Tensor &positive, const Tensor &negative)#
 - Public Members - 
TripletMarginLossOptions options#
- The options with which this - Modulewas constructed.
 
- 
explicit TripletMarginLossImpl(TripletMarginLossOptions options_ = {})#