tensorflow / quantum

Hybrid Quantum-Classical Machine Learning in TensorFlow
https://www.tensorflow.org/quantum
Apache License 2.0
1.77k stars 560 forks source link

How to use a QNN with encrypted data? #731

Open sauravtii opened 1 year ago

sauravtii commented 1 year ago

Hi,

How can I use the model mentioned in this tutorial for this use case?

lockwo commented 1 year ago

I'm not really sure what the question is, just copy the model setup over and create a classical to quantum data conversion function and you should be good to go

sauravtii commented 1 year ago

Actually my question is, is it possible to save the QML model in the above mentioned MNIST tutorial ?

lockwo commented 1 year ago

Yes, you can save and load weights the same as other TF models

sauravtii commented 1 year ago

Okay, and also can it be converted it to a pytorch one (since CryPten is in Pytorch) ?

lockwo commented 1 year ago

While you can use ONNX to convert between frameworks (I think), I don't think there is a standard that works with quantum. My advice would be to either convert that code to TensorFlow (looks like basic MLPs so shouldn't be hard) or convert the TFQ training to an equivalent PyTorch package (I'm sure there are QML packages in it)

sauravtii commented 1 year ago

Okay, by converting to Tensorflow do you mean converting CyPten code to tensorflow?

lockwo commented 1 year ago

Yes

sauravtii commented 1 year ago

Okay, thanks! And as you meantioned that the QNN model can be saved, can you tell how can I achieve that ? I mean, saving the model after completing the training in the same way as a normal TF model, right?

lockwo commented 1 year ago

Yes, save_weights and load_weights are what I use

sauravtii commented 1 year ago

Okay, thank you for your response!