pub struct MultiModalContrastiveLearning { /* private fields */ }Expand description
Contrastive learning for multi-modal graphs
Implementations§
Source§impl MultiModalContrastiveLearning
impl MultiModalContrastiveLearning
Sourcepub fn new(
modalities: Vec<Modality>,
modality_dims: HashMap<Modality, usize>,
projection_dim: usize,
temperature: f32,
) -> Result<Self, TorshError>
pub fn new( modalities: Vec<Modality>, modality_dims: HashMap<Modality, usize>, projection_dim: usize, temperature: f32, ) -> Result<Self, TorshError>
Create new contrastive learning module
Sourcepub fn contrastive_loss(
&self,
modality1: Modality,
features1: &Tensor,
modality2: Modality,
features2: &Tensor,
) -> Result<f32, TorshError>
pub fn contrastive_loss( &self, modality1: Modality, features1: &Tensor, modality2: Modality, features2: &Tensor, ) -> Result<f32, TorshError>
Compute contrastive loss between modalities
Sourcepub fn generate_contrastive_pairs(
&self,
mm_graph: &MultiModalGraphData,
modality1: Modality,
modality2: Modality,
) -> Vec<(Tensor, Tensor, bool)>
pub fn generate_contrastive_pairs( &self, mm_graph: &MultiModalGraphData, modality1: Modality, modality2: Modality, ) -> Vec<(Tensor, Tensor, bool)>
Generate positive and negative pairs for contrastive learning
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MultiModalContrastiveLearning
impl RefUnwindSafe for MultiModalContrastiveLearning
impl Send for MultiModalContrastiveLearning
impl Sync for MultiModalContrastiveLearning
impl Unpin for MultiModalContrastiveLearning
impl UnsafeUnpin for MultiModalContrastiveLearning
impl UnwindSafe for MultiModalContrastiveLearning
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> 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