hqm.circuits.amplitudeencoding
1from types import FunctionType 2import pennylane as qml 3import numpy as np 4import sys 5 6sys.path += ['.', './utils/'] 7 8from .circuit import QuantumCircuit 9 10class BasicEntangledCircuit(QuantumCircuit): 11 ''' 12 This class implements a torch/keras quantum layer using a basic entangler 13 circuit. 14 ''' 15 16 def __init__(self, n_qubits : int, n_layers : int, dev : qml.devices = None) -> None: 17 ''' 18 BasicEntangledCircuit constructor. 19 20 Parameters: 21 ----------- 22 - n_qubits : int 23 number of qubits for the quantum circuit 24 - n_layers : int 25 number of layers for the quantum circuit 26 - dev : qml.device 27 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 28 to 'default.qubit' 29 30 Returns: 31 -------- 32 Nothing, a BasicEntangledCircuit object will be created. 33 ''' 34 35 super().__init__(n_qubits=n_qubits, n_layers=n_layers, dev=dev) 36 37 self.weight_shape = {"weights": (n_layers, n_qubits)} 38 self.circuit = self.circ(self.dev, self.n_qubits) 39 40 41 @staticmethod 42 def circ(dev : qml.devices, n_qubits : int) -> FunctionType: 43 ''' 44 BasicEntangledCircuit static method that implements the quantum circuit. 45 46 Parameters: 47 ----------- 48 - dev : qml.device 49 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 50 to 'default.qubit' 51 - n_qubits : int 52 number of qubits for the quantum circuit 53 54 Returns: 55 -------- 56 - qnode : qml.qnode 57 the actual PennyLane circuit 58 ''' 59 60 @qml.qnode(dev) 61 def qnode(inputs : np.ndarray, weights : np.ndarray) -> list: 62 ''' 63 PennyLane based quantum circuit composed of an angle embedding layer and a basic entangler 64 layer. 65 66 Parameters: 67 ----------- 68 - inputs : np.ndarray 69 array containing input values (can came from previous torch/keras layers or quantum layers) 70 - weights : np.ndarray 71 array containing the weights of the circuit that are tuned during training, the shape of this 72 array depends on circuit's layers and qubits. 73 74 Returns: 75 -------- 76 - measurements : list 77 list of values measured from the quantum circuits 78 ''' 79 80 qml.AmplitudeEmbedding(features=inputs, wires=range(n_qubits), normalize=True) 81 qml.BasicEntanglerLayers(weights, wires=range(n_qubits)) 82 measurements = [qml.expval(qml.PauliZ(wires=i)) for i in range(n_qubits)] 83 return measurements 84 85 return qnode 86 87class StronglyEntangledCircuit(QuantumCircuit): 88 ''' 89 This class implements a torch/keras quantum layer using a strongly entangler 90 circuit. 91 ''' 92 93 def __init__(self, n_qubits : int, n_layers : int, dev : qml.devices = None) -> None: 94 ''' 95 StronglyEntangledCircuit constructor. 96 97 Parameters: 98 ----------- 99 - n_qubits : int 100 number of qubits for the quantum circuit 101 - n_layers : int 102 number of layers for the quantum circuit 103 - dev : qml.device 104 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 105 to 'default.qubit' 106 107 Returns: 108 -------- 109 Nothing, a StronglyEntangledCircuit object will be created. 110 ''' 111 112 super().__init__(n_qubits=n_qubits, n_layers=n_layers, dev=dev) 113 114 self.weight_shape = {"weights": (n_layers, n_qubits, 3)} 115 self.circuit = self.circ(self.dev, self.n_qubits) 116 117 @staticmethod 118 def circ(dev : qml.devices, n_qubits : int) -> FunctionType: 119 ''' 120 StronglyEntangledCircuit static method that implements the quantum circuit. 121 122 Parameters: 123 ----------- 124 - dev : qml.device 125 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 126 to 'default.qubit' 127 - n_qubits : int 128 number of qubits for the quantum circuit 129 130 Returns: 131 -------- 132 - qnode : qml.qnode 133 the actual PennyLane circuit 134 ''' 135 136 @qml.qnode(dev) 137 def qnode(inputs : np.ndarray, weights : np.ndarray) -> list: 138 ''' 139 PennyLane based quantum circuit composed of an angle embedding layer and a strongly entangler 140 layer. 141 142 Parameters: 143 ----------- 144 - inputs : np.ndarray 145 array containing input values (can came from previous torch/keras layers or quantum layers) 146 - weights : np.ndarray 147 array containing the weights of the circuit that are tuned during training, the shape of this 148 array depends on circuit's layers and qubits. 149 150 Returns: 151 -------- 152 - measurements : list 153 list of values measured from the quantum circuits 154 ''' 155 156 qml.AmplitudeEmbedding(features=inputs, wires=range(n_qubits), normalize=True) 157 qml.StronglyEntanglingLayers(weights, wires=range(n_qubits)) 158 measurements = [qml.expval(qml.PauliZ(wires=i)) for i in range(n_qubits)] 159 return measurements 160 161 return qnode 162 163class RandomCircuit(QuantumCircuit): 164 ''' 165 This class implements a torch/keras quantum layer using a random 166 circuit. 167 ''' 168 169 def __init__(self, n_qubits : int, n_layers : int, dev : qml.devices = None) -> None: 170 ''' 171 RandomCircuit constructor. 172 173 Parameters: 174 ----------- 175 - n_qubits : int 176 number of qubits for the quantum circuit 177 - n_layers : int 178 number of layers for the quantum circuit 179 - dev : qml.device 180 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 181 to 'default.qubit' 182 183 Returns: 184 -------- 185 Nothing, a RandomCircuit object will be created. 186 ''' 187 188 super().__init__(n_qubits=n_qubits, n_layers=n_layers, dev=dev) 189 190 self.weight_shape = {"weights": (n_layers, n_qubits)} 191 self.circuit = self.circ(self.dev, self.n_qubits) 192 193 @staticmethod 194 def circ(dev : qml.devices, n_qubits : int) -> FunctionType: 195 ''' 196 RandomCircuit static method that implements the quantum circuit. 197 198 Parameters: 199 ----------- 200 - dev : qml.device 201 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 202 to 'default.qubit' 203 - n_qubits : int 204 number of qubits for the quantum circuit 205 206 Returns: 207 -------- 208 - qnode : qml.qnode 209 the actual PennyLane circuit 210 ''' 211 212 @qml.qnode(dev) 213 def qnode(inputs : np.ndarray, weights : np.ndarray) -> list: 214 ''' 215 PennyLane based quantum circuit composed of an angle embedding layer and a basic entangler 216 layer. 217 218 Parameters: 219 ----------- 220 - inputs : np.ndarray 221 array containing input values (can came from previous torch/keras layers or quantum layers) 222 - weights : np.ndarray 223 array containing the weights of the circuit that are tuned during training, the shape of this 224 array depends on circuit's layers and qubits. 225 226 Returns: 227 -------- 228 - measurements : list 229 list of values measured from the quantum circuits 230 ''' 231 232 qml.AmplitudeEmbedding(features=inputs, wires=range(n_qubits), normalize=True) 233 qml.RandomLayers(weights, wires=range(n_qubits)) 234 measurements = [qml.expval(qml.PauliZ(wires=i)) for i in range(n_qubits)] 235 return measurements 236 237 return qnode
class
BasicEntangledCircuit(typing.Generic[~quantumcircuit]):
11class BasicEntangledCircuit(QuantumCircuit): 12 ''' 13 This class implements a torch/keras quantum layer using a basic entangler 14 circuit. 15 ''' 16 17 def __init__(self, n_qubits : int, n_layers : int, dev : qml.devices = None) -> None: 18 ''' 19 BasicEntangledCircuit constructor. 20 21 Parameters: 22 ----------- 23 - n_qubits : int 24 number of qubits for the quantum circuit 25 - n_layers : int 26 number of layers for the quantum circuit 27 - dev : qml.device 28 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 29 to 'default.qubit' 30 31 Returns: 32 -------- 33 Nothing, a BasicEntangledCircuit object will be created. 34 ''' 35 36 super().__init__(n_qubits=n_qubits, n_layers=n_layers, dev=dev) 37 38 self.weight_shape = {"weights": (n_layers, n_qubits)} 39 self.circuit = self.circ(self.dev, self.n_qubits) 40 41 42 @staticmethod 43 def circ(dev : qml.devices, n_qubits : int) -> FunctionType: 44 ''' 45 BasicEntangledCircuit static method that implements the quantum circuit. 46 47 Parameters: 48 ----------- 49 - dev : qml.device 50 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 51 to 'default.qubit' 52 - n_qubits : int 53 number of qubits for the quantum circuit 54 55 Returns: 56 -------- 57 - qnode : qml.qnode 58 the actual PennyLane circuit 59 ''' 60 61 @qml.qnode(dev) 62 def qnode(inputs : np.ndarray, weights : np.ndarray) -> list: 63 ''' 64 PennyLane based quantum circuit composed of an angle embedding layer and a basic entangler 65 layer. 66 67 Parameters: 68 ----------- 69 - inputs : np.ndarray 70 array containing input values (can came from previous torch/keras layers or quantum layers) 71 - weights : np.ndarray 72 array containing the weights of the circuit that are tuned during training, the shape of this 73 array depends on circuit's layers and qubits. 74 75 Returns: 76 -------- 77 - measurements : list 78 list of values measured from the quantum circuits 79 ''' 80 81 qml.AmplitudeEmbedding(features=inputs, wires=range(n_qubits), normalize=True) 82 qml.BasicEntanglerLayers(weights, wires=range(n_qubits)) 83 measurements = [qml.expval(qml.PauliZ(wires=i)) for i in range(n_qubits)] 84 return measurements 85 86 return qnode
This class implements a torch/keras quantum layer using a basic entangler circuit.
BasicEntangledCircuit( n_qubits: int, n_layers: int, dev: <module 'pennylane.devices' from '/Users/asebastianelli/miniforge3/envs/hqm/lib/python3.10/site-packages/pennylane/devices/__init__.py'> = None)
17 def __init__(self, n_qubits : int, n_layers : int, dev : qml.devices = None) -> None: 18 ''' 19 BasicEntangledCircuit constructor. 20 21 Parameters: 22 ----------- 23 - n_qubits : int 24 number of qubits for the quantum circuit 25 - n_layers : int 26 number of layers for the quantum circuit 27 - dev : qml.device 28 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 29 to 'default.qubit' 30 31 Returns: 32 -------- 33 Nothing, a BasicEntangledCircuit object will be created. 34 ''' 35 36 super().__init__(n_qubits=n_qubits, n_layers=n_layers, dev=dev) 37 38 self.weight_shape = {"weights": (n_layers, n_qubits)} 39 self.circuit = self.circ(self.dev, self.n_qubits)
BasicEntangledCircuit constructor.
Parameters:
- n_qubits : int
number of qubits for the quantum circuit - n_layers : int
number of layers for the quantum circuit - dev : qml.device
PennyLane device on wich run quantum operations (dafault : None). When None it will be set to 'default.qubit'
Returns:
Nothing, a BasicEntangledCircuit object will be created.
@staticmethod
def
circ( dev: <module 'pennylane.devices' from '/Users/asebastianelli/miniforge3/envs/hqm/lib/python3.10/site-packages/pennylane/devices/__init__.py'>, n_qubits: int) -> function:
42 @staticmethod 43 def circ(dev : qml.devices, n_qubits : int) -> FunctionType: 44 ''' 45 BasicEntangledCircuit static method that implements the quantum circuit. 46 47 Parameters: 48 ----------- 49 - dev : qml.device 50 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 51 to 'default.qubit' 52 - n_qubits : int 53 number of qubits for the quantum circuit 54 55 Returns: 56 -------- 57 - qnode : qml.qnode 58 the actual PennyLane circuit 59 ''' 60 61 @qml.qnode(dev) 62 def qnode(inputs : np.ndarray, weights : np.ndarray) -> list: 63 ''' 64 PennyLane based quantum circuit composed of an angle embedding layer and a basic entangler 65 layer. 66 67 Parameters: 68 ----------- 69 - inputs : np.ndarray 70 array containing input values (can came from previous torch/keras layers or quantum layers) 71 - weights : np.ndarray 72 array containing the weights of the circuit that are tuned during training, the shape of this 73 array depends on circuit's layers and qubits. 74 75 Returns: 76 -------- 77 - measurements : list 78 list of values measured from the quantum circuits 79 ''' 80 81 qml.AmplitudeEmbedding(features=inputs, wires=range(n_qubits), normalize=True) 82 qml.BasicEntanglerLayers(weights, wires=range(n_qubits)) 83 measurements = [qml.expval(qml.PauliZ(wires=i)) for i in range(n_qubits)] 84 return measurements 85 86 return qnode
BasicEntangledCircuit static method that implements the quantum circuit.
Parameters:
- dev : qml.device
PennyLane device on wich run quantum operations (dafault : None). When None it will be set
to 'default.qubit' - n_qubits : int
number of qubits for the quantum circuit
Returns:
- qnode : qml.qnode
the actual PennyLane circuit
class
StronglyEntangledCircuit(typing.Generic[~quantumcircuit]):
88class StronglyEntangledCircuit(QuantumCircuit): 89 ''' 90 This class implements a torch/keras quantum layer using a strongly entangler 91 circuit. 92 ''' 93 94 def __init__(self, n_qubits : int, n_layers : int, dev : qml.devices = None) -> None: 95 ''' 96 StronglyEntangledCircuit constructor. 97 98 Parameters: 99 ----------- 100 - n_qubits : int 101 number of qubits for the quantum circuit 102 - n_layers : int 103 number of layers for the quantum circuit 104 - dev : qml.device 105 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 106 to 'default.qubit' 107 108 Returns: 109 -------- 110 Nothing, a StronglyEntangledCircuit object will be created. 111 ''' 112 113 super().__init__(n_qubits=n_qubits, n_layers=n_layers, dev=dev) 114 115 self.weight_shape = {"weights": (n_layers, n_qubits, 3)} 116 self.circuit = self.circ(self.dev, self.n_qubits) 117 118 @staticmethod 119 def circ(dev : qml.devices, n_qubits : int) -> FunctionType: 120 ''' 121 StronglyEntangledCircuit static method that implements the quantum circuit. 122 123 Parameters: 124 ----------- 125 - dev : qml.device 126 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 127 to 'default.qubit' 128 - n_qubits : int 129 number of qubits for the quantum circuit 130 131 Returns: 132 -------- 133 - qnode : qml.qnode 134 the actual PennyLane circuit 135 ''' 136 137 @qml.qnode(dev) 138 def qnode(inputs : np.ndarray, weights : np.ndarray) -> list: 139 ''' 140 PennyLane based quantum circuit composed of an angle embedding layer and a strongly entangler 141 layer. 142 143 Parameters: 144 ----------- 145 - inputs : np.ndarray 146 array containing input values (can came from previous torch/keras layers or quantum layers) 147 - weights : np.ndarray 148 array containing the weights of the circuit that are tuned during training, the shape of this 149 array depends on circuit's layers and qubits. 150 151 Returns: 152 -------- 153 - measurements : list 154 list of values measured from the quantum circuits 155 ''' 156 157 qml.AmplitudeEmbedding(features=inputs, wires=range(n_qubits), normalize=True) 158 qml.StronglyEntanglingLayers(weights, wires=range(n_qubits)) 159 measurements = [qml.expval(qml.PauliZ(wires=i)) for i in range(n_qubits)] 160 return measurements 161 162 return qnode
This class implements a torch/keras quantum layer using a strongly entangler circuit.
StronglyEntangledCircuit( n_qubits: int, n_layers: int, dev: <module 'pennylane.devices' from '/Users/asebastianelli/miniforge3/envs/hqm/lib/python3.10/site-packages/pennylane/devices/__init__.py'> = None)
94 def __init__(self, n_qubits : int, n_layers : int, dev : qml.devices = None) -> None: 95 ''' 96 StronglyEntangledCircuit constructor. 97 98 Parameters: 99 ----------- 100 - n_qubits : int 101 number of qubits for the quantum circuit 102 - n_layers : int 103 number of layers for the quantum circuit 104 - dev : qml.device 105 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 106 to 'default.qubit' 107 108 Returns: 109 -------- 110 Nothing, a StronglyEntangledCircuit object will be created. 111 ''' 112 113 super().__init__(n_qubits=n_qubits, n_layers=n_layers, dev=dev) 114 115 self.weight_shape = {"weights": (n_layers, n_qubits, 3)} 116 self.circuit = self.circ(self.dev, self.n_qubits)
StronglyEntangledCircuit constructor.
Parameters:
- n_qubits : int
number of qubits for the quantum circuit - n_layers : int
number of layers for the quantum circuit - dev : qml.device
PennyLane device on wich run quantum operations (dafault : None). When None it will be set to 'default.qubit'
Returns:
Nothing, a StronglyEntangledCircuit object will be created.
@staticmethod
def
circ( dev: <module 'pennylane.devices' from '/Users/asebastianelli/miniforge3/envs/hqm/lib/python3.10/site-packages/pennylane/devices/__init__.py'>, n_qubits: int) -> function:
118 @staticmethod 119 def circ(dev : qml.devices, n_qubits : int) -> FunctionType: 120 ''' 121 StronglyEntangledCircuit static method that implements the quantum circuit. 122 123 Parameters: 124 ----------- 125 - dev : qml.device 126 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 127 to 'default.qubit' 128 - n_qubits : int 129 number of qubits for the quantum circuit 130 131 Returns: 132 -------- 133 - qnode : qml.qnode 134 the actual PennyLane circuit 135 ''' 136 137 @qml.qnode(dev) 138 def qnode(inputs : np.ndarray, weights : np.ndarray) -> list: 139 ''' 140 PennyLane based quantum circuit composed of an angle embedding layer and a strongly entangler 141 layer. 142 143 Parameters: 144 ----------- 145 - inputs : np.ndarray 146 array containing input values (can came from previous torch/keras layers or quantum layers) 147 - weights : np.ndarray 148 array containing the weights of the circuit that are tuned during training, the shape of this 149 array depends on circuit's layers and qubits. 150 151 Returns: 152 -------- 153 - measurements : list 154 list of values measured from the quantum circuits 155 ''' 156 157 qml.AmplitudeEmbedding(features=inputs, wires=range(n_qubits), normalize=True) 158 qml.StronglyEntanglingLayers(weights, wires=range(n_qubits)) 159 measurements = [qml.expval(qml.PauliZ(wires=i)) for i in range(n_qubits)] 160 return measurements 161 162 return qnode
StronglyEntangledCircuit static method that implements the quantum circuit.
Parameters:
- dev : qml.device
PennyLane device on wich run quantum operations (dafault : None). When None it will be set to 'default.qubit' - n_qubits : int
number of qubits for the quantum circuit
Returns:
- qnode : qml.qnode
the actual PennyLane circuit
class
RandomCircuit(typing.Generic[~quantumcircuit]):
164class RandomCircuit(QuantumCircuit): 165 ''' 166 This class implements a torch/keras quantum layer using a random 167 circuit. 168 ''' 169 170 def __init__(self, n_qubits : int, n_layers : int, dev : qml.devices = None) -> None: 171 ''' 172 RandomCircuit constructor. 173 174 Parameters: 175 ----------- 176 - n_qubits : int 177 number of qubits for the quantum circuit 178 - n_layers : int 179 number of layers for the quantum circuit 180 - dev : qml.device 181 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 182 to 'default.qubit' 183 184 Returns: 185 -------- 186 Nothing, a RandomCircuit object will be created. 187 ''' 188 189 super().__init__(n_qubits=n_qubits, n_layers=n_layers, dev=dev) 190 191 self.weight_shape = {"weights": (n_layers, n_qubits)} 192 self.circuit = self.circ(self.dev, self.n_qubits) 193 194 @staticmethod 195 def circ(dev : qml.devices, n_qubits : int) -> FunctionType: 196 ''' 197 RandomCircuit static method that implements the quantum circuit. 198 199 Parameters: 200 ----------- 201 - dev : qml.device 202 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 203 to 'default.qubit' 204 - n_qubits : int 205 number of qubits for the quantum circuit 206 207 Returns: 208 -------- 209 - qnode : qml.qnode 210 the actual PennyLane circuit 211 ''' 212 213 @qml.qnode(dev) 214 def qnode(inputs : np.ndarray, weights : np.ndarray) -> list: 215 ''' 216 PennyLane based quantum circuit composed of an angle embedding layer and a basic entangler 217 layer. 218 219 Parameters: 220 ----------- 221 - inputs : np.ndarray 222 array containing input values (can came from previous torch/keras layers or quantum layers) 223 - weights : np.ndarray 224 array containing the weights of the circuit that are tuned during training, the shape of this 225 array depends on circuit's layers and qubits. 226 227 Returns: 228 -------- 229 - measurements : list 230 list of values measured from the quantum circuits 231 ''' 232 233 qml.AmplitudeEmbedding(features=inputs, wires=range(n_qubits), normalize=True) 234 qml.RandomLayers(weights, wires=range(n_qubits)) 235 measurements = [qml.expval(qml.PauliZ(wires=i)) for i in range(n_qubits)] 236 return measurements 237 238 return qnode
This class implements a torch/keras quantum layer using a random circuit.
RandomCircuit( n_qubits: int, n_layers: int, dev: <module 'pennylane.devices' from '/Users/asebastianelli/miniforge3/envs/hqm/lib/python3.10/site-packages/pennylane/devices/__init__.py'> = None)
170 def __init__(self, n_qubits : int, n_layers : int, dev : qml.devices = None) -> None: 171 ''' 172 RandomCircuit constructor. 173 174 Parameters: 175 ----------- 176 - n_qubits : int 177 number of qubits for the quantum circuit 178 - n_layers : int 179 number of layers for the quantum circuit 180 - dev : qml.device 181 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 182 to 'default.qubit' 183 184 Returns: 185 -------- 186 Nothing, a RandomCircuit object will be created. 187 ''' 188 189 super().__init__(n_qubits=n_qubits, n_layers=n_layers, dev=dev) 190 191 self.weight_shape = {"weights": (n_layers, n_qubits)} 192 self.circuit = self.circ(self.dev, self.n_qubits)
RandomCircuit constructor.
Parameters:
- n_qubits : int
number of qubits for the quantum circuit - n_layers : int
number of layers for the quantum circuit - dev : qml.device
PennyLane device on wich run quantum operations (dafault : None). When None it will be set to 'default.qubit'
Returns:
Nothing, a RandomCircuit object will be created.
@staticmethod
def
circ( dev: <module 'pennylane.devices' from '/Users/asebastianelli/miniforge3/envs/hqm/lib/python3.10/site-packages/pennylane/devices/__init__.py'>, n_qubits: int) -> function:
194 @staticmethod 195 def circ(dev : qml.devices, n_qubits : int) -> FunctionType: 196 ''' 197 RandomCircuit static method that implements the quantum circuit. 198 199 Parameters: 200 ----------- 201 - dev : qml.device 202 PennyLane device on wich run quantum operations (dafault : None). When None it will be set 203 to 'default.qubit' 204 - n_qubits : int 205 number of qubits for the quantum circuit 206 207 Returns: 208 -------- 209 - qnode : qml.qnode 210 the actual PennyLane circuit 211 ''' 212 213 @qml.qnode(dev) 214 def qnode(inputs : np.ndarray, weights : np.ndarray) -> list: 215 ''' 216 PennyLane based quantum circuit composed of an angle embedding layer and a basic entangler 217 layer. 218 219 Parameters: 220 ----------- 221 - inputs : np.ndarray 222 array containing input values (can came from previous torch/keras layers or quantum layers) 223 - weights : np.ndarray 224 array containing the weights of the circuit that are tuned during training, the shape of this 225 array depends on circuit's layers and qubits. 226 227 Returns: 228 -------- 229 - measurements : list 230 list of values measured from the quantum circuits 231 ''' 232 233 qml.AmplitudeEmbedding(features=inputs, wires=range(n_qubits), normalize=True) 234 qml.RandomLayers(weights, wires=range(n_qubits)) 235 measurements = [qml.expval(qml.PauliZ(wires=i)) for i in range(n_qubits)] 236 return measurements 237 238 return qnode
RandomCircuit static method that implements the quantum circuit.
Parameters:
- dev : qml.device
PennyLane device on wich run quantum operations (dafault : None). When None it will be set
to 'default.qubit' - n_qubits : int
number of qubits for the quantum circuit
Returns:
- qnode : qml.qnode
the actual PennyLane circuit