# Qnode with data-reupload and basic entangler layers

**URL:** <https://discuss.pennylane.ai/t/qnode-with-data-reupload-and-basic-entangler-layers/1177>\
**Category:** PennyLane Help\
**Created:** [July 2, 2021, 10:30pm UTC](https://discuss.pennylane.ai/t/qnode-with-data-reupload-and-basic-entangler-layers/1177 "2021-07-02T22:30:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NikSchet](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/nikschet/32/786_2.png) [@NikSchet](https://discuss.pennylane.ai/u/NikSchet)\
**Post date:** [July 2, 2021, 10:30pm UTC](https://discuss.pennylane.ai/t/qnode-with-data-reupload-and-basic-entangler-layers/1177/1 "2021-07-02T22:30:43Z")

</div>

Hello , i have a Qnode with data-reupload technique in which i use strongly entangled layers but i would like to use basicentangler layers instead and for some reason i get some errors

```
> @qml.qnode(dev, interface="tf", grad_method="backprop")
> def qnode(inputs, weights):
> for i in range(blocks):
> qml.templates.AngleEmbedding(inputs, wires=range(n_qubits))
> # qml.templates.BasicEntanglerLayers(weights, wires=range(n_qubits)) #BASIC ENTANGLER LAYERS , chan
> qml.templates.StronglyEntanglingLayers(weights[i], wires=range(n_qubits)) #STRONGLY ENTANGLING LAYERS
> return [qml.expval(qml.PauliZ(i)) for i in range(n_qubits)]
> 
> 
> weights_shape = (blocks, layers, n_qubits, 3) 
> 
> 
>

weight_shapes = {"weights": weights_shape}

qlayer = qml.qnn.KerasLayer(qnode, weight_shapes, output_dim=n_qubits)

```

This is the working code with strongly entangling layers in which every “block” must be initialized with random weights (which hopefully works as i describe it). Can you let me know what changes to make so it works with basic entangler layers ? thanks.

---

<div class="post-metadata">

**Author:** ![theodor](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/theodor/32/178_2.png) [@theodor](https://discuss.pennylane.ai/u/theodor)\
**Post date:** [July 5, 2021, 10:33pm UTC](https://discuss.pennylane.ai/t/qnode-with-data-reupload-and-basic-entangler-layers/1177/2 "2021-07-05T22:33:03Z")

</div>

Hi @NikSchet,

It seems like the issue might be the shape of the weights that you’re using. Are you getting something similar to the following error?

```auto
ValueError: Weights tensor must be 2-dimensional; got shape (3, 2, 3)

```

If so, you’d need to change the weights-shape to be `(number_of_layers, n_qubits)` instead of the the one you’re currently using, which I believe would work for `StronglyEntanglingLayers`. Try running your code without the final dimension of 3 and let me know if it works.

The change is due to the difference between how many parameters the different entangling-layer templates are using. `StronglyEntanglingLayers` uses rotation gates with 3 parameters each, while `BasicEntanglerLayers` only has single parameter rotation gates.

You can read more about it in the docs [here, for StronglyEntanglingLayers](https://pennylane.readthedocs.io/en/stable/code/api/pennylane.templates.layers.StronglyEntanglingLayers.html), and [here, for BasicEntanglerLayers](https://pennylane.readthedocs.io/en/latest/code/api/pennylane.templates.layers.BasicEntanglerLayers.html).

---

<div class="post-metadata">

**Author:** ![NikSchet](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/nikschet/32/786_2.png) [@NikSchet](https://discuss.pennylane.ai/u/NikSchet)\
**Post date:** [July 14, 2021, 4:21pm UTC](https://discuss.pennylane.ai/t/qnode-with-data-reupload-and-basic-entangler-layers/1177/3 "2021-07-14T16:21:43Z")

</div>

That works thanks! (I removed the 3)
