You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
When I try Demo_3_Float_CKKS.py with a 2-dimensional numpy array, I get an error.
Code To Reproduce Error
arr_x [[1. 2. 3.]
[4. 5. 6.]
[7. 8. 9.]]
Traceback (most recent call last):
File "/home/elyas/Pyfhel/examples/Try_Float_CKKS.py", line 60, in <module>
ptxt_x = HE.encodeFrac(arr_x) # Creates a PyPtxt plaintext with the encoded arr_x
File "Pyfhel/Pyfhel.pyx", line 742, in Pyfhel.Pyfhel.Pyfhel.encodeFrac
ValueError: Buffer has wrong number of dimensions (expected 1, got 2)
Setup:
OS: Ubuntu
Python: 3.9.2
C compiler version: GCC 10.2.1 20210110
Pyfhel Version: most-recent
The text was updated successfully, but these errors were encountered:
Hi @elyasgoli, I just want to add that there is a nice example of how encrypting and performing simple arithmetic operations over 2-D matrices in this issue.
Hi Shokofeh,
Thank you! That's helpful! My goal is actually to encrypt images with CKKS
or BFV. For that purpose, I need to encrypt a Numpy 2D array as a whole,
not by breaking it down row by row. Is it possible to do that with PyFHEL?
Many thanks,
Elyas
You virtually always want to flatten images before encryption, as FHE ciphertexts are effectively vectors and FHE offers SIMD operations over vectors. For advanced use cases, more complex patterns might be beneficial, but expressing your FHE computation as a vectorized computation is a good start for most applications.
ibarrond
changed the title
[up to 10 words short bug description]: [one-line error message]
Encrypting and operating with 2D numpy arrays (images)
Sep 2, 2023
ibarrond
added
HowTo
How to accomplish something with Pyfhel. Candidate to a demo/example.
and removed
bug
labels
Sep 2, 2023
Description
When I try
Demo_3_Float_CKKS.py
with a 2-dimensionalnumpy
array, I get an error.Code To Reproduce Error
Setup:
The text was updated successfully, but these errors were encountered: