Model

Struct Model 

Source
pub struct Model {
Show 15 fields pub layers: Vec<Layer>, pub lambda: f64, pub optimizer: Optimizer, pub layers_debug: Option<Vec<Layer>>, pub input: Option<Matrix>, pub input_label: Option<Matrix>, pub itermediate_evaluation_results: Option<Vec<Matrix>>, pub softmax_output: Option<Matrix>, pub data_loss: Option<f64>, pub reg_loss: Option<f64>, pub loss: Option<f64>, pub d_score: Option<Matrix>, pub d_zs: Option<Vec<Matrix>>, pub d_ws: Option<Vec<Matrix>>, pub d_bs: Option<Vec<Matrix>>,
}

Fields§

§layers: Vec<Layer>§lambda: f64§optimizer: Optimizer§layers_debug: Option<Vec<Layer>>§input: Option<Matrix>§input_label: Option<Matrix>§itermediate_evaluation_results: Option<Vec<Matrix>>§softmax_output: Option<Matrix>§data_loss: Option<f64>§reg_loss: Option<f64>§loss: Option<f64>§d_score: Option<Matrix>§d_zs: Option<Vec<Matrix>>§d_ws: Option<Vec<Matrix>>§d_bs: Option<Vec<Matrix>>

Implementations§

Source§

impl Model

Source

pub fn init(layers: Vec<Layer>, optimizer: Optimizer, lambda: f64) -> Model

Source

pub fn evaluate(&mut self, input: &Matrix, debug: bool) -> Matrix

Examples found in repository?
examples/mnist.rs (line 28)
14pub fn testing() {
15    println!("extracting mnist data...");
16    let labels: Matrix = extract_labels("t10k-labels.idx1-ubyte");
17    let mut images: Matrix = extract_images("t10k-images.idx3-ubyte");
18    println!("extraction done");
19
20    images.normalize();
21    println!("number of images {}", images.height);
22    println!("number of pixels in each image {}", images.width);
23
24    println!("loading pre-trained model...");
25    let mut model: Model = load_model("mnist_128x128".to_string()).unwrap();
26
27    println!("evaluating...");
28    let score = model.evaluate(&images, false);
29    let acc = model.accuracy(&score, &labels);
30
31    println!("acc : {}", acc);
32}
Source

pub fn compute_loss( &mut self, output: &Matrix, labels: &Matrix, debug: bool, ) -> (f64, f64)

Source

pub fn compute_d_score(score: &Matrix, labels: &Matrix) -> Matrix

Source

pub fn update_params( &mut self, d_score: Matrix, input: Matrix, iteration: i32, debug: bool, )

Source

pub fn train( &mut self, data: &Matrix, labels: &Matrix, batch_size: u32, epochs: u32, validation_dataset_size: usize, checkpoint: Option<Checkpoint>, print_frequency: usize, debug: bool, silent_mode: bool, ) -> Option<Vec<Model>>

Source

pub fn accuracy(&mut self, score: &Matrix, labels: &Matrix) -> f64

Examples found in repository?
examples/mnist.rs (line 29)
14pub fn testing() {
15    println!("extracting mnist data...");
16    let labels: Matrix = extract_labels("t10k-labels.idx1-ubyte");
17    let mut images: Matrix = extract_images("t10k-images.idx3-ubyte");
18    println!("extraction done");
19
20    images.normalize();
21    println!("number of images {}", images.height);
22    println!("number of pixels in each image {}", images.width);
23
24    println!("loading pre-trained model...");
25    let mut model: Model = load_model("mnist_128x128".to_string()).unwrap();
26
27    println!("evaluating...");
28    let score = model.evaluate(&images, false);
29    let acc = model.accuracy(&score, &labels);
30
31    println!("acc : {}", acc);
32}
Source

pub fn evaluation_output(score: &Matrix) -> Matrix

Trait Implementations§

Source§

impl Clone for Model

Source§

fn clone(&self) -> Model

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V