Struct surrealml_core::execution::compute::ModelComputation
source · pub struct ModelComputation<'a> {
pub surml_file: &'a mut SurMlFile,
}
Expand description
A wrapper for the loaded machine learning model so we can perform computations on the loaded model.
§Attributes
surml_file
- The loaded machine learning model using interior mutability to allow mutable access to the model
Fields§
§surml_file: &'a mut SurMlFile
Implementations§
source§impl<'a> ModelComputation<'a>
impl<'a> ModelComputation<'a>
sourcepub fn input_tensor_from_key_bindings(
&self,
input_values: HashMap<String, f32>
) -> Result<ArrayD<f32>, SurrealError>
pub fn input_tensor_from_key_bindings( &self, input_values: HashMap<String, f32> ) -> Result<ArrayD<f32>, SurrealError>
sourcepub fn input_vector_from_key_bindings(
&self,
input_values: HashMap<String, f32>
) -> Result<Vec<f32>, SurrealError>
pub fn input_vector_from_key_bindings( &self, input_values: HashMap<String, f32> ) -> Result<Vec<f32>, SurrealError>
Creates a Vector that can be used manipulated with other operations such as normalisation from a hashmap of keys and values.
§Arguments
input_values
- A hashmap of keys and values that will be used to create the input vector.
§Returns
A Vector that can be used manipulated with other operations such as normalisation.
sourcepub fn raw_compute(
&self,
tensor: ArrayD<f32>,
_dims: Option<(i32, i32)>
) -> Result<Vec<f32>, SurrealError>
pub fn raw_compute( &self, tensor: ArrayD<f32>, _dims: Option<(i32, i32)> ) -> Result<Vec<f32>, SurrealError>
sourcepub fn buffered_compute(
&self,
input_values: &mut HashMap<String, f32>
) -> Result<Vec<f32>, SurrealError>
pub fn buffered_compute( &self, input_values: &mut HashMap<String, f32> ) -> Result<Vec<f32>, SurrealError>
Checks the header applying normalisers if present and then performs a raw computation on the loaded model. Will also apply inverse normalisers if present on the outputs.
§Notes
This function is fairly coupled and will consider breaking out the functions later on if needed.
§Arguments
input_values
- A hashmap of keys and values that will be used to create the input tensor.
§Returns
The computed output tensor from the loaded model.
Auto Trait Implementations§
impl<'a> Freeze for ModelComputation<'a>
impl<'a> RefUnwindSafe for ModelComputation<'a>
impl<'a> Send for ModelComputation<'a>
impl<'a> Sync for ModelComputation<'a>
impl<'a> Unpin for ModelComputation<'a>
impl<'a> !UnwindSafe for ModelComputation<'a>
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