Sequential

Struct Sequential 

Source
pub struct Sequential { /* private fields */ }

Implementations§

Source§

impl Sequential

Source

pub fn new() -> Self

Source

pub fn new_simple(net_cfg: &Vec<usize>) -> Self

Examples found in repository?
examples/xor/main.rs (line 32)
18fn main() -> Result<(), Box<dyn std::error::Error>> {
19    init_logger();
20    log::info!("nevermind-neu xor example starting...");
21
22    // prepare data set
23    let mut dataset_train: Vec<LabeledEntry> = Vec::new();
24    dataset_train.push(LabeledEntry::new(vec![0.0, 0.0], vec![0.0]));
25    dataset_train.push(LabeledEntry::new(vec![0.0, 1.0], vec![1.0]));
26    dataset_train.push(LabeledEntry::new(vec![1.0, 0.0], vec![1.0]));
27    dataset_train.push(LabeledEntry::new(vec![1.0, 1.0], vec![0.0]));
28
29    let dataloader = Box::new(SimpleDataLoader::new(dataset_train));
30
31    let net_cfg = vec![2, 10, 1];
32    let mut seq_mdl = Sequential::new_simple(&net_cfg);
33    seq_mdl.set_batch_size(4);
34
35    let opt = Box::new(OptimizerRMS::new(1e-2, 0.8));
36    seq_mdl.set_optim(opt);
37
38    let mut net = Orchestra::new(seq_mdl).test_batch_size(4);
39
40    net.set_save_on_finish_flag(false);
41    net.set_train_dataset(dataloader);
42
43    let now_time = Instant::now();
44
45    net.train_for_error_or_iter(0.05, 2000)?;
46
47    let elapsed_bench = now_time.elapsed();
48
49    info!("Elapsed for training : {} ms", elapsed_bench.as_millis());
50
51    info!("Now testing net !!!");
52
53    let out = net.eval(array![[0.0, 0.0], [0.0, 1.0], [1.0, 0.0], [1.0, 1.0]]).unwrap();
54    let out_b = out.borrow();
55
56    info!("Trained-net XOR out : {}", out_b);
57
58    Ok(())
59}
Source

pub fn from_yaml(yaml_str: &str) -> Result<Self, Box<dyn Error>>

Source

pub fn new_with_layers(ls: SequentialLayersStorage) -> Self

Source

pub fn from_file(filepath: &str) -> Result<Self, Box<dyn Error>>

Source

pub fn to_file(&self, filepath: &str) -> Result<(), Box<dyn Error>>

Source

pub fn compile_shapes(&mut self)

Source

pub fn set_optim(&mut self, optim: Box<dyn Optimizer>)

Examples found in repository?
examples/xor/main.rs (line 36)
18fn main() -> Result<(), Box<dyn std::error::Error>> {
19    init_logger();
20    log::info!("nevermind-neu xor example starting...");
21
22    // prepare data set
23    let mut dataset_train: Vec<LabeledEntry> = Vec::new();
24    dataset_train.push(LabeledEntry::new(vec![0.0, 0.0], vec![0.0]));
25    dataset_train.push(LabeledEntry::new(vec![0.0, 1.0], vec![1.0]));
26    dataset_train.push(LabeledEntry::new(vec![1.0, 0.0], vec![1.0]));
27    dataset_train.push(LabeledEntry::new(vec![1.0, 1.0], vec![0.0]));
28
29    let dataloader = Box::new(SimpleDataLoader::new(dataset_train));
30
31    let net_cfg = vec![2, 10, 1];
32    let mut seq_mdl = Sequential::new_simple(&net_cfg);
33    seq_mdl.set_batch_size(4);
34
35    let opt = Box::new(OptimizerRMS::new(1e-2, 0.8));
36    seq_mdl.set_optim(opt);
37
38    let mut net = Orchestra::new(seq_mdl).test_batch_size(4);
39
40    net.set_save_on_finish_flag(false);
41    net.set_train_dataset(dataloader);
42
43    let now_time = Instant::now();
44
45    net.train_for_error_or_iter(0.05, 2000)?;
46
47    let elapsed_bench = now_time.elapsed();
48
49    info!("Elapsed for training : {} ms", elapsed_bench.as_millis());
50
51    info!("Now testing net !!!");
52
53    let out = net.eval(array![[0.0, 0.0], [0.0, 1.0], [1.0, 0.0], [1.0, 1.0]]).unwrap();
54    let out_b = out.borrow();
55
56    info!("Trained-net XOR out : {}", out_b);
57
58    Ok(())
59}
Source

pub fn add_layer(&mut self, l: Box<dyn AbstractLayer>)

Trait Implementations§

Source§

impl Clone for Sequential

Source§

fn clone(&self) -> Sequential

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
Source§

impl<'de> Deserialize<'de> for Sequential

Source§

fn deserialize<D>(deserializer: D) -> Result<Sequential, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Model for Sequential

Source§

fn feedforward(&mut self, train_data: Array2D)

Source§

fn backpropagate(&mut self, expected: Array2D)

Source§

fn optimize(&mut self)

Source§

fn optimizer(&self) -> &Box<dyn WithParams>

Source§

fn optimizer_mut(&mut self) -> &mut Box<dyn WithParams>

Source§

fn model_type(&self) -> &str

Source§

fn output_params(&self) -> CpuParams

Source§

fn last_layer_metrics(&self) -> Option<&Metrics>

Source§

fn batch_size(&self) -> usize

Source§

fn set_batch_size(&mut self, batch_size: usize)

Source§

fn set_batch_size_for_tests(&mut self, batch_size: usize)

Source§

fn layer(&self, id: usize) -> &Box<dyn AbstractLayer>

Source§

fn layers_count(&self) -> usize

Source§

fn last_layer(&self) -> &Box<dyn AbstractLayer>

Source§

fn save_state(&self, filepath: &str) -> Result<(), Box<dyn Error>>

Source§

fn load_state(&mut self, filepath: &str) -> Result<(), Box<dyn Error>>

Source§

impl Serialize for Sequential

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,