Neural Network implementation from scratch using Cairo 1.0

Overview

CI Badge

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:

  • Vector implementation with operations: sum, max, min, argmax.
  • Matrix implementation with operations: get, dot, add, len.
  • Tensor implementation.
  • 8-bit weight quantization based in ONNX quantization.
  • ReLU activation.
  • Forward propagation of NN.
  • Predict method for NN.
  • Pseudo-softmax activation optimized for quantized values.
  • Weight loading into Cairo NN from trained Tensorflow NN.
  • MNIST inferences using Cairo NN.

Built with auditless/cairo-template

Working with the project

Currently supports building and testing contracts.

Build

Build the contracts.

$ make build

Test

Run the tests in src/test:

$ make test

Format

Format the Cairo source code (using Scarb):

$ make fmt

Credits

You might also like...
A turing-complete programming language using only zero-width unicode characters, inspired by brainfuck and whitespace.

Zero-Width A turing-complete programming language using only zero-width unicode characters, inspired by brainfuck and whitespace. Currently a (possibl

Quantogram - Approximate Quantile calculation using Histograms
Quantogram - Approximate Quantile calculation using Histograms

Quantogram - Approximate Quantile calculation using Histograms A library for Estimating Online Quantiles of Streams Quantogram accepts a stream of flo

Parse and encoding of data using the SCTE-35 standard.

SCTE-35 lib and parser for Rust Work in progress! This library provide access to parse and encoding of data using the SCTE-35 standard. This standard

Public aircraft & flightroute api Built in Rust for Docker, using PostgreSQL & Redis

api.adsbdb.com public aircraft & flightroute api Built in Rust for Docker, using PostgreSQL & Redis See typescript branch for original typescript vers

Key-value store for embedded systems, for raw NOR flash, using an LSM-Tree.

ekv Key-value store for embedded systems, for raw NOR flash, using an LSM-Tree. Features None yet TODO Everything Minimum supported Rust version (MSRV

Bitpack a boolean into a pointer using bit magic.

ptr-bool tl;dr: a pointer and boolean with the same size as a pointer. A convenience crate used to bitpack a boolean and pointer into the same eight b

The utility is designed to check the availability of peers and automatically update them in the Yggdrasil configuration file, as well as using the admin API - addPeer method.

Yggrasil network peers checker / updater The utility is designed to check the availability of peers and automatically update them in the Yggdrasil con

Using iced-rs library for YT monitoring app
Using iced-rs library for YT monitoring app

YouTube Monitoring App (using Rust) Description This app is built on the top of iced library. If you're curious what this is about, check out the YT m

Unify your game sources in one place and aquire more of them, using modules made by the community.

Project Black Pearl Unify your game sources in one place by using modules made by the community. What is Project Black Pearl? Project Black Pearl (or

Owner
Fran Algaba
MLOps Engineer. Blockchain enthusiast
Fran Algaba
Microservice written in Rust from scratch.

Simple-ms This Repo This repository contains code for a microservice written in Rust using the Tokio Axum framework. This code is used in MongoDB's wo

MongoDB Developer Relations 5 Nov 10, 2022
A comprehensive and FREE Online Rust hacking tutorial utilizing the x64, ARM64 and ARM32 architectures going step-by-step into the world of reverse engineering Rust from scratch.

FREE Reverse Engineering Self-Study Course HERE Hacking Rust A comprehensive and FREE Online Rust hacking tutorial utilizing the x64, ARM64 and ARM32

Kevin Thomas 98 Jun 21, 2023
Statistics network traffic --- Rust Library

Language : ???? English | ???? ็ฎ€ไฝ“ไธญๆ–‡ netraffic Overview netraffic is a rust library that provides ability to statistics network traffic. Prerequisites

ๅ‹คๅŠณ็š„ๅฐ่œœ่œ‚ 9 Mar 29, 2023
A Noir's backend implementation using gnark

Using gnark as a backend for Noir If you want to develop a backend for Noir, basically what you need to do is to translate an ACIR (Abstract Circuit I

Lambdaclass 13 Mar 4, 2023
Rust explained using easy English

Update 22 December 2020: mdBook can be found here. 28 November 2020: Now also available in simplified Chinese thanks to kumakichi! 1 February 2021: No

null 7.3k Jan 3, 2023
A fast uuid generator in Python using Rust

ruuid A fast UUID generator for Python built using Rust. Its a simple wrapper on top of Rust's UUID crate. How to use? Installation: pip3 install ruui

Rahul Nair 19 Jul 13, 2022
An API for getting questions from http://either.io implemented fully in Rust, using reqwest and some regex magic. Provides asynchronous and blocking clients respectively.

eithers_rust An API for getting questions from http://either.io implemented fully in Rust, using reqwest and some regex magic. Provides asynchronous a

null 2 Oct 24, 2021
(Ab)using technology for fun & profit.

(Ab)using technology for fun & profit. Code accompanying my blog

Sylvain Kerkour 357 Dec 30, 2022
A mixer for jack-audio using rust and druid UI

A simple mixer to allow me to use my midi controller (Novation LaunchControl XL) on linux and also to explore the new druid ui. Features volume faders

Richard Dodd (dodj) 25 Jul 6, 2022
Serialize & deserialize device tree binary using serde

serde_device_tree Use serde framework to deserialize Device Tree Blob binary files; no_std compatible. Use this library Run example: cargo run --examp

Luo Jia 20 Aug 20, 2022