Reputation: 11
I have an encrypted CKKS tensor(enc_x) of size 1xN and Weight matrix(converted to plain tensor(W)) of size NxN. I want to perform the dot product of encrypted tensor enc_x and W. In tenseal, dot product function(.dot() and .dot_()) is available, but when i perform its not working. the code i wrote for the same is :
W1= ts.plain_tensor(W, [N,N]) where W is array of size N x N
p= enc_x.dot_(W1) # dot_() is used when dot product is performed between encrypted tensor and a plain tensor.
This function is not working.
In second case, this dot product function is working when i have an encrypted tensor of size (1x1) and plain tensor of size (1xN) Win1= ts.plain_tensor(Win, [1,N]) where Win is array of shape 1x500 and then converted into plain tensor. Then i performed q= enc_u.dot_(Win1.tolist()) and this dot product is working...
why dot product is not working in first case?
Tenseal library is used.
Win1= ts.plain_tensor(Win, [1,500]) W1= ts.plain_tensor(W, [500,500])
enc_u= ts.ckks_tensor(context, u) # u is an array of 1x1 size enc_x= ts.ckks_tensor(context, x) # x is array of 1x500 size
p= enc_x.dot_(W1.tolist()) #this dot product is not working, not working means there is no error but it gives no output and cell is running for longer time
print(p.shape)
q= enc_u.dot_(Win1.tolist()) # its working print(q.shape) this gives shape of q: [1,500]
Upvotes: 0
Views: 67