Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuantumPoolingLayer (s): For odd number of qubits, cz gates are not applied to the last qubit when conditional is False #40

Open
SaashaJoshi opened this issue Dec 21, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@SaashaJoshi
Copy link
Owner

When the conditional argument is False, i.e. when dynamic circuits are not used, a cz gate should be applied to adjacent qubits to perform the pooling function. The adjacent qubits must be in pairs, (0, 1), (1, 2) or groups (0, 1, 2), (2, 3, 4), where the phase_bits are 1, 2 and 1, 3 respectively.

However, in the current implementation of the QuantumPoolingLayer(s) when the num_qubits is odd and conditional = False, a cz is not getting applied to the last qubit. This can also be seen in the unit test test_pooling_layer.py as below,

https://github.com/SaashaJoshi/quantum-image-processing/blob/828a9297f9fa1976f531b23c98ad05623c2a1390/tests/neural_networks/layers/test_pooling_layer.py#L132-L140

To pinpoint the origin of the error, the for loop here generates an incorrect group of qubits for the cz gate to be applied on.
https://github.com/SaashaJoshi/quantum-image-processing/blob/828a9297f9fa1976f531b23c98ad05623c2a1390/quantum_image_processing/neural_networks/layers/pooling_layer.py#L152-L156

While it is sure that this bug occurs in QuantumPoolingLayer3, it still needs to be verified if QuantumPoolingLayer2 shows similar behaviour.

This bug was discovered after #39 was closed.

@SaashaJoshi SaashaJoshi added the bug Something isn't working label Dec 21, 2023
@SaashaJoshi
Copy link
Owner Author

Also consider the open boundary conditions for QCNN, as proposed in the following paper.

T. Hur, L. Kim, and D. K. Park, “Quantum convolutional neural network for classical data classification,” Quantum Machine Intelligence, vol. 4, no. 1, Feb. 2022, doi: https://doi.org/10.1007/s42484-021-00061-x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant