Skip to content
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

External Product #1774

Open
Sameeksha0709 opened this issue Nov 13, 2024 · 5 comments
Open

External Product #1774

Sameeksha0709 opened this issue Nov 13, 2024 · 5 comments
Labels
feature_request Something I need does not exist

Comments

@Sameeksha0709
Copy link

Hi can we use negative numbers in external product. How to do external product for negative numbers.

@Sameeksha0709 Sameeksha0709 added the feature_request Something I need does not exist label Nov 13, 2024
@IceTDrinker
Copy link
Member

Hello @Sameeksha0709

Can you share your code and use case ? If you are only doing external products then you can probably encode a negative value in the GGSW

@Sameeksha0709
Copy link
Author

Hi i am using this in Convolution operation in CNN, where weights and input both are in encrypted domain

@IceTDrinker
Copy link
Member

Hi i am using this in Convolution operation in CNN, where weights and input both are in encrypted domain

If you are only working on integer data then you likely need to see your data range as an unsigned integer and use the 2's complement representation https://en.wikipedia.org/wiki/Two%27s_complement

If your data is floating point then you likely need to use quantization and in that case I would recommend using https://github.com/zama-ai/concrete-ml/ as they already have a lot of tools for that

@Sameeksha0709
Copy link
Author

Hi i am using integer data only

@IceTDrinker
Copy link
Member

Then you should use 2’s complement

For example over 3 bits

[0, 4[ is still mapped to [0, 4[ but 4,5,6,7 are mapped to -4,-3,-2,-1 the good thing is the computations work the same between unsigned and signed numbers, you just have to interpret the output in a signed way.

Note however that is susceptible to overflows and you are essentially computing modulo the precision you choose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature_request Something I need does not exist
Projects
None yet
Development

No branches or pull requests

2 participants