pub struct ModelAdapter<T: FloatBounds> { /* private fields */ }Expand description
Model adapter for replacing layers during transfer learning
Implementations§
Source§impl<T: FloatBounds + ScalarOperand> ModelAdapter<T>
impl<T: FloatBounds + ScalarOperand> ModelAdapter<T>
Sourcepub fn new(init_strategy: InitStrategy) -> Self
pub fn new(init_strategy: InitStrategy) -> Self
Create a new model adapter
Sourcepub fn replace_layer(
&mut self,
layer_name: String,
new_layer: Box<dyn Layer<T>>,
)
pub fn replace_layer( &mut self, layer_name: String, new_layer: Box<dyn Layer<T>>, )
Add a layer replacement
Sourcepub fn replace_classifier(
&mut self,
num_classes: usize,
hidden_size: usize,
_layer_name: String,
) -> NeuralResult<()>
pub fn replace_classifier( &mut self, num_classes: usize, hidden_size: usize, _layer_name: String, ) -> NeuralResult<()>
Remove the final classification layer and add a new one
Sourcepub fn apply_replacements<M>(&self, model: &mut M) -> NeuralResult<()>where
M: HasReplaceableLayer<T>,
pub fn apply_replacements<M>(&self, model: &mut M) -> NeuralResult<()>where
M: HasReplaceableLayer<T>,
Apply layer replacements to a model
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for ModelAdapter<T>
impl<T> !Send for ModelAdapter<T>
impl<T> !Sync for ModelAdapter<T>
impl<T> !UnwindSafe for ModelAdapter<T>
impl<T> Freeze for ModelAdapter<T>
impl<T> Unpin for ModelAdapter<T>
impl<T> UnsafeUnpin for ModelAdapter<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
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