Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/franalgaba/neural-network-cairo
Neural Network implementation from scratch for MNIST using Cairo 1.0
https://github.com/franalgaba/neural-network-cairo
cairo-lang machine-learning starknet
Last synced: about 2 months ago
JSON representation
Neural Network implementation from scratch for MNIST using Cairo 1.0
- Host: GitHub
- URL: https://github.com/franalgaba/neural-network-cairo
- Owner: franalgaba
- License: mit
- Created: 2023-03-04T15:56:56.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-01T15:55:53.000Z (over 1 year ago)
- Last Synced: 2024-07-30T20:34:35.353Z (4 months ago)
- Topics: cairo-lang, machine-learning, starknet
- Language: Rust
- Homepage:
- Size: 8.78 MB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-cairo - `neural-network-cairo`
- awesome-starknet - neural-network-cairo - Neural Network implementation from scratch for MNIST. (Additional developer resources)
- awesome-rust-list - franalgaba/neural-network-cairo - network-cairo?style=social"/> : Neural Network implementation from scratch for MNIST using Cairo 1.0. (Machine Learning)
- awesome-rust-list - franalgaba/neural-network-cairo - network-cairo?style=social"/> : Neural Network implementation from scratch for MNIST using Cairo 1.0. (Web3 and ZKP Framework)
README
# Neural Network for MNIST in Cairo 1.0
Implementation of a Neural Network from scratch using Cairo 1.0 for MNIST predictions.
The NN has a simple two-layer architecture:
- Input layer 𝑎[0] will have 784 units corresponding to the 784 pixels in each 28x28 input image.
- A hidden layer 𝑎[1] will have 10 units with ReLU activation.
- Output layer 𝑎[2] will have 10 units corresponding to the ten digit classes with softmax activation.Functionalities implemented in Cairo 1.0:
- [X] Vector implementation with operations: sum, max, min, argmax.
- [X] Matrix implementation with operations: get, dot, add, len.
- [X] Tensor implementation.
- [X] 8-bit weight quantization based in [ONNX quantization](https://onnxruntime.ai/docs/performance/quantization.html#quantization-overview).
- [X] ReLU activation.
- [X] Forward propagation of NN.
- [X] Predict method for NN.
- [X] [Pseudo-softmax activation](https://www.nature.com/articles/s41598-021-94691-7) optimized for quantized values.
- [X] Weight loading into Cairo NN from trained Tensorflow NN.
- [X] MNIST inferences using Cairo NN.[Built with **`auditless/cairo-template`**](https://github.com/auditless/cairo-template)
## Working with the project
Currently supports building and testing contracts.
### Build
Build the contracts.
```bash
$ make build
```### Test
Run the tests in `src/test`:
```bash
$ make test
```### Format
Format the Cairo source code (using Scarb):
```bash
$ make fmt
```### Credits
- [cairo-ml](https://github.com/raphaelDkhn/cairo_ml) by [Raphael Doukhan](https://twitter.com/raphael_dkhn).