# Error creating a keras model with a quantum Circuit as a layer

**URL:** <https://discuss.pennylane.ai/t/error-creating-a-keras-model-with-a-quantum-circuit-as-a-layer/2911>\
**Category:** PennyLane Help\
**Created:** [May 2, 2023, 10:21am UTC](https://discuss.pennylane.ai/t/error-creating-a-keras-model-with-a-quantum-circuit-as-a-layer/2911 "2023-05-02T10:21:48Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Guillermo\_Valverde](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/guillermo_valverde/32/1524_2.png) [@Guillermo\_Valverde](https://discuss.pennylane.ai/u/Guillermo_Valverde)\
**Post date:** [May 2, 2023, 5:20pm UTC](https://discuss.pennylane.ai/t/error-creating-a-keras-model-with-a-quantum-circuit-as-a-layer/2911/3 "2023-05-02T17:20:50Z")

</div>

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**

```auto
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.templates.StronglyEntanglingLayers(weights, wires=range(n_qubits))
    return qml.expval(qml.PauliZ(0)), qml.expval(qml.PauliZ(1))

weight_shapes = {"weights": (3, n_qubits, 3)}

qlayer = qml.qnn.KerasLayer(qnode, weight_shapes, output_dim=2)
clayer1 = tf.keras.layers.Dense(2)
clayer2 = tf.keras.layers.Dense(2, activation="softmax")
model = tf.keras.models.Sequential([clayer1, qlayer, clayer2])

train_feats, train_labels, test_feats, test_labels =qiskitml.datasets.breast_cancer(80, 30, n=2, plot_data=False,one_hot=False)
X = tf.constant(train_feats)
Y = tf.one_hot(train_labels, depth=2)
X_test= tf.constant(test_feats)
Y_test= tf.one_hot(test_labels,depth=2)

opt = tf.keras.optimizers.SGD(learning_rate=0.5)
model.compile(opt, loss='mae', metrics=['accuracy'])

import warnings
warnings.filterwarnings('ignore') # To ignore warnings.
model.fit(X, Y, epochs=8, batch_size=5, verbose=1, validation_data=(X_test, Y_test))

```

**The warning**

 ![image](https://canada1.discourse-cdn.com/flex012/uploads/pennylane/original/2X/2/21eeb086c3da770b5a44b6f3b6b563281837368c.png)

---

_[View the full topic](https://discuss.pennylane.ai/t/error-creating-a-keras-model-with-a-quantum-circuit-as-a-layer/2911)._
