Hi!
I tried to test the gpu training code sample under tensorflow-gpu 2.2.0+PennyLane 0.23.1, the specific URL is here:Pennylane DEMO v4, but I got some errors, can anyone give me some hints?
StagingError: in user code:
D:\ASC20\Anaconda3\envs\tnq-gpu\lib\site-packages\pennylane\qnode.py:576 __call__ *
res = qml.execute(
D:\ASC20\Anaconda3\envs\tnq-gpu\lib\site-packages\pennylane\interfaces\execution.py:337 execute *
qml.interfaces.cache_execute(
D:\ASC20\Anaconda3\envs\tnq-gpu\lib\site-packages\pennylane\interfaces\execution.py:85 cache_execute *
if expand_fn is not None:
D:\ASC20\Anaconda3\envs\tnq-gpu\lib\site-packages\tensorflow\python\autograph\operators\control_flow.py:926 if_stmt
return _py_if_stmt(cond, body, orelse)
D:\ASC20\Anaconda3\envs\tnq-gpu\lib\site-packages\tensorflow\python\autograph\operators\control_flow.py:1035 _py_if_stmtPreformatted text
return body() if cond else orelse()
C:\Users\24164\AppData\Local\Temp\tmplr3er8nz.py:19 if_true
(fn_1,) = (fn,)
UnboundLocalError: local variable 'fn' referenced before assignment
The problem occurs when running modelh.fit,But I tested that the error seems to be related to @tf.function.
@tf.function
@qml.qnode(dev, interface="tf", diff_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)) #STRONGLY ENTANGLING LAYERS
return [qml.expval(qml.PauliZ(i)) for i in range(n_qubits)]
What changePreformatted texts or environment are required to run the demo?