Giter Club home page Giter Club logo

garbled-neural-network-experiments's Introduction

garbled neural net experiments

This repo contains an implementation of convolutional neural networks using arithmetic garbled circuits, via fancy-garbling. It contains the models we ran our experiments on in our paper, Garbled Neural Networks Are Practical.

The high-level idea is that we use JSON output of tensorflow models to build neural network layers as a garbled circuit. The Garbler either hard codes the weights and biases as public values or as secret garbler input wires, depending on how the circuit is configured. Public weights is much, much cheaper to run. Finally, the Evaluator is started on another thread, and the Garbler passes the garbled circuit incrementally through a channel as it is created. The Evaluator evaluates it using the test input - in our examples this is always an image.

The neural_nets directory contains the trained neural networks we used in the paper. To run an experiment, you simply point the binary rust program to the directory you want and give it a command on what kind of test you would like to run.

Generally, the Garbler does not know how large to make the integers. Integers must be large enough to avoid overflow. But the smaller they are, the better the performance. Therefore, we have the bitwidth command to run on a particular neural network. This will evaluate the neural network on all the test data and return the maximum bitwith necessary for each layer. You can then use this information to customize the bitwith for each layer when using other commands (using the -w argument).

If you aren't familiar with rust, the getting started page is here.

Note on requirements: This project uses nightly rustc due to use of atomic operations. We recommend using rustup to configure nightly rust. Fancy Garbling also requires AESNI, so requires a processor that supports that instruction.

usage

cargo run --relase -- [FLAGS] [OPTIONS] <DIR> [SUBCOMMAND]

FLAGS:
    -b, --boolean    runs in boolean mode
    -h, --help       Prints help information
    -s, --secret     use secret weights
    -V, --version    Prints version information

OPTIONS:
    -w, --bitwidth <bitwidth>            comma separated bitwidths to use for each layer (last number is replicated)
                                         [default: 15]
    -a, --accuracy <default-accuracy>    default accuracy for activations and max (overridden by specific accuracy
                                         settings) [default: 100%]
        --max <max-accuracy>             accuracy of max
    -n <NUM>                             number of tests to run
        --relu <relu-accuracy>           accuracy of relu
        --sign <sign-accuracy>           accuracy of sign

ARGS:
    <DIR>    Sets the neural network directory to use

SUBCOMMANDS:
    bitwidth    Evaluate the neural net to find the maximum bitwidth needed for each layer
    direct      Evaluate the given neural net directly over i64 values
    dummy       Test the accuracy of the fancy encoding of the neural network
    bench       Benchmark garbling and evaluating the neural network
    help        Prints this message or the help of the given subcommand(s)

for example: to run a benchmark on a neural network:

cargo run --release -- neural_nets/DINN_30 bench

garbled-neural-network-experiments's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

spaceships namnc

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.