Dear, happy new year!

I have read the tutorial:

Computing gradients in parallel with Amazon Braket

Is it possible to customise it so someone can run a hybrid model?

In my case my qnode is defined as:

```
@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.StronglyEntanglingLayers(weights[i], wires=range(n_qubits))
return [qml.expval(qml.PauliZ(i)) for i in range(n_qubits)]
```

And i also have two classical keras layers and a hybrid model defined as:

`modelh = tf.keras.models.Sequential([clayer1,qlayer,clayer2])`

Thanks in advance!

Hey @NikSchet! It should be possible to do what you say and I recall I prototyped something along these lines. I’d be curious to see how it goes, please let us know and feel free to share some code snippets if you get stuck.

You may notice that training times are slow for QML-based applications. In this case, we have multiple circuits (e.g., a different circuit for each data point) and we must evaluate the gradient over each circuit to train the cost function. Currently we have added just parallelization of the gradient calculation for a given circuit.

So it seems to work, thanks for the help. Unfortunately my model is too big and i need to update my s3. In any case just by looking the logs i get decent results.

thanks!

1 Like