Проба примера

master

148
Cargo.lock generated

@ -5,3 +5,151 @@ version = 3
[[package]] [[package]]
name = "Neur" name = "Neur"
version = "0.1.0" version = "0.1.0"
dependencies = [
"rand",
"serde",
"serde_json",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "getrandom"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"
dependencies = [
"cfg-if",
"libc",
"wasi",
]
[[package]]
name = "itoa"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]]
name = "libc"
version = "0.2.151"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
[[package]]
name = "ppv-lite86"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "proc-macro2"
version = "1.0.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a293318316cf6478ec1ad2a21c49390a8d5b5eae9fab736467d93fbc0edc29c5"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22a37c9326af5ed140c86a46655b5278de879853be5573c01df185b6f49a580a"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha",
"rand_core",
]
[[package]]
name = "rand_chacha"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom",
]
[[package]]
name = "ryu"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
[[package]]
name = "serde"
version = "1.0.193"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.193"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.108"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "syn"
version = "2.0.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"

@ -1,11 +1,41 @@
use activations::RELU; use activations::{RELU, SIGMOID};
use network::Network; use network::Network;
use crate::activations::TANH;
pub mod activations; pub mod activations;
pub mod matrix; pub mod matrix;
pub mod network; pub mod network;
pub mod simula; pub mod simula;
fn main(){ fn main(){
let inputs = vec![
vec![0.0,0.0],
vec![0.0,1.0],
vec![1.0,0.0],
vec![1.0,1.0],
];
let targets = vec![
vec![0.0],
vec![1.0],
vec![1.0],
vec![0.0],
];
let mut network = Network::new(vec![2, 3, 1], 1.0, SIGMOID);
println!("0 and 0: {:?}", network.feed_forward(vec![0.0,0.0]));
println!("0 and 1: {:?}", network.feed_forward(vec![0.0,1.0]));
println!("1 and 0: {:?}", network.feed_forward(vec![1.0,0.0]));
println!("1 and 1: {:?}", network.feed_forward(vec![1.0,1.0]));
network.train(inputs, targets, 2000);
println!("0 and 0: {:?}", network.feed_forward(vec![0.0,0.0]));
println!("0 and 1: {:?}", network.feed_forward(vec![0.0,1.0]));
println!("1 and 0: {:?}", network.feed_forward(vec![1.0,0.0]));
println!("1 and 1: {:?}", network.feed_forward(vec![1.0,1.0]));
network.save("weights".to_string());
} }

@ -0,0 +1 @@
{"biases":[[[4.870327559407807],[11.09981638356452],[4.932220449034749]],[[0.6068613357408664]]],"weights":[[[-10.7985994744612,-8.58312276005114],[-6.217673474019029,-9.227257028840848],[8.292012545230659,-7.263893689697394]],[[-7.201486053815492,7.103973514898267,-4.297072672690916]]]}

@ -0,0 +1 @@
{"biases":[[[-5.172410992146818],[-3.033170251903816],[-5.13635551903822]],[[-4.8932802389322685]]],"weights":[[[10.601569078393347,-11.927061926900015],[7.5854982860260005,7.620486663515182],[-11.866987494709251,10.533269979541583]],[[8.131552743311454,1.0232057828085046,8.133322552007222]]]}
Loading…
Cancel
Save