Skip to main content

Micro Neural Network framework implemented in Rust w/ Python bindings

Project description

# pyrus-nn

[![Build Status](](
[![Dependabot Status](](

[Rust API Documentation](

Lightweight neural network framework written in Rust, with _thin_ python bindings.

- Features:
- Serialize networks into/from YAML & JSON!
- Rust -> serde compatible
- Python -> `network.to_dict()` & `Sequential.from_dict()`
- Python install requires _zero_ dependencies
- No external system libs to install

- Draw backs:
- Only supports generic gradient descent.
- Fully connected (Dense) layers only so far
- Activation functions limited to linear, tanh, sigmoid and softmax
- Cost functions limited to MSE, MAE, Cross Entropy and Accuracy

### Install:

pip install pyrus-nn # Has ZERO dependencies!

pyrus-nn = "0.2.1"

### From Python
from pyrus_nn.models import Sequential
from pyrus_nn.layers import Dense

model = Sequential(lr=0.001, n_epochs=10)
model.add(Dense(n_input=12, n_output=24, activation='sigmoid'))
model.add(Dense(n_input=24, n_output=1, activation='sigmoid'))

# Create some X and y, each of which must be 2d
X = [list(range(12)) for _ in range(10)]
y = [[i] for i in range(10)], y)
out = model.predict(X)



### From Rust
use ndarray::Array2;
use pyrus_nn::{network::Sequential, layers::Dense};

// Network with 4 inputs and 1 output.
fn main() {
let mut network = Sequential::new(0.001, 100, 32, CostFunc::CrossEntropy);
network.add(Dense::new(4, 5)).is_ok()
network.add(Dense::new(5, 6)).is_ok()
network.add(Dense::new(6, 4)).is_ok()
network.add(Dense::new(4, 1)).is_ok()

let X: Array2<f32> = ...
let y: Array2<f32> = ..., y.view());

let yhat: Array2<f32> = network.predict(another_x.view());


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Built Distributions

pyrus_nn-0.2.1-cp37-cp37m-win_amd64.whl (488.5 kB view hashes)

Uploaded cp37

pyrus_nn-0.2.1-cp36-cp36m-win_amd64.whl (488.6 kB view hashes)

Uploaded cp36

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page