1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
pub mod dataset;
pub mod neural_network;
pub mod plotter;
#[allow(unused_imports)]
use crate::{
dataset::example_datasets::{CIRCLE, RGB_DONUT, RGB_TEST, XOR},
neural_network::{
activation_function::{linear::LINEAR, relu::RELU, sigmoid::SIGMOID},
cost_function::quadratic_cost::QUADRATIC_COST,
optimizer::{adam_optimizer::ADAM, rmsprop_optimizer::RMS_PROP, sgd_optimzer::SGD},
Network, Summary,
},
plotter::{graph_plotter::plot_graph, png_plotter::plot_png},
};
#[allow(dead_code)]
fn main() {
let network_shape = [
(&RELU, 2),
(&RELU, 32),
(&RELU, 32),
(&RELU, 32),
(&RELU, 3),
];
let mut optimizer = ADAM::default();
let mut network = Network::new(&network_shape, &mut optimizer, &QUADRATIC_COST);
let dataset = &RGB_DONUT;
let cost_history = network.train_and_log(dataset, 128, 512, 10000);
let (dim, unit_square_prediction) = network.predict_unit_square(512);
let name = String::from(dataset.name) + "_" + &network.summerize();
plot_png(&name, dim, &unit_square_prediction, png::ColorType::Rgb).unwrap();
plot_graph(&name, &cost_history).unwrap();
}