# Does the algorithm work?

**URL:** <https://discuss.pennylane.ai/t/does-the-algorithm-work/4237>\
**Category:** PennyLane Help\
**Created:** [March 6, 2024, 1:12pm UTC](https://discuss.pennylane.ai/t/does-the-algorithm-work/4237 "2024-03-06T13:12:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhong\_Feng](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/zhong_feng/32/2370_2.png) [@zhong\_Feng](https://discuss.pennylane.ai/u/zhong_Feng)\
**Post date:** [March 6, 2024, 1:12pm UTC](https://discuss.pennylane.ai/t/does-the-algorithm-work/4237/1 "2024-03-06T13:12:57Z")

</div>

Can I perform classification tasks using The Quantum Graph Recurrent Neural Network? If so, are there any more details, you know I’m a novice

---

<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:** [March 7, 2024, 8:11pm UTC](https://discuss.pennylane.ai/t/does-the-algorithm-work/4237/2 "2024-03-07T20:11:12Z")

</div>

Hey @zhong_Feng, welcome to the forum!

From our tutorial ([The Quantum Graph Recurrent Neural Network | PennyLane Demos](https://pennylane.ai/qml/demos/tutorial_qgrnn/)), this is the QGRNN:

```auto
def qgrnn(weights, bias, time=None):

    # Prepares the low energy state in the two registers
    qml.StatePrep(np.kron(low_energy_state, low_energy_state), wires=reg1 + reg2)

    # Evolves the first qubit register with the time-evolution circuit to
    # prepare a piece of quantum data
    state_evolve(ham_matrix, reg1, time)

    # Applies the QGRNN layers to the second qubit register
    depth = time / trotter_step # P = t/Delta
    for _ in range(0, int(depth)):
        qgrnn_layer(weights, bias, reg2, new_ising_graph, trotter_step)

    # Applies the SWAP test between the registers
    swap_test(control, reg1, reg2)

    # Returns the results of the SWAP test
    return qml.expval(qml.PauliZ(control))

```

If you look at it far enough away, looks like a run-of-the-mill variational quantum circuit! So you can definitely use it for all sorts of applications so long as the inputs, outputs, etc., are interpreted or processed in a way that makes sense for the learning task you’re interested in (classification, in your case).

---

<div class="post-metadata">

**Author:** ![zhong\_Feng](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/zhong_feng/32/2370_2.png) [@zhong\_Feng](https://discuss.pennylane.ai/u/zhong_Feng)\
**Post date:** [March 9, 2024, 7:36am UTC](https://discuss.pennylane.ai/t/does-the-algorithm-work/4237/3 "2024-03-09T07:36:49Z")

</div>

When using QGNN, if my topology graph structure has 39 nodes, do we have to have 39 quantum bits? Can it be run on a simulator? How much larger will the computational cost be?

---

<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:** [March 11, 2024, 10:37pm UTC](https://discuss.pennylane.ai/t/does-the-algorithm-work/4237/4 "2024-03-11T22:37:06Z")

</div>

I believe so, yes 🙂. 39 qubits is quite a bit! If you’re going to try to simulate that, I definitely recommend using some of our performance libraries, like PennyLane lightning ([Lightning plugins — Lightning 0.35.1 documentation](https://docs.pennylane.ai/projects/lightning/en/stable/index.html)) or Catalyst ([Catalyst — Catalyst 0.5.0 documentation](https://docs.pennylane.ai/projects/catalyst/en/stable/index.html)).
