-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
qcnn class: add sequence method to build a qcnn model
- Loading branch information
1 parent
2d21202
commit 024ddff
Showing
7 changed files
with
186 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
""" Neural Network Structures""" | ||
|
||
from .quantum_neural_network import QuantumNeuralNetwork | ||
|
||
__all__ = [ | ||
"QuantumNeuralNetwork", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
"""Abstract Base Class for QNN Layers""" | ||
|
||
from __future__ import annotations | ||
from abc import ABC, abstractmethod | ||
from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister | ||
|
||
|
||
class Layer(ABC): | ||
def __init__(self, num_qubits: int, **kwargs): | ||
self.num_qubits = num_qubits | ||
|
||
@abstractmethod | ||
def build_layer(self): | ||
return NotImplementedError |
28 changes: 0 additions & 28 deletions
28
quantum_image_processing/models/neural_networks/neural_network.py
This file was deleted.
Oops, something went wrong.
Empty file.
32 changes: 32 additions & 0 deletions
32
quantum_image_processing/models/neural_networks/quantum_neural_network.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""Neural Network Abstract Base Class""" | ||
|
||
from __future__ import annotations | ||
from abc import ABC, abstractmethod | ||
from typing import Callable | ||
from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister | ||
|
||
|
||
class QuantumNeuralNetwork(ABC): | ||
""" | ||
Abstract base class for all quantum neural network structures. | ||
These structures consist of data encoding/embedding, | ||
model layers (consisting of layers such as convolutional, | ||
pooling, etc.), and a measurement stage. | ||
""" | ||
|
||
def __init__(self, num_qubits: int): | ||
""" | ||
Initializes a Quantum Neural Network circuit with the given | ||
number of qubits. | ||
""" | ||
self.num_qubits = num_qubits | ||
# self.qr = QuantumRegister(self.num_qubits) | ||
# self.cr = ClassicalRegister(self.num_qubits) | ||
# self.circuit = QuantumCircuit(self.qr, self.cr) | ||
|
||
@abstractmethod | ||
def sequence(self, operations: Callable): | ||
""" | ||
Composes circuits with given list of operations. | ||
""" | ||
return NotImplementedError |
Oops, something went wrong.