snwagh / falcon-public

Implementation of protocols in Falcon

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting model parameters after training

imtiyazuddin opened this issue · comments

Is there an in-built method which can help me save the model parameters after training is completed?
If not, can you suggest some pointers. I have tried using the test() method in Secondary.cpp but I wasn't able to see any output written to any file (it should've written to file in "/files/preload/...").

sorry, my bad. It is writing some output, but I am unable to understand what it means, can you explain what is written in test() method? (when PRELOADING is set to true)

I see that there are getter methods for retrieving weights and biases for each layer, so that way I can fetch the model layer by layer. But can you explain how to reconstruct the model before I retrieve them ?

It was on my todo list to save a trained model but unfortunately saving the model parameters is not implemented.

PRELOADING = true lets you import the 4 pre-trained network files I have provided in the codebase. So these are models trained in plaintext and the command lets you load them into the codebase and then use them to do secure inference.

The reconstruction will work the as it does anywhere else, calling one of the reconstruct function calls. Take a look for instance at this line which will reconstruct a secret shared variable. It would be great to add functions to each layer to export its parameters (and also a method in the neural network class) and then call the export function after a few rounds of training.

Ok, thanks. How do I compare model trained on Falcon v/s model trained on plain ?? Only by last layer outputs ??? like net.layer[NUM_LAYERS-1]->getActivation() compared with plain inference output?? Does SMPC output also compute Softmax or I need to compute it?

Depends on how you want to compare the models. For accuracy, you can compare the predictions (index of the maximum value of the last layer output). To study the raw difference in values between plaintext computation and MPC, you can compare as you described above (the difference between net.layer[NUM_LAYERS-1]->getActivation() and plaintext output).