I want to write a CV classifier. To get probabilities in the context of binary classification,
we would need two expectation values. For instance, get the Fock probability of [0, 1] and [1, 0] outcomes and normalize like:
QuantumFunctionError: Each wire in the quantum circuit can only be measured once.
TypeError: unsupported operand type(s) for +: 'NumberState' and 'NumberState'
While QNodes can contain quantum functions that are constructed similarly to Python functions, there are some important restrictions:
Quantum functions must only contain quantum operations, one operation per line, in the order in which they are to be applied,
Quantum functions must return either a single or a tuple of expectation values, with one expectation value per wire,
Quantum functions must not contain any classical processing.
In the example you have posted, this breaks the above restrictions in a few ways:
Across the two expectation values, wires 0 and wires 1 are measured twice. This is not allowed, as it does not map to physical hardware devices.
return p1 / (p0+p1 + 1e-10) is also invalid, as it involves classical processing within the QNode.
One solution is to use a combination of two QNodes, one for each expectation value you wish to measure, alongside a classical node for post-processing: