OpenMined / TenSEAL

A library for doing homomorphic encryption operations on tensors
Apache License 2.0
837 stars 158 forks source link

support for maxpool, avgpool layers #361

Open tolusophy opened 3 years ago

tolusophy commented 3 years ago

Question

self.conv1_weight = torch_nn.conv1.weight.data.view( torch_nn.conv1.out_channels, torch_nn.conv1.kernel_size[0], torch_nn.conv1.kernel_size[1] ).tolist() self.conv1_bias = torch_nn.conv1.bias.data.tolist()

Can we also use this idea for maxpool and avgpool layers i.e.

self.maxpool_weight = torch_nn.maxpool.weight.data.view( torch_nn.maxpool.kernel_size[0], torch_nn.maxpool.kernel_size[1] ).tolist() self.maxpool_bias = torch_nn.maxpool.bias.data.tolist()

Iridesscent233 commented 2 years ago

Has your problem been solved? I've been thinking about it lately.

tolusophy commented 2 years ago

Has your problem been solved? I've been thinking about it lately.

No. It hasn't. The CKKS vector doesn't support multiple layers of convolution, so if you are using ANN, it could work. I'm trying to see how the CKKS Tensor couldwork, but so far, nada!

Iridesscent233 commented 2 years ago

您的问题解决了吗?我最近一直在思考这个问题。

不。事实并非如此。 CKKS 矢量不支持多层卷积,因此,如果您使用的是 ANN,它可以工作。我试图看看CKKS Tensor是如何工作的,但到目前为止,nada!

Do you mean that ckks can't realize the average pooling layer?

MartinNoc commented 2 years ago

Convolution and AveragePool layers can be implemented using vector-matrix multiplication, where the vector is your (encrypted) CKKSVector matrix is a (rather big) sparse matrix simulating the convolution and averagepool, respectively. It's very costly in terms of computational complexity, but it enables arbitrary convolution and averagepool layers.