# Error using quantum nodes into Keras Layers using modulation dataset

**URL:** <https://discuss.pennylane.ai/t/error-using-quantum-nodes-into-keras-layers-using-modulation-dataset/3259>\
**Category:** PennyLane Help\
**Created:** [August 1, 2023, 12:59pm UTC](https://discuss.pennylane.ai/t/error-using-quantum-nodes-into-keras-layers-using-modulation-dataset/3259 "2023-08-01T12:59:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahamiftikhar](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@Mahamiftikhar](https://discuss.pennylane.ai/u/Mahamiftikhar)\
**Post date:** [August 1, 2023, 12:59pm UTC](https://discuss.pennylane.ai/t/error-using-quantum-nodes-into-keras-layers-using-modulation-dataset/3259/1 "2023-08-01T12:59:37Z")

</div>

Hi! I’, using tutorial example of turning quantum nodes into keras layers for modulation dataset but i got an error while running the code on jupyter notebook. same code is used as used in pennylane demo [Turning quantum nodes into Keras Layers](https://pennylane.ai/qml/demos/tutorial_qnn_module_tf) . error is not occuring when i use the classical keras layers excluding the qnlayer. also i ran the demo as it is and it gives the same error. i attached the error below  
Epoch 1/6  
WARNING:tensorflow:You are casting an input of type complex128 to an incompatible dtype float64. This will discard the imaginary part and may not be what you intended.  
WARNING:tensorflow:You are casting an input of type complex128 to an incompatible dtype float64. This will discard the imaginary part and may not be what you intended.  
WARNING:tensorflow:You are casting an input of type complex128 to an incompatible dtype float64. This will discard the imaginary part and may not be what you intended.  
suggest a solution to this. thanks

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [August 1, 2023, 2:39pm UTC](https://discuss.pennylane.ai/t/error-using-quantum-nodes-into-keras-layers-using-modulation-dataset/3259/2 "2023-08-01T14:39:30Z")

</div>

Hey @Mahamiftikhar! Welcome to the forum 🚀

I think this other forum post might be useful to check out:

> [@Error creating a keras model with a quantum Circuit as a layer](https://discuss.pennylane.ai/t/error-creating-a-keras-model-with-a-quantum-circuit-as-a-layer/2911/3):
>
> The following is a simpler code with the same warning. The solution you gave me it didn’t solve the warning problem, here I attach an screenshot. My code import pennylane as qml import tensorflow as tf import sklearn.datasets from qiskit\_machine\_learning import datasets import qiskit\_machine\_learning as qiskitml n\_qubits = 2 dev = qml.device("default.qubit", wires=n\_qubits) @qml.qnode(dev) def qnode(inputs, weights): qml.templates.AngleEmbedding(inputs, wires=range(n\_qubits)) qml.temp…

Let me know if this helps!

---

<div class="post-metadata">

**Author:** ![Mahamiftikhar](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@Mahamiftikhar](https://discuss.pennylane.ai/u/Mahamiftikhar)\
**Post date:** [August 1, 2023, 3:01pm UTC](https://discuss.pennylane.ai/t/error-using-quantum-nodes-into-keras-layers-using-modulation-dataset/3259/3 "2023-08-01T15:01:34Z")

</div>

Thanks for the suggestion @isaacdevlugt i already tried this but using this i got very low validation accuracy and high loss.

---

<div class="post-metadata">

**Author:** ![Guillermo\_Alonso](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/guillermo_alonso/32/816_2.png) [@Guillermo\_Alonso](https://discuss.pennylane.ai/u/Guillermo_Alonso)\
**Post date:** [August 4, 2023, 12:11pm UTC](https://discuss.pennylane.ai/t/error-using-quantum-nodes-into-keras-layers-using-modulation-dataset/3259/4 "2023-08-04T12:11:06Z")

</div>

Hello @Mahamiftikhar ! 😄 This could also be due to many factors: the model is not expressive enough, the dataset is not good enough to generalize, …  
In the end this is the challenge of the researcher, not easy at all!  
Or do you think this is related to problem with PennyLane?

---

<div class="post-metadata">

**Author:** ![Mahamiftikhar](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@Mahamiftikhar](https://discuss.pennylane.ai/u/Mahamiftikhar)\
**Post date:** [August 5, 2023, 9:58am UTC](https://discuss.pennylane.ai/t/error-using-quantum-nodes-into-keras-layers-using-modulation-dataset/3259/5 "2023-08-05T09:58:13Z")

</div>

@Guillermo_Alonso Yeah it’s possible that this is due to these factors.
