I can’t save the model, using:
traced_cell = torch.jit.script(model)
# saving model to disc memory for post processing
traced_cell.save(path + f"/policy_{sample}.pt")
The error:
"Could not export Python function call 'quantum_circuit'. Remove calls to Python functions before export. Did you forget to add @script or @script_method annotation? If this is a nn.ModuleList, add it to __constants__:"
Could any one can help me?
Note: I use the default qubit mode:
dev = qml.device("default.qubit", wires=n_qubits);
@qml.qnode(dev)
def quantum_circuit(inputs, weights):
weights = weights.reshape(q_depth, n_qubits)
# Initialise latent vectors
for i in range(n_qubits):
qml.RY(inputs[i], wires=i)
# Repeated layer
for i in range(q_depth):
# Parameterised layer
for y in range(n_qubits):
qml.RY(weights[i][y], wires=y)
# Control Z gates
for y in range(n_qubits - 1):
qml.CZ(wires=[y, y + 1])
return qml.probs(wires=list(range(n_qubits)))