Huelse / SEAL-Python

Microsoft SEAL 4.X For Python
MIT License
310 stars 66 forks source link

Results Issue on small values #73

Closed Arman001 closed 2 years ago

Arman001 commented 2 years ago

Type Working not properly on small values like 0.02 etc

Describe I have some experience with SEAL c++ and it works pretty fine in these type of situations. But on smaller values result in this library is not working properly ignoring the decimal point place. image

Can you kindly check it on your side. Thank you.

Huelse commented 2 years ago

I think this is caused by the python print floating-point rule, we can believe the result is accurate (precision loss is normal, it's determined by HE scheme). when you print the result by std::cout, it will auto rounding when the decimal places exceed 6 digits.

Arman001 commented 2 years ago

Kind of you to reply quickly. :) So, you mean that it is working fine and issue is in just printing? If I keep using computations it will work fine in the end?

Huelse commented 2 years ago

By so far, it's working well in my place, you can try this test examples/matrix_operations.py or refer to @DreamingRaven 's work. Basically, python is just a container, the real work is counting on c++.

Arman001 commented 2 years ago

Ok I will check more but you are right may be its print floating point working if python. Thank you again.

DreamingRaven commented 2 years ago

I will be overhauling my implementation soon, but yeah as @Huelse says feel free to take a look at how I use the bindings. In my version: https://github.com/DreamingRaven/python-fhez (linking to github mirror since this is a github issue)

I have two levels of abstraction reseal which is the lower level rebinding of the C++ to python like serialisation etc. Then a much higher level abstraction that takes reseal and makes it numpy compatible called rearray. Now that I have submitted my paper yesterday I will be looking to change everything to an erray (encrypted-array) abstraction which will clean up and merge the two prior abstractions into one single numpy-compatible way to bind many FHE implementations and make it easier for me to make a working setup.py to install everything directly rather than my docker containers. If you are intending to use RNS-CKKS for deep learning check out my library it might help, if not go right ahead and see if I have used Huelses bindings differently to you if it helps you.

Arman001 commented 2 years ago

@DreamingRaven I am actually working on encrypted deep learning. I have over viewed your work a bit. I will look into it in detail because this is related to my MS work. Thank you for your kind comment. :)