pub struct TripletLoss {
pub axis: i32,
pub p: f32,
pub margin: f32,
pub eps: f32,
pub reduction: LossReduction,
}Expand description
Computes the triplet loss for a set of anchor, positive, and negative samples. Margin is represented with alpha in the math section.
Fields§
§axis: i32Distribution axis. Default to TripletLoss::DEFAULT_AXIS
p: f32The norm degree for pairwise distance. Default to TripletLoss::DEFAULT_P
margin: f32Margin for the triplet loss. Default to TripletLoss::DEFAULT_MARGIN
eps: f32Small positive constant for numerical stability. Default to TripletLoss::DEFAULT_EPS
reduction: LossReductionReduction type. Default to TripletLoss::DEFAULT_REDUCTION
Implementations§
Source§impl TripletLoss
impl TripletLoss
Source§impl TripletLoss
impl TripletLoss
Sourcepub const DEFAULT_AXIS: i32 = -1
pub const DEFAULT_AXIS: i32 = -1
Default value for the axis parameter.
Sourcepub const DEFAULT_MARGIN: f32 = 1.0
pub const DEFAULT_MARGIN: f32 = 1.0
Default value for the margin parameter.
Sourcepub const DEFAULT_EPS: f32 = 1e-6
pub const DEFAULT_EPS: f32 = 1e-6
Default value for the eps parameter.
Sourcepub const DEFAULT_REDUCTION: LossReduction = LossReduction::None
pub const DEFAULT_REDUCTION: LossReduction = LossReduction::None
Default value for the reduction parameter.
Sourcepub fn apply(
&self,
anchors: impl AsRef<Array>,
positives: impl AsRef<Array>,
negatives: impl AsRef<Array>,
) -> Result<Array, Exception>
pub fn apply( &self, anchors: impl AsRef<Array>, positives: impl AsRef<Array>, negatives: impl AsRef<Array>, ) -> Result<Array, Exception>
Computes the triplet loss for a set of anchor, positive, and negative samples. Margin is represented with alpha in the math section.
§Params
anchors: The anchor samplespositives: The positive samplesneonatives: The negative samples
Trait Implementations§
Source§impl Buildable for TripletLoss
impl Buildable for TripletLoss
Source§type Builder = TripletLossBuilder
type Builder = TripletLossBuilder
Source§impl Builder<TripletLoss> for TripletLossBuilder
impl Builder<TripletLoss> for TripletLossBuilder
Source§type Error = Infallible
type Error = Infallible
Source§impl Clone for TripletLoss
impl Clone for TripletLoss
Source§fn clone(&self) -> TripletLoss
fn clone(&self) -> TripletLoss
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for TripletLoss
impl RefUnwindSafe for TripletLoss
impl Send for TripletLoss
impl Sync for TripletLoss
impl Unpin for TripletLoss
impl UnsafeUnpin for TripletLoss
impl UnwindSafe for TripletLoss
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Option.