Micro Neural Network framework implemented in Rust w/ Python bindings
Project description
# pyrus-nn
[![Build Status](https://milesgranger.visualstudio.com/builds/_apis/build/status/pyrus-nn?branchName=master)](https://milesgranger.visualstudio.com/builds/_build/latest?definitionId=1&branchName=master)
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=milesgranger/black-jack)](https://dependabot.com)
[![crates.io](http://meritbadge.herokuapp.com/pyrus-nn)](https://crates.io/crates/pyrus-nn)
[Rust API Documentation](https://docs.rs/pyrus-nn)
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:
Python:
```
pip install pyrus-nn # Has ZERO dependencies!
```
Rust:
```toml
[dependencies]
pyrus-nn = "0.2.1"
```
### From Python
```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)]
model.fit(X, y)
out = model.predict(X)
```
---
### From Rust
```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);
assert!(
network.add(Dense::new(4, 5)).is_ok()
);
assert!(
network.add(Dense::new(5, 6)).is_ok()
);
assert!(
network.add(Dense::new(6, 4)).is_ok()
);
assert!(
network.add(Dense::new(4, 1)).is_ok()
);
let X: Array2<f32> = ...
let y: Array2<f32> = ...
network.fit(X.view(), y.view());
let yhat: Array2<f32> = network.predict(another_x.view());
}
```
[![Build Status](https://milesgranger.visualstudio.com/builds/_apis/build/status/pyrus-nn?branchName=master)](https://milesgranger.visualstudio.com/builds/_build/latest?definitionId=1&branchName=master)
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=milesgranger/black-jack)](https://dependabot.com)
[![crates.io](http://meritbadge.herokuapp.com/pyrus-nn)](https://crates.io/crates/pyrus-nn)
[Rust API Documentation](https://docs.rs/pyrus-nn)
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:
Python:
```
pip install pyrus-nn # Has ZERO dependencies!
```
Rust:
```toml
[dependencies]
pyrus-nn = "0.2.1"
```
### From Python
```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)]
model.fit(X, y)
out = model.predict(X)
```
---
### From Rust
```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);
assert!(
network.add(Dense::new(4, 5)).is_ok()
);
assert!(
network.add(Dense::new(5, 6)).is_ok()
);
assert!(
network.add(Dense::new(6, 4)).is_ok()
);
assert!(
network.add(Dense::new(4, 1)).is_ok()
);
let X: Array2<f32> = ...
let y: Array2<f32> = ...
network.fit(X.view(), y.view());
let yhat: Array2<f32> = network.predict(another_x.view());
}
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
File details
Details for the file pyrus_nn-0.2.1-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: pyrus_nn-0.2.1-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 488.5 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a81181e278190c05dd36fbf5d154f7b6c7b3b9382026273d889a9d299e00bd1d |
|
MD5 | f3661c1f763223d0792aaa9e26dd8f1c |
|
BLAKE2b-256 | fb7921157ab4821966f7ab6ed270988e8b6313fcc0676f87a2a12853667e12e3 |
File details
Details for the file pyrus_nn-0.2.1-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: pyrus_nn-0.2.1-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 3.9 MB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53320d65328e2ffa5695bdd974bb740c92d8ede8be87707c8420aaacf6c5caad |
|
MD5 | bb86e3f714617a6629b9af2a2bca599e |
|
BLAKE2b-256 | 12c71267f7d063c5b19d6015d1fe8748751a43abc558a3df15676ab4dca1a181 |
File details
Details for the file pyrus_nn-0.2.1-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: pyrus_nn-0.2.1-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 488.6 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e8333e8cc7a5c47b765c79551a97075c5d1af7fbdc3da0fde0ff1bd149e0932 |
|
MD5 | 2caa3918b90bbb2bf6b8615ab0f44852 |
|
BLAKE2b-256 | d0ba5b28feb149a5a0d22bd9b09942fda15e965566b9fd5b3323fea109152ddf |
File details
Details for the file pyrus_nn-0.2.1-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: pyrus_nn-0.2.1-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d87623c52ab0f9b57c8e0f3c2c554537a274f9fe27020d58ff79de6844878ffc |
|
MD5 | 7653d9c750f887f324b20338fbfed0bb |
|
BLAKE2b-256 | d803330440ea9556123011fa957d2db893ad15e5c19c5cdc95f185295391f5f3 |
File details
Details for the file pyrus_nn-0.2.1-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: pyrus_nn-0.2.1-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc345d8b4e21d18262641340a3fed7ea5f94c8667fd4663b82dfc5ab944df978 |
|
MD5 | a5b0bf08a2087044f23a12080fb99f66 |
|
BLAKE2b-256 | 982bfc6abe651ca8b8ecc24a798c78c7f5e4b0b4b473d4f96ccbbbb29c268f95 |
File details
Details for the file pyrus_nn-0.2.1-cp27-cp27mu-manylinux1_x86_64.whl
.
File metadata
- Download URL: pyrus_nn-0.2.1-cp27-cp27mu-manylinux1_x86_64.whl
- Upload date:
- Size: 989.5 kB
- Tags: CPython 2.7mu
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e9d2cdb95bfb82bb6b70325edeb158f53b143165755d811e324becbf046bea3 |
|
MD5 | 07db828f178833a1d95e42108a5d2f4f |
|
BLAKE2b-256 | 36a9eaeb486bbde169757ddd54ed0f7f3a07398478403d0c1bfe66c603fc44dc |
File details
Details for the file pyrus_nn-0.2.1-cp27-cp27m-manylinux1_x86_64.whl
.
File metadata
- Download URL: pyrus_nn-0.2.1-cp27-cp27m-manylinux1_x86_64.whl
- Upload date:
- Size: 989.5 kB
- Tags: CPython 2.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc93fb547ebd95d0f59e33e45e459db99d131d34daa5c0811542b00ee8de64c8 |
|
MD5 | c1a4395255b6cb43a04848cff93dab8b |
|
BLAKE2b-256 | 259d523d6aedb8cb21cc335babaa65b762423dd01bf93374b11e4464774b3095 |