Closed a-matsuo closed 1 month ago
Hi @a-matsuo,
Thanks for your message. SamplerQNN does in fact return 2^circuit.num_qubits as per default when using it, as defined in it's description, which you can find here: https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.neural_networks.SamplerQNN.html
But the output is indeed a modifiable parameter which you change for your needs. Just remember to change the output_shape alongside the interpret function, in order to have SamplerQNN work with a number of classical registers that is smaller than then number qubits.
Environment
What is happening?
When the number of classical registers (measurements) is less than the total qubit size of the circuit, the shape of the return values is incorrect.
How can we reproduce the issue?
Run SamplerQNN where the circuit has fewer classical registers (measurements) than the total qubit size of the circuit.
What should happen?
The following line should be
output_shape_ = 2**self.circuit.num_clbits
https://github.com/qiskit-community/qiskit-machine-learning/blob/253b190eba869b4d002e490323ee4139612f01c9/qiskit_machine_learning/neural_networks/sampler_qnn.py#L280Any suggestions?
No response