-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incomplete Implementation of getAccuracy() in NeuralNetwork.cpp #29
Comments
Indeed, the function is not implemented and thus the bizarre accuracy numbers. I would not have the time to implement this but here's a brief code logic for the simplest way to get this working (parts of which should already be implemented):
Let me know if you need clarification on any of these. If you manage to complete this, do a pull request and I can merge it to this repo. |
So I think there must be an issue with the training. 9/11 % indicates that the model is outputting random values so you need to do a bit of parameter tuning. What is the learning rate you're using? Fixed-point precision? And the weight initialization? |
I does not change any code in FCLayer.cpp and the hyperparameters provided in global.h (except I changed the NUM_ITERATIONS to 5). So the LOG_LEARNING_RATE is 5, FLOAT_PRECISION is 13, LEARNING_RATE is (1 << (FLOAT_PRECISION - LOG_LEARNING_RATE)), the weight and bias is initialized to all 0. |
The weight initialization makes a big difference. Biases set to 0 are fine. For weights, ideally you would like to use Kaiming He initialization but you can use a more "hacky" form of it using something similar to the code provided in FCLayer.cpp You have to set two things, one generate random "small" values (about 0.001). And second you need to ensure the RSS constraint is met, that each pair of parties shares one of these random values so the randomness generated should be common randomness (for ease, you can set the other two RSS shares to be zero but one of the non-zero RSS share components has to be generated randomly). |
I have changed the weight initialization to initialize weight randomly by following the idea of FCLayer.cpp. Now the weight of the first two FC layer is updating throughout the iterations. However, the third FC layer is still not updating (I get a weird observation that the deltaWeight variable of the third FC layer of SecureML always remain all 0). As a result, the training and testing accuracy is still very low and flutuating. I have also tried to include more training and testing data and also different value of LOG_LEARNING_RATE in global.h, but it does not help on improving the accuracy. |
I think I know what's causing this. The 32 bit space is too small for the entire training. Try setting |
Can you print all the weights and activations for the first forward and backward pass? The weights seem already to have overflown. With 20 bits of floating precision, any integer above 1000 would result in an overflow. LOG_LEARNING_RATE of 19 seems to be too high. |
I would recommend you don't print the entire sets. Print only the first 10 input, output values (and other values) for each layer. Right now the weights seem fine, deltaWeight doesn't look right but it is hard to say why -- (1) I don't know which layer the above variables are printed (assuming it is SecureML network, is the first, second, or third FCLayer) (2) The other inputs/outputs to this computation particularly, the delta calculation (3) Finally, are you using with or without normalization (if I remember correctly, you probably want the control flow to use this part of the code)? So print an output (only of the FC layers or since it is a small network you can print all the layers, including the ReLUs) in the following manner that contains the first 10 samples of:
Backward:
|
Hey, i am also working on this part. Could @AndesPooh258 init a PR or put the link to your github repo? Thanks a lot!! |
As I am currently dealing with multiple deadlines, for (1) and (2) I will do the testing as soon as I completed these deadlines. For (3) I am current setting WITH_NORMALIZATION as true.
I have made a fork for this repo here. |
Good chance the issue is caused because of non-normalized inputs. Can you try after converting the inputs between 0-1 as floats (by default MNIST has 0-255 range values)? |
Right, can you now print the weights/input/output of each FCLayer? So until some work is done on automating this/building more software, unfortunately we're stuck with this "looks reasonable" debugging. To help you break the process down further, you can do the following:
|
Hello,
I am an undergraduate student who are working on privacy-preserving machine learning for my graduation thesis. By testing the code downloaded from the repo, I found that the getAccuracy() in NeuralNetwork.cpp is not implemented, and it always showed an accuracy of 100%, which is quite weird. Can anyone kindly provide some solution on how I can fix it?
Thank you very much!
The text was updated successfully, but these errors were encountered: