pub struct FastAdaptationEngine<T: Float + Debug + Send + Sync + 'static> { /* private fields */ }Expand description
Fast adaptation engine
Implementations§
Source§impl<T: Float + Debug + Send + Sync + 'static> FastAdaptationEngine<T>
impl<T: Float + Debug + Send + Sync + 'static> FastAdaptationEngine<T>
Sourcepub fn new(config: FastAdaptationConfig) -> Result<Self>
pub fn new(config: FastAdaptationConfig) -> Result<Self>
Create a new fast adaptation engine
Sourcepub fn from_params(inner_lr: T, adaptation_steps: usize) -> Result<Self>
pub fn from_params(inner_lr: T, adaptation_steps: usize) -> Result<Self>
Create from inner learning rate and adaptation steps (convenience)
Sourcepub fn config(&self) -> &FastAdaptationConfig
pub fn config(&self) -> &FastAdaptationConfig
Get the configuration
Sourcepub fn adapt_fast(
&mut self,
_optimizer: &mut dyn FewShotOptimizer<T>,
_task_data: &TaskData<T>,
_strategy: AdaptationStrategyType,
_config: &AdaptationConfig,
) -> Result<AdaptationResult<T>>
pub fn adapt_fast( &mut self, _optimizer: &mut dyn FewShotOptimizer<T>, _task_data: &TaskData<T>, _strategy: AdaptationStrategyType, _config: &AdaptationConfig, ) -> Result<AdaptationResult<T>>
Perform fast adaptation
Source§impl<T: Float + Debug + Send + Sync + 'static> FastAdaptationEngine<T>
impl<T: Float + Debug + Send + Sync + 'static> FastAdaptationEngine<T>
Sourcepub fn adapt(
&self,
params: &Array1<T>,
gradients: &[Array1<T>],
inner_lr: T,
) -> Result<Array1<T>>
pub fn adapt( &self, params: &Array1<T>, gradients: &[Array1<T>], inner_lr: T, ) -> Result<Array1<T>>
Perform multi-step gradient adaptation on parameters.
For each gradient in gradients, applies one step:
params = params - inner_lr * gradient
returning the final adapted parameters.
Sourcepub fn select_algorithm(&self, task_complexity: T) -> AdaptationStrategyType
pub fn select_algorithm(&self, task_complexity: T) -> AdaptationStrategyType
Select an adaptation algorithm based on task complexity.
Low complexity -> FOMAML (fast, first-order) Medium -> MAML (second-order) High -> MemoryAugmented (richer capacity)
Sourcepub fn evaluate_adaptation(
&self,
before: &Array1<T>,
after: &Array1<T>,
) -> Result<T>
pub fn evaluate_adaptation( &self, before: &Array1<T>, after: &Array1<T>, ) -> Result<T>
Evaluate the quality of an adaptation step.
Returns the relative improvement: ||before|| - ||after|| normalised by ||before|| (higher is better; negative means regression).
Auto Trait Implementations§
impl<T> Freeze for FastAdaptationEngine<T>
impl<T> !RefUnwindSafe for FastAdaptationEngine<T>
impl<T> Send for FastAdaptationEngine<T>
impl<T> Sync for FastAdaptationEngine<T>
impl<T> Unpin for FastAdaptationEngine<T>
impl<T> UnsafeUnpin for FastAdaptationEngine<T>
impl<T> !UnwindSafe for FastAdaptationEngine<T>
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
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 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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.