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

scale mismatch #235

Closed
scutyuqiu opened this issue Apr 9, 2024 · 3 comments
Closed

scale mismatch #235

scutyuqiu opened this issue Apr 9, 2024 · 3 comments
Labels

Comments

@scutyuqiu
Copy link

File "Pyfhel/PyCtxt.pyx", line 360, in Pyfhel.PyCtxt.PyCtxt.add
File "Pyfhel/Pyfhel.pyx", line 1050, in Pyfhel.Pyfhel.Pyfhel.add_plain
File "Pyfhel/Pyfhel.pyx", line 1070, in Pyfhel.Pyfhel.Pyfhel.add_plain
ValueError: scale mismatch

How can I resolve this error?

I use homomorphic encryption in neural networks. At the full connection layer, the encrypted data has been weighted, but this error occurs when adding with bias.

code.docx

@scutyuqiu scutyuqiu added the bug label Apr 9, 2024
@ShokofehVS
Copy link

Hi @scutyuqiu, I reviewed issues on Pyfhel and demos, I found one that is helpful for you to read (exploring CKKS pitfalls).

I can recall that I faced similar issue and fixed that with rescaling (HE.rescale) as also pointed out in this issue on SEAL because when you are doing multiplication, you'll have ciphertext in different scale (compared to addition/subtraction) then addition wont work properly as you desired.

@scutyuqiu
Copy link
Author

I solved the problem, but I was curious. It doesn't work when I set qi to 21, but it works when I set it to 22.

@ShokofehVS
Copy link

Well-done!

qi_size is about the number of bits of each prime in the chain to ensure precision in encoding and decoding. However, I also dont have any connection now in mind between your scale mismatch and qi_size.

@ibarrond ibarrond closed this as completed Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants