Computing Jacobian for multiple measurement outcomes

Hi @Pratibha_Hegde :slight_smile:
It seems to be a bug when you try to return the measurement tuple. I’ll notify the team but in the meantime, this code should give you the desired output:

import pennylane as qml
from pennylane import numpy as np


dev = qml.device("default.qubit", wires=2)

@qml.qnode(dev)
def circuit(x, y, z, measure_wire):
    qml.RX(x, wires=0)
    qml.RY(y, wires=1)
    qml.RZ(z, wires=0)
    return qml.expval(qml.PauliZ(measure_wire))

x = np.array(0.2, requires_grad=True)
y = np.array(0.9, requires_grad=True)
z = np.array(-1.4, requires_grad=True)

jac = [qml.jacobian(circuit)(x, y, z, measure_wire) for measure_wire in dev.wires]

print(jac)

thanks for sharing!

1 Like