Struct TripletMarginWithDistanceLossOptions¶
Defined in File loss.h
Page Contents
Struct Documentation¶
-
struct TripletMarginWithDistanceLossOptions¶
Options for the
TripletMarginWithDistanceLoss
module.Example:
TripletMarginWithDistanceLoss model(TripletMarginWithDistanceLossOptions().margin(3).swap(false));
Public Types
-
typedef std::function<Tensor(const Tensor&, const Tensor&)> distance_function_t¶
Public Functions
-
inline auto distance_function(const std::optional<distance_function_t> &new_distance_function) -> decltype(*this)¶
Specifies a nonnegative, real-valued function that quantifies the closeness of two tensors.
If not specified,
F::pairwise_distance
will be used. Default: nullopt
-
inline auto distance_function(std::optional<distance_function_t> &&new_distance_function) -> decltype(*this)¶
-
inline const std::optional<distance_function_t> &distance_function() const noexcept¶
-
inline std::optional<distance_function_t> &distance_function() noexcept¶
-
inline auto margin(const double &new_margin) -> decltype(*this)¶
Specifies a nonnegative margin representing the minimum difference between the positive and negative distances required for the loss to be 0.
Larger margins penalize cases where the negative examples are not distance enough from the anchors, relative to the positives. Default: 1
-
inline auto margin(double &&new_margin) -> decltype(*this)¶
-
inline const double &margin() const noexcept¶
-
inline double &margin() noexcept¶
-
inline auto swap(const bool &new_swap) -> decltype(*this)¶
Whether to use the distance swap described in the paper Learning shallow convolutional feature descriptors with triplet losses by V.
Balntas, E. Riba et al. If True, and if the positive example is closer to the negative example than the anchor is, swaps the positive example and the anchor in the loss computation. Default: False
-
inline auto swap(bool &&new_swap) -> decltype(*this)¶
-
inline const bool &swap() const noexcept¶
-
inline bool &swap() noexcept¶
-
inline auto reduction(const reduction_t &new_reduction) -> decltype(*this)¶
Specifies the reduction to apply to the output. Default: Mean.
-
inline auto reduction(reduction_t &&new_reduction) -> decltype(*this)¶
-
inline const reduction_t &reduction() const noexcept¶
-
inline reduction_t &reduction() noexcept¶
-
typedef std::function<Tensor(const Tensor&, const Tensor&)> distance_function_t¶