You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the parameters of a ParametrizedGate are returned as a tuple which is perfectly fine when you set them as simple floats
fromqiboimportgatesrz=gates.RZ(0, 0.)
u3=gates.U3(0, 1., 2., 3.)
print(rz.parameters)
# this is (0.,)print(u3.parameters)
# this is (1., 2., 3.)
However, in some cases, you might want them to be arrays of a particular backend (for instance this is needed for backpropagation through pytorch), and you can set the parameters manually:
if you try to recover them, though, you'll find them split and returned as a tuple again:
print(rz.parameters)
# this is (array([0]),) print(u3.parameters)
# this is (array([1.]), array([2.]), array([3.]))
which begs for further unneeded machinery to restore the native representation.
Furthermore, for the sake of not riskying to brake the trace that torch, tensorflow and jax do, it would be better to cut to the bone any operation that is performed on the parameters that is not really needed in the parameters property (as well as in the Circuit.get/set_parameters).
The text was updated successfully, but these errors were encountered:
Currently the parameters of a
ParametrizedGate
are returned as atuple
which is perfectly fine when you set them as simple floatsHowever, in some cases, you might want them to be arrays of a particular backend (for instance this is needed for backpropagation through
pytorch
), and you can set the parameters manually:if you try to recover them, though, you'll find them split and returned as a tuple again:
which begs for further unneeded machinery to restore the native representation.
Furthermore, for the sake of not riskying to brake the trace that
torch
,tensorflow
andjax
do, it would be better to cut to the bone any operation that is performed on the parameters that is not really needed in theparameters
property (as well as in theCircuit.get/set_parameters
).The text was updated successfully, but these errors were encountered: