pub struct Sequential { /* private fields */ }Implementations§
Source§impl Sequential
impl Sequential
pub fn new() -> Self
Sourcepub fn new_simple(net_cfg: &Vec<usize>) -> Self
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}pub fn from_yaml(yaml_str: &str) -> Result<Self, Box<dyn Error>>
pub fn new_with_layers(ls: SequentialLayersStorage) -> Self
pub fn from_file(filepath: &str) -> Result<Self, Box<dyn Error>>
pub fn to_file(&self, filepath: &str) -> Result<(), Box<dyn Error>>
pub fn compile_shapes(&mut self)
Sourcepub fn set_optim(&mut self, optim: Box<dyn Optimizer>)
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}pub fn add_layer(&mut self, l: Box<dyn AbstractLayer>)
Trait Implementations§
Source§impl Clone for Sequential
impl Clone for Sequential
Source§fn clone(&self) -> Sequential
fn clone(&self) -> Sequential
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'de> Deserialize<'de> for Sequential
impl<'de> Deserialize<'de> for Sequential
Source§fn deserialize<D>(deserializer: D) -> Result<Sequential, D::Error>where
D: Deserializer<'de>,
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
impl Model for Sequential
fn feedforward(&mut self, train_data: Array2D)
fn backpropagate(&mut self, expected: Array2D)
fn optimize(&mut self)
fn optimizer(&self) -> &Box<dyn WithParams>
fn optimizer_mut(&mut self) -> &mut Box<dyn WithParams>
fn model_type(&self) -> &str
fn output_params(&self) -> CpuParams
fn last_layer_metrics(&self) -> Option<&Metrics>
fn batch_size(&self) -> usize
fn set_batch_size(&mut self, batch_size: usize)
fn set_batch_size_for_tests(&mut self, batch_size: usize)
fn layer(&self, id: usize) -> &Box<dyn AbstractLayer>
fn layers_count(&self) -> usize
fn last_layer(&self) -> &Box<dyn AbstractLayer>
fn save_state(&self, filepath: &str) -> Result<(), Box<dyn Error>>
fn load_state(&mut self, filepath: &str) -> Result<(), Box<dyn Error>>
Auto Trait Implementations§
impl Freeze for Sequential
impl !RefUnwindSafe for Sequential
impl !Send for Sequential
impl !Sync for Sequential
impl Unpin for Sequential
impl !UnwindSafe for Sequential
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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