pub struct ModelCheckpoint {
pub metadata: ModelMetadata,
pub weights: HashMap<String, Vec<f32>>,
pub shapes: HashMap<String, Vec<usize>>,
}Expand description
Model checkpoint containing weights and metadata
Fields§
§metadata: ModelMetadataCheckpoint metadata
weights: HashMap<String, Vec<f32>>Model weights as tensor data
shapes: HashMap<String, Vec<usize>>Weight shapes for reconstruction
Implementations§
Source§impl ModelCheckpoint
impl ModelCheckpoint
Sourcepub fn new(metadata: ModelMetadata) -> Self
pub fn new(metadata: ModelMetadata) -> Self
Create a new checkpoint
Sourcepub fn add_weight(&mut self, name: String, data: Vec<f32>, shape: Vec<usize>)
pub fn add_weight(&mut self, name: String, data: Vec<f32>, shape: Vec<usize>)
Add a weight tensor to the checkpoint
Sourcepub fn add_array2(&mut self, name: String, array: &Array2<f32>)
pub fn add_array2(&mut self, name: String, array: &Array2<f32>)
Add a 2D array weight
Sourcepub fn get_array2(&self, name: &str) -> TokenizerResult<Array2<f32>>
pub fn get_array2(&self, name: &str) -> TokenizerResult<Array2<f32>>
Get a weight as Array2
Sourcepub fn save<P: AsRef<Path>>(&self, path: P) -> TokenizerResult<()>
pub fn save<P: AsRef<Path>>(&self, path: P) -> TokenizerResult<()>
Save checkpoint to safetensors format
Sourcepub fn load<P: AsRef<Path>>(path: P) -> TokenizerResult<Self>
pub fn load<P: AsRef<Path>>(path: P) -> TokenizerResult<Self>
Load checkpoint from safetensors format
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ModelCheckpoint
impl RefUnwindSafe for ModelCheckpoint
impl Send for ModelCheckpoint
impl Sync for ModelCheckpoint
impl Unpin for ModelCheckpoint
impl UnwindSafe for ModelCheckpoint
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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