Skip to content

Commit

Permalink
add doc strings for mera
Browse files Browse the repository at this point in the history
  • Loading branch information
SaashaJoshi committed Nov 17, 2023
1 parent 0863a02 commit 08e52f8
Showing 1 changed file with 56 additions and 10 deletions.
66 changes: 56 additions & 10 deletions quantum_image_processing/models/tensor_network_circuits/mera.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
import numpy as np
"""Multiscale Entanglement Renormalization Ansatz (MERA) Tensor Network"""
from typing import Callable
import numpy as np
from qiskit.circuit import QuantumCircuit, QuantumRegister, ParameterVector
from quantum_image_processing.gates.two_qubit_unitary import TwoQubitUnitary


# Can TTN be an ABC for MERA? Good thought!
class MERA:
"""
Implements QCNN structure by Cong et al. (2019), replicating
the architecture described by MERA - Multiscale Entanglement
Renormalization Ansatz, given by Vidal et al. (2008).
The decomposition of MERA architecture takes from the paper
by Grant et al. (2018).
NOTE: Remember QCNN and MERA have opposite directions!!
Implements a Multiscale Entanglement Renormalization Ansatz
(MERA) tensor network structure as given by [2].
References:
[1] E. Grant et al., “Hierarchical quantum classifiers,”
npj Quantum Information, vol. 4, no. 1, Dec. 2018,
doi: https://doi.org/10.1038/s41534-018-0116-9.
[2] G. Vidal, “Class of Quantum Many-Body States That
Can Be Efficiently Simulated,” Physical Review Letters,
vol. 101, no. 11, Sep. 2008,
doi: https://doi.org/10.1103/physrevlett.101.110501.
"""

def __init__(self, img_dim):
self.img_dim = img_dim

def mera_simple(self, complex_structure: bool = True) -> QuantumCircuit:
"""
Builds a MERA circuit with a simple unitary gate
parameterization.
Args:
complex_structure (bool): If True, builds the MERA
structure with complex unitary gates (e.g. RY, etc.)
Returns:
circuit (QuantumCircuit): Returns the MERA circuit
generated with the help of the input arguments.
"""
param_vector = ParameterVector(
"theta",
int(self.img_dim / 2 * (self.img_dim / 2 + 1)) + 3,
Expand All @@ -34,6 +50,18 @@ def mera_simple(self, complex_structure: bool = True) -> QuantumCircuit:

# Check number of params here.
def mera_general(self, complex_structure: bool = True) -> QuantumCircuit:
"""
Builds a MERA circuit with a general unitary gate
parameterization. Refer [1].
Args:
complex_structure (bool): If True, builds the MERA
structure with complex unitary gates (e.g. RY, etc.)
Returns:
circuit (QuantumCircuit): Returns the MERA circuit
generated with the help of the input arguments.
"""
if complex_structure:
param_vector = ParameterVector("theta", 20 * self.img_dim - 1)
param_vector_copy = param_vector
Expand All @@ -52,6 +80,24 @@ def mera_backbone(
param_vector_copy: ParameterVector,
complex_structure: bool = True,
) -> QuantumCircuit:
"""
Lays out the backbone structure of a MERA circuit onto
which the unitary gates are applied.
Args:
gate_structure (Callable): calls the function with
the required unitary gate parameterization structure.
param_vector_copy (ParameterVector): list of unitary
gate parameters to be used in the circuit.
complex_structure (bool): If True, builds the MERA
structure with complex unitary gates (e.g. RY, etc.)
Returns:
circuit (QuantumCircuit): Returns the MERA circuit
generated with the help of the input arguments.
"""
mera_qr = QuantumRegister(size=self.img_dim)
mera_circ = QuantumCircuit(mera_qr)

Expand Down

0 comments on commit 08e52f8

Please sign in to comment.