Skip to main content

CrossDomainTransfer

Struct CrossDomainTransfer 

Source
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>

Source

pub fn new(shared_dim: usize) -> Self

Create a new engine with a shared representation of the given dimension.

Source

pub fn transfer_history(&self) -> &[TransferResult<T>]

Get a reference to the transfer history.

Source

pub fn shared_representation(&self) -> &SharedRepresentation<T>

Get a reference to the shared representation.

Source

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.

Source

pub fn get_registered_domains(&self) -> Vec<&str>

Return the names of all registered domains (sorted for determinism).

Source

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.

Source

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.

Source

pub fn update_shared_representation( &mut self, domain_name: &str, gradients: &Array1<T>, lr: T, ) -> Result<()>

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.

Source

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§

Source§

impl<T: Debug + Float + Debug + Send + Sync + 'static> Debug for CrossDomainTransfer<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V