Shortcuts

Struct TripletMarginLossOptions

Page Contents

Struct Documentation

struct torch::nn::TripletMarginLossOptions

Options for the TripletMarginLoss module.

Example:

TripletMarginLoss model(TripletMarginLossOptions().margin(3).p(2).eps(1e-06).swap(false));

Public Types

typedef c10::variant<enumtype::kNone, enumtype::kMean, enumtype::kSum> reduction_t

Public Functions

auto margin(const double &new_margin) -> decltype(*this)

Specifies the threshold for which the distance of a negative sample must reach in order to incur zero loss.

Default: 1

auto margin(double &&new_margin) -> decltype(*this)
const double &margin() const noexcept
double &margin() noexcept
auto p(const double &new_p) -> decltype(*this)

Specifies the norm degree for pairwise distance. Default: 2.

auto p(double &&new_p) -> decltype(*this)
const double &p() const noexcept
double &p() noexcept
auto eps(const double &new_eps) -> decltype(*this)
auto eps(double &&new_eps) -> decltype(*this)
const double &eps() const noexcept
double &eps() noexcept
auto swap(const bool &new_swap) -> decltype(*this)

The distance swap is described in detail in the paper Learning shallow convolutional feature descriptors with triplet losses by V.

Balntas, E. Riba et al. Default: False

auto swap(bool &&new_swap) -> decltype(*this)
const bool &swap() const noexcept
bool &swap() noexcept
auto reduction(const reduction_t &new_reduction) -> decltype(*this)

Specifies the reduction to apply to the output. Default: Mean.

auto reduction(reduction_t &&new_reduction) -> decltype(*this)
const reduction_t &reduction() const noexcept
reduction_t &reduction() noexcept

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources