Crates.io | unda |
lib.rs | unda |
version | 0.2.2 |
source | src |
created_at | 2024-02-06 12:47:07.46545 |
updated_at | 2024-02-13 13:43:31.935845 |
description | General purpose machine learning crate for neural network development and analysis |
homepage | |
repository | https://github.com/BradenEverson/unda |
max_upload_size | |
id | 1128838 |
size | 350,057 |
Unda aims to bring the future of deep learning to the world of rust. With dynamic input traits, concurrent minibatch processing, and full Dense network support(with convolutions soon to come), Unda is quickly emerging and making neural network development easy and blazingly fast.
Use the package manager cargo to add unda to your rust project.
cargo add unda
or add the dependency directly in your cargo.toml file
[dependencies]
unda = "{version}"
use unda::core::network::Network;
use unda::core::layer::{methods::activations::Activations, layers::{LayerTypes, InputTypes}};
use unda::core::data::input::Input;
use unda::core::layer::{methods::errors::ErrorTypes};
fn main() {
let inputs = vec![vec![0.0,0.0],vec![1.0,0.0],vec![0.0,1.0], vec![1.0,1.0]];
let outputs = vec![vec![0.0],vec![1.0],vec![1.0], vec![0.0]];
let mut new_net = Network::new(4);
new_net.set_input(InputTypes::DENSE(2))
new_net.add_layer(LayerTypes::DENSE(3, Activations::RELU, 0.001));
new_net.add_layer(LayerTypes::DENSE(1, Activations::SIGMOID, 0.001));
new_net.compile();
new_net.fit(&inputs, &outputs, 2, ErrorTypes::MeanAbsolute);
println!("1 and 0: {:?}", new_net.predict(vec![1.0,0.0])[0]);
println!("0 and 1: {:?}", new_net.predict(vec![0.0,1.0])[0]);
println!("1 and 1: {:?}", new_net.predict(vec![1.0,1.0])[0]);
println!("0 and 0: {:?}", new_net.predict(vec![0.0,0.0])[0]);
new_net.save("best_network.json");
}
The unda repository hosts a plethora of example ML models to compute a series of common problems. These examples can be found in the /examples
folder and can be run by entering:
cargo run --release --example {example_name}
where example_name
is the name of the file/folder you wish to run, omitting the .rs
Important! When using running the MNIST example, please make sure to put the appropriate ubyte files into the /src/util/mnist directory of this repository. We are currently working on using reqwest to automatically build the dataset, but for now it must be done manually
Here are google drive links to the necessary ubyte files
Using the built in Input trait, practically any data type can be mapped to an input for a neural network without the need for cutting corners, and the inner trait for layers allows for a plug and play style to neural network development. Currently, Unda has full support for Dense layers, Adam Optimization for Backprop, Activation functions (Sigmoid, TanH, ReLU and LeakyReLU), and even loss analysis per model and per layer.
Gradient descent currently can happen both syncronously as stochastic gradient descent or asynchronously through minibatch gradient descent.
Currently, Unda is in a very beta stage, the following features are still in development:
[Neural Network Goals]
Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 or the MIT license http://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.