| Crates.io | zlearn |
| lib.rs | zlearn |
| version | 0.1.1 |
| created_at | 2025-05-21 16:51:20.643187+00 |
| updated_at | 2025-05-21 16:51:20.643187+00 |
| description | A simple neural network implementation library in Rust |
| homepage | |
| repository | https://github.com/GrishmUmesh/zlearn |
| max_upload_size | |
| id | 1683637 |
| size | 13,438 |
A simple neural network library in rust, designed for simplicity and higher control to the user.
Builtin activation functions
Builtin Matrices
Backpropogation
use zlearn::activation::SIGMOID;
use zlearn:network::Network;
fn main() {
// XOR input and target data
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],
];
// Create a network: 2 input neurons, 2 hidden neurons, 1 output neuron
let mut network = Network::new(vec![2, 2, 1], SIGMOID, 0.5);
// Train the network for 10,000 epochs
network.train(inputs.clone(), targets, 10000);
// Test the network
println!("\nTesting XOR after training:");
for i in 0..inputs.len() {
let output = network.feed_forward(inputs[i].clone());
println!(
"Input: [{:.1}, {:.1}] Output: {:.3} Expected: [{:.1}]",
inputs[i][0], inputs[i][1], output[0], targets[i][0]
);
}
}