Skip to content

Latest commit

 

History

History
70 lines (50 loc) · 3.02 KB

lenet-step-by-step-guide.md

File metadata and controls

70 lines (50 loc) · 3.02 KB

LeNet step-by-step guide

This is a step-by-step guide to know how to run test_obliv_nn_lenet program from scratch.

Running oblivious LeNet by scratch

Parameters and input and output files generation

A Jupyter Notebook program that implements LeNet using PyTorch is provided. This notebook trains the neural network and executes the inference for 50 runs with different inputs.

A set of files with the parameters, and the inputs and outputs of each layer is generated by this notebook for testing purposes. The parameters files are used to set up the parameters of the different layers in the oblivious LeNet implementation. Moreover, the input and output files are used to run the same executions in the pytorch implementation and in the oblivious LeNet implementation and to ensure we obtain the same results in both implementations.

  1. This project requires the use of Python 3, pip and Jupyter Notebook. All the processes have been tested using Python 3.8.15. Check the LeNet pytorch implementation Readme.md for further information. These prerequisites can be installed in an Ubuntu 20.04 machine by applying the following commands:

       sudo apt install python3
       sudo apt install pip
       sudo apt install jupyter
       sudo apt install ipython3

    To use any other OS, check the Python 3, pip and Jupyter Notebook documentation to know how to install them.

  2. After installing Python and pip on your OS you can install the necessary packages running the next commands:

        cd pytorch-implementations/Lenet
        pip install -r requirements.txt
  3. The LeNet_jupyter.ipynb file contains the pytorch implementation of the LeNet neural network. You can run the cells of the Jupyter notebook one by one to generate the parameters and input and output files or convert the jupyter notebook file to a python file typing this command:

        jupyter nbconvert --to script ./LeNet_jupiter.ipynb --output LeNet_python 
  4. After that, you can run the next command to train the neural network, run the inference and generate the parameters and input and output files.

        ipython3 LeNet_python.py

Running oblivious LeNet program using previously generated files

At this step, it is assumed that FANNG-MPC has been set up and configured correctly. If this is not your case, please review the FANNG-MPC installation guide.

  1. The first step to run the oblivious LeNet implementation consists of moving the generated files to the FANNG-MPC Data folder.

        cp -r LenetData ../../Data
  2. After that, we can proceed with the compilation and execution of the oblivious LeNet implementation.

        cd ../..
        ./compile.sh -O1 Programs/test_obliv_nn_lenet
        ./Scripts/run-lenet.sh . Programs/test_obliv_nn_lenet/