quantum icon indicating copy to clipboard operation
quantum copied to clipboard

Arithmetic expression outside of simple scalar multiplication is currently not supported.

Open Gopal-Dahale opened this issue 2 years ago • 2 comments

I created a parameterized circuit using Cirq for Amplitude Encoding as described in Supervised Learning with Quantum Computers. The parameter is an arithmetic expression involving multiple operations like division and squaring. Below is the formula used. This value is used inside the $Ry$ gate.

$$\beta_{j}^{g}=2 \arcsin \left(\frac{\sqrt{\sum_{l=1}^{2 g-1}\left|A_{(2 j-1) 2^{g-1}+l}\right|^{2}}}{\sqrt{\sum_{l=1}^{2 g}\left|A_{(j-1) 2^{g}+l}\right|^{2}}}\right).$$

Using the circuit in the tfq.layers.ControlledPQC gives the following error.

ValueError: Arithmetic expression outside of simple scalar multiplication is currently not supported. 
See serializer.py for more information.

Any hack for this?

Gopal-Dahale avatar Jun 21 '22 11:06 Gopal-Dahale

Hard to say the best solution without seeing the exact code causing you trouble. But based on the error I would guess you are doing some disallowed symbol operations and that it could probably be done in a custom layer. I recommend https://github.com/tensorflow/quantum/issues/565 which had the same problem/error

lockwo avatar Jun 21 '22 17:06 lockwo

Any updates on this or should it be closed?

lockwo avatar Aug 14 '22 23:08 lockwo