parent
d3d5f57a2b
commit
7a6921a1c1
@ -0,0 +1,42 @@
|
|||||||
|
#![feature(generic_arg_infer)]
|
||||||
|
|
||||||
|
use neuramethyst::prelude::*;
|
||||||
|
use neuramethyst::derivable::activation::{Relu, Tanh};
|
||||||
|
use neuramethyst::derivable::loss::Euclidean;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mut network = neura_network![
|
||||||
|
neura_layer!("dense", Tanh, 2, 2),
|
||||||
|
neura_layer!("dense", Tanh, 3),
|
||||||
|
neura_layer!("dense", Relu, 1)
|
||||||
|
];
|
||||||
|
|
||||||
|
let inputs = [
|
||||||
|
([0.0, 0.0], [0.0]),
|
||||||
|
([0.0, 1.0], [1.0]),
|
||||||
|
([1.0, 0.0], [1.0]),
|
||||||
|
([1.0, 1.0], [0.0])
|
||||||
|
];
|
||||||
|
|
||||||
|
// println!("{:#?}", network);
|
||||||
|
|
||||||
|
for (input, target) in inputs {
|
||||||
|
println!("Input: {:?}, target: {}, actual: {}", &input, target[0], network.eval(&input)[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
train_batched(
|
||||||
|
&mut network,
|
||||||
|
inputs.clone(),
|
||||||
|
&inputs,
|
||||||
|
NeuraBackprop::new(Euclidean),
|
||||||
|
0.01,
|
||||||
|
1,
|
||||||
|
25
|
||||||
|
);
|
||||||
|
|
||||||
|
// println!("{:#?}", network);
|
||||||
|
|
||||||
|
for (input, target) in inputs {
|
||||||
|
println!("Input: {:?}, target: {}, actual: {}", &input, target[0], network.eval(&input)[0]);
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,19 @@
|
|||||||
#![feature(generic_arg_infer)]
|
#![feature(generic_arg_infer)]
|
||||||
|
|
||||||
|
pub mod algebra;
|
||||||
pub mod derivable;
|
pub mod derivable;
|
||||||
pub mod layer;
|
pub mod layer;
|
||||||
pub mod network;
|
pub mod network;
|
||||||
pub mod train;
|
pub mod train;
|
||||||
pub mod algebra;
|
|
||||||
|
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
|
pub mod prelude {
|
||||||
|
// Macros
|
||||||
|
pub use crate::{neura_network, neura_layer};
|
||||||
|
|
||||||
|
// Structs and traits
|
||||||
|
pub use super::network::{NeuraNetwork};
|
||||||
|
pub use super::layer::{NeuraLayer, NeuraDenseLayer};
|
||||||
|
pub use super::train::{NeuraBackprop, train_batched};
|
||||||
|
}
|
||||||
|
Loading…
Reference in new issue