Rate this Page

Struct TripletMarginWithDistanceLossImpl#

Inheritance Relationships#

Base Type#

Struct Documentation#

struct TripletMarginWithDistanceLossImpl : public torch::nn::Cloneable<TripletMarginWithDistanceLossImpl>#

Creates a criterion that measures the triplet loss given input tensors :math:a, :math:p, and :math:n (representing anchor, positive, and negative examples, respectively); and a nonnegative, real-valued function (“distance function”) used to compute the relationships between the anchor and positive example (“positive distance”) and the anchor and negative example (“negative distance”).

See https://pytorch.org/docs/main/nn.html#torch.nn.TripletMarginWithDistanceLoss to learn about the exact behavior of this module.

See the documentation for torch::nn::TripletMarginWithDistanceLossOptions class to learn what constructor arguments are supported for this module.

Example:

TripletMarginWithDistanceLoss
model(TripletMarginWithDistanceLossOptions().margin(3).swap(false));

Public Functions

explicit TripletMarginWithDistanceLossImpl(TripletMarginWithDistanceLossOptions 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 TripletMarginWithDistanceLoss module into the given stream.

Tensor forward(const Tensor &anchor, const Tensor &positive, const Tensor &negative)#

Public Members

TripletMarginWithDistanceLossOptions options#

The options with which this Module was constructed.