Skip to content

Latest commit

 

History

History
76 lines (55 loc) · 3.59 KB

pruned-resnet-step-by-step-guide.md

File metadata and controls

76 lines (55 loc) · 3.59 KB

Pruned Resnet step-by-step guide

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

Running oblivious Pruned Resnet by scratch

Parameters and input and output files generation

A Jupyter Notebook program that implements Pruned Resnet using PyTorch is provided. This notebook trains the neural network and executes the inference for 1 input.

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 Pruned Resnet implementation. Moreover, the input and output files are used to run the same execution in the pytorch implementation and in the oblivious Pruned Resnet 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 Pruned Resnet 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/PrunedResnet
    pip install -r requirements.txt
  3. The Pruned Resnet pytorch implementation contains 3 different files Jupyter Notebook files, Pruned_Resnet_CNN.ipynb, extraction_of_parameters.ipynb, input_output_layer_extraction.ipynb and their python corresponding ones that are responsible for doing the training, the extraction of parameters and the extraction of input and output of each layer for 1 inference execution.

    You can run the cells of the Jupyter notebook files one by one or use their python associated files directly.

    To train the system and generate the necessary files you can run the next commands:

    cd Pruned_Resnet_CNN
    ipython3 Pruned_Resnet_CNN.py
    cd inference
    ipython3 extraction_of_parameters.py
    ipython3 input_output_layer_extraction.py

Running oblivious Pruned Resnet 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 Pruned Resnet implementation consists of moving the generated files to the FANNG-MPC Data folder.

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

    cd ../../../..
    ./compile.sh -O1 Programs/test_obliv_nn_pruned_resnet
    ./Scripts/run-pruned-resnet.sh . Programs/test_obliv_nn_pruned_resnet/