sophchoe / Binary_Classification_Pennylane_Keras

Classical-Quantum hybrid model for credit card fraud detection
18 stars 14 forks source link

Error during loss calculations #3

Open karaposu opened 2 years ago

karaposu commented 2 years ago

I am using the exact replica (except linux/colab tf version 2.4.0) of your code. And I am getting dtype mismatch in the end of first epoch. I already checked with input dtypes and they all are float32 as they should be. Anyone managed to replicate this code on colab?

sophchoe commented 2 years ago

I am running it again without an issue. I wouldn't now how to replicate your problem.

karaposu commented 2 years ago

https://colab.research.google.com/drive/1Fj3bdoeVFGJoNHAu0bdeUUsfZVjN3Bgf?usp=sharing

This is a Colab notebook with mentioned error. I only tried to adapt it to Colab. There are no other fundamental changes.

sophchoe commented 2 years ago

I'm getting a device error message on Google Colab. I will ask the Xanadu support tomorrow.

Screen Shot 2022-01-23 at 3 16 09 PM

karaposu commented 2 years ago

There is already a solution for this. Basically you need to restart runtime after imports in order to load the devices. But even after this I couldnt find strawberryfields.fock among the device list. Solution for that was installing pennylane-sf

!pip install pennylane-sf==0.16.0

sophchoe commented 2 years ago

I'm getting a data type error. The quantum layer is outputting float64. I wonder if the classical layer is outputting double. I will figure out how to test the output data type of the classical layer with one sample.

Screen Shot 2022-01-24 at 8 47 10 AM
karaposu commented 2 years ago

I wonder why it works on your local and doesnt work on Colab. Please update here if you find a solution

sophchoe commented 2 years ago

Try the MNIST classifier. It's essentially the same circuit with a different measurement method for multi-classification. If you encounter the same problem, we will consult with Xanadu.

https://github.com/sophchoe/Hybrid-Quantum-Classical-MNIST-Classfication-Model/blob/main/MNIST_Pennylane_Keras.ipynb

JuFeng-grape commented 1 year ago

I have checked all the data for precision issues and they have all been entered as float32 types, how can I fix this error? image

JuFeng-grape commented 1 year ago

I wonder why it works on your local and doesnt work on Colab. Please update here if you find a solution

V6LUPR_6VC69DATM@{XD091 try these versions