1 unstable release
0.1.0 | Dec 17, 2022 |
---|
#503 in Machine learning
10KB
119 lines
wasm-nn: A Deep Learning Framework for WebAssembly
wasm-nn is a deep learning framework for WebAssembly (Wasm) that allows you to train and deploy neural networks in the browser or on the server. It has Python bindings that are compatible with PyTorch, so you can use your existing PyTorch code and models with wasm-nn.
Features
- Compiles and runs on Wasm for fast and efficient execution
- Python bindings for easy integration with PyTorch
- Supports a wide range of layer types and optimization algorithms
- Easy to use and well-documented API
Installation
To install wasm-nn, you need to have Rust and wasm-pack installed on your system. Then, you can install wasm-nn with the following command:
wasm-pack install wasm-nn
Usage
[dependencies]
wasm-nn = "0.1.0"
Then, you can use it in your Rust code like this:
extern crate wasm_nn;
use wasm_nn::tensor::Tensor;
use wasm_nn::optim::SGD;
use wasm_nn::nn::{Module, Linear};
fn main() {
let mut model = Linear::new(2, 3);
let optimizer = SGD::default();
// Train the model on some data...
}
To use wasm-nn with Python, you can install the Python package with pip:
pip install wasm-nn
Then, you can use it in your Python code like this:
import wasm_nn
model = wasm_nn.Linear(2, 3)
optimizer = wasm_nn.SGD()
# Train the model on some data...
For more details on how to use wasm-nn, see the API documentation.
Contributing
We welcome contributions to wasm-nn! If you'd like to contribute, please read our contribution guidelines and open a pull request.
License
wasm-nn is licensed under the MIT License.
Acknowledgements
wasm-nn is built on top of the WasmBindgen project, which makes it easy to interface between Rust and JavaScript. We are grateful to the WasmBindgen team and community for their efforts in making Wasm development a pleasure.
Dependencies
~1.1–2MB
~28K SLoC