Git Product home page Git Product logo

torch2circom

torch2circom_banner

torch2circom is a python tool that transpiles a PyTorch model into a Circom circuit.

Installation

First, clone these two repositories in the same directory:

git clone https://github.com/torch2circom/circomlib-ml.git
git clone https://github.com/torch2circom/torch2circom.git

Then, install the dependencies. You can use pip:

cd torch2circom && pip install -r requirements.txt

If you use conda, you can also create a new environment with the following command:

conda env create -f environment.yml

You will also need to install circom and snarkjs. You can run the following commands to install them:

bash setup-circom.sh

Last but not least, run

npm install

Testing

To test the package, you can run the following command:

npm test

Usage

To use the package, you can run the following command:

python main.py <model_path> [-o <output_dir>] [--raw]

For example, to transpile the model in models/best_practice.h5 into a circom circuit, you can run:

python main.py models/best_practice.h5

The output will be in the output directory.

If you want to transpile the model into a circom circuit with "raw" output, i.e. no ArgMax at the end, you can run:

python main.py models/best_practice.h5 --raw

Acknowledgements

This project is based on keras2circom by @socathie.

torch2circom's Projects

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.