Open SaashaJoshi opened 7 months ago
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.
When the
conditional
argument isFalse
, i.e. when dynamic circuits are not used, acz
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 thephase_bits
are 1, 2 and 1, 3 respectively.However, in the current implementation of the
QuantumPoolingLayer
(s) when thenum_qubits
is odd andconditional = False
, acz
is not getting applied to the last qubit. This can also be seen in the unit testtest_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-L156While it is sure that this bug occurs in
QuantumPoolingLayer3
, it still needs to be verified ifQuantumPoolingLayer2
shows similar behaviour.This bug was discovered after #39 was closed.