Struct TripletMarginWithDistanceLossImpl

Inheritance Relationships

Base Type

Struct Documentation

struct torch::nn::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 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.


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

Public Functions

TripletMarginWithDistanceLossImpl(TripletMarginWithDistanceLossOptions options_ = {})
void reset() override

reset() must perform initialization of all members with reference semantics, most importantly parameters, buffers and submodules.

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.


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources