Skip to content

Commit

Permalink
updated docstrings for QuantumCNN class
Browse files Browse the repository at this point in the history
  • Loading branch information
jf-kong committed Mar 18, 2024
1 parent a73997c commit 555c502
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/qibo/models/qcnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ def __init__(
twoqubitansatz=None,
copy_init_state=None,
):
"""
Initializes the QuantumCNN object.
Args:
nqubits (int): The number of qubits in the QCNN.
nlayers (int): The number of layers in the QCNN.
nclasses (int, optional): The number of classes for the classification task. Defaults to 2.
params (np.ndarray, optional): The initial parameters for the QCNN. If None, random parameters are generated. Defaults to None.
twoqubitansatz (qibo.core.circuit.Circuit, optional): A two-qubit ansatz for the convolutional layers. If None, a default ansatz is used. Defaults to None.
copy_init_state (bool, optional): Whether to copy the initial state for each shot in the simulation. If None, the behavior depends on the backend. Defaults to None.
Raises:
ValueError: If nqubits is not larger than 1.
"""

self.nclasses = nclasses
self.nqubits = nqubits
self.nlayers = nlayers
Expand Down Expand Up @@ -262,9 +277,6 @@ def Classifier_circuit(self, theta):
"""
Args:
theta: list or numpy.array with the biases and the angles to be used in the circuit.
nlayers: int number of layers of the varitional circuit ansatz.
RY: if True, parameterized Rx,Rz,Rx gates are used in the circuit.
if False, parameterized Ry gates are used in the circuit (default=False).
Returns:
Circuit implementing the variational ansatz for angles "theta".
"""
Expand Down Expand Up @@ -318,7 +330,6 @@ def Cost_function(self, theta, data=None, labels=None, nshots=10000):
"""
Args:
theta: list or numpy.array with the biases and the angles to be used in the circuit.
nlayers: int number of layers of the varitional circuit ansatz.
data: numpy.array data[page][word] (this is an array of kets).
labels: list or numpy.array with the labels of the quantum states to be classified.
nshots: int number of runs of the circuit during the sampling process (default=10000).
Expand Down

0 comments on commit 555c502

Please sign in to comment.