pub struct CrossDomainTransfer<T: Float + Debug + Send + Sync + 'static> { /* private fields */ }Expand description
Engine for cross-domain knowledge transfer.
Maintains a registry of domain-specific knowledge and a global shared representation. Supports computing pairwise domain similarities and performing transfer of knowledge from one domain to another.
Implementations§
Source§impl<T: Float + Debug + Send + Sync + 'static + ScalarOperand> CrossDomainTransfer<T>
impl<T: Float + Debug + Send + Sync + 'static + ScalarOperand> CrossDomainTransfer<T>
Sourcepub fn new(shared_dim: usize) -> Self
pub fn new(shared_dim: usize) -> Self
Create a new engine with a shared representation of the given dimension.
Sourcepub fn transfer_history(&self) -> &[TransferResult<T>]
pub fn transfer_history(&self) -> &[TransferResult<T>]
Get a reference to the transfer history.
Get a reference to the shared representation.
Sourcepub fn register_domain(&mut self, knowledge: DomainKnowledge<T>) -> Result<()>
pub fn register_domain(&mut self, knowledge: DomainKnowledge<T>) -> Result<()>
Register a new domain or update an existing one.
§Errors
Returns OptimError::InvalidConfig if the domain’s shared
representation dimension does not match the engine’s shared dimension.
Sourcepub fn get_registered_domains(&self) -> Vec<&str>
pub fn get_registered_domains(&self) -> Vec<&str>
Return the names of all registered domains (sorted for determinism).
Sourcepub fn compute_domain_similarity(&self, source: &str, target: &str) -> Result<T>
pub fn compute_domain_similarity(&self, source: &str, target: &str) -> Result<T>
Compute the cosine similarity between two domains’ shared representations.
The result is in [-1, 1]. If both vectors are zero the similarity is defined as zero.
§Errors
Returns OptimError::InvalidState if either domain is not registered.
Sourcepub fn transfer(
&mut self,
source: &str,
target: &str,
) -> Result<TransferResult<T>>
pub fn transfer( &mut self, source: &str, target: &str, ) -> Result<TransferResult<T>>
Transfer knowledge from source domain to target domain.
The adapted parameters are computed as:
transferred = target_specific
+ transferability * (source_shared - target_shared)where transferability is (cosine_similarity + 1) / 2 (mapped to
[0, 1]).
§Errors
Returns OptimError::InvalidState if either domain is not registered,
or OptimError::ComputationError if domain-specific parameter
dimensions differ.
Update the shared representation using gradients from a specific domain.
Applies a simple gradient-descent step:
shared_features -= lr * gradients
and also updates the domain’s own shared-representation snapshot.
§Errors
Returns OptimError::InvalidState if the domain is not registered, or
OptimError::ComputationError on dimension mismatch.
Sourcepub fn get_transferability_matrix(&self) -> Result<Array2<T>>
pub fn get_transferability_matrix(&self) -> Result<Array2<T>>
Compute an NxN pairwise transferability (cosine-similarity) matrix.
Rows and columns are ordered by sorted domain name. The diagonal is 1.0 (self-similarity).
§Errors
Returns OptimError::InsufficientData if fewer than two domains are
registered.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for CrossDomainTransfer<T>
impl<T> RefUnwindSafe for CrossDomainTransfer<T>where
T: RefUnwindSafe,
impl<T> Send for CrossDomainTransfer<T>
impl<T> Sync for CrossDomainTransfer<T>
impl<T> Unpin for CrossDomainTransfer<T>where
T: Unpin,
impl<T> UnsafeUnpin for CrossDomainTransfer<T>
impl<T> UnwindSafe for CrossDomainTransfer<T>where
T: RefUnwindSafe + UnwindSafe,
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
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> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.