This is a step-by-step guide to know how to run test_obliv_nn_pruned_resnet
program from scratch.
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.
-
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.
-
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
-
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
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.
-
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
-
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/