Git Product home page Git Product logo

pyrus-nn's Introduction

pyrus-nn

Build Status Dependabot Status crates.io

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:

Python:

pip install pyrus-nn  # Has ZERO dependencies!

Rust:

[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)]  

model.fit(X, 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);
    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());
}

pyrus-nn's People

Contributors

dependabot-preview[bot] avatar milesgranger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.