pub struct Model {
pub metadata: ModelMetadata,
pub parameters: Vec<(String, Tensor)>,
}Expand description
High-level model abstraction for I/O
Fields§
§metadata: ModelMetadataModel metadata
parameters: Vec<(String, Tensor)>Model parameters
Implementations§
Source§impl Model
impl Model
Sourcepub fn new(metadata: ModelMetadata, parameters: Vec<(String, Tensor)>) -> Self
pub fn new(metadata: ModelMetadata, parameters: Vec<(String, Tensor)>) -> Self
Create a new model
Sourcepub fn get_parameter(&self, name: &str) -> Option<&Tensor>
pub fn get_parameter(&self, name: &str) -> Option<&Tensor>
Get parameter by name
Sourcepub fn get_parameter_mut(&mut self, name: &str) -> Option<&mut Tensor>
pub fn get_parameter_mut(&mut self, name: &str) -> Option<&mut Tensor>
Get mutable parameter by name
Sourcepub fn from_state(state: ModelState) -> Self
pub fn from_state(state: ModelState) -> Self
Create model from serializable state
Auto Trait Implementations§
impl Freeze for Model
impl !RefUnwindSafe for Model
impl !Send for Model
impl !Sync for Model
impl Unpin for Model
impl !UnwindSafe for Model
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