pub struct SimCLR { /* private fields */ }Expand description
SimCLR framework (Chen et al., 2020).
Simple framework for contrastive learning of visual representations:
- Apply two random augmentations to create positive pairs
- Use NT-Xent loss (normalized temperature-scaled cross-entropy)
§Reference
Chen, T., et al. (2020). A Simple Framework for Contrastive Learning of Visual Representations. ICML.
Implementations§
Source§impl SimCLR
impl SimCLR
Sourcepub fn nt_xent_loss(&self, z_i: &[Vec<f32>], z_j: &[Vec<f32>]) -> f32
pub fn nt_xent_loss(&self, z_i: &[Vec<f32>], z_j: &[Vec<f32>]) -> f32
Compute NT-Xent loss for a batch of positive pairs.
§Arguments
z_i- First augmented view embeddings[batch_size, dim]z_j- Second augmented view embeddings[batch_size, dim]
For each sample i, its positive pair is z_j[i] and negatives are
all other samples in the batch.
pub fn temperature(&self) -> f32
pub fn projection_dim(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SimCLR
impl RefUnwindSafe for SimCLR
impl Send for SimCLR
impl Sync for SimCLR
impl Unpin for SimCLR
impl UnsafeUnpin for SimCLR
impl UnwindSafe for SimCLR
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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 more