code stringlengths 17 6.64M |
|---|
class _S_conjugate_operation(_operation):
'class for a conjugated S operation'
def get_circuit(self, var_param_assignment=None):
QC = QuantumCircuit(self.num_qubits)
QC.sdg(range(self.num_qubits))
return QC
|
class _T_operation(_operation):
'class for a conjugated S operation'
def get_circuit(self, var_param_assignment=None):
QC = QuantumCircuit(self.num_qubits)
QC.t(range(self.num_qubits))
return QC
|
class _T_conjugate_operation(_operation):
'class for a conjugated T operation'
def get_circuit(self, var_param_assignment=None):
QC = QuantumCircuit(self.num_qubits)
QC.tdg(range(self.num_qubits))
return QC
|
class _rot_operation(_operation):
def __init__(self, num_qubits: int, variablegroup_tuple: tuple, map=None):
super().__init__(num_qubits, variablegroup_tuple, map)
def apply_param_vectors(self, QC, r_star, var_param_assignment):
'\n Applies the param vectors creating a quantum circuit... |
class _Rx_operation(_rot_operation):
'class for a Rx operation'
def get_circuit(self, var_param_assignment: dict):
'\n Args:\n var_param_assignment: a dictionary, that assigns hash values of variable groups with their parameter vectors (by qiskit)\n returns:\n Quan... |
class _Ry_operation(_rot_operation):
'class for a Ry operation'
def get_circuit(self, var_param_assignment: dict):
'\n Args:\n var_param_assignment: a dictionary, that assigns hash values of variable groups with their parameter vectors (by qiskit)\n returns:\n Quan... |
class _Rz_operation(_rot_operation):
'class for a Rz operation'
def get_circuit(self, var_param_assignment: dict):
'\n Args:\n var_param_assignment: a dictionary, that assigns hash values of variable groups with their parameter vectors (by qiskit)\n returns:\n Quan... |
class _P_operation(_rot_operation):
'class for a P operation'
def get_circuit(self, var_param_assignment: dict):
'\n Args:\n var_param_assignment: a dictionary, that assigns hash values of variable groups with their parameter vectors (by qiskit)\n returns:\n Quantu... |
class _U_operation(_operation):
'class for an U operation'
def get_circuit(self, var_param_assignment: dict):
'\n Args:\n var_param_assignment: a dictionary, that assigns hash values of variable groups with their parameter vectors (by qiskit)\n returns:\n QuantumCi... |
class _two_qubit_operation(_operation):
'\n parent class for any two-qubit operation\n '
def __init__(self, num_qubits: int, variablegroup_tuple: tuple, ent_strategy: str, map=None):
super().__init__(num_qubits, variablegroup_tuple, map)
self.ent_strategy = ent_strategy
def apply_p... |
class _CH_entangle_operation(_two_qubit_operation):
'Default class for a controlled x entangling operation'
def get_circuit(self, var_param_assignment=None):
QC = QuantumCircuit(self.num_qubits)
QC = self.apply_param_vectors(QC, CHGate, var_param_assignment)
return QC
|
class _CX_entangle_operation(_two_qubit_operation):
'Default class for a controlled x entangling operation'
def get_circuit(self, var_param_assignment=None):
QC = QuantumCircuit(self.num_qubits)
QC = self.apply_param_vectors(QC, CXGate, var_param_assignment)
return QC
|
class _CY_entangle_operation(_two_qubit_operation):
'Default class for a controlled y entangling operation'
def get_circuit(self, var_param_assignment=None):
QC = QuantumCircuit(self.num_qubits)
QC = self.apply_param_vectors(QC, CYGate, var_param_assignment)
return QC
|
class _CZ_entangle_operation(_two_qubit_operation):
'Default class for a controlled z entangling operation'
def get_circuit(self, var_param_assignment=None):
QC = QuantumCircuit(self.num_qubits)
QC = self.apply_param_vectors(QC, CZGate, var_param_assignment)
return QC
|
class _SWAP_operation(_two_qubit_operation):
'class for a SWAP operation'
def get_circuit(self, var_param_assignment=None):
QC = QuantumCircuit(self.num_qubits)
QC = self.apply_param_vectors(QC, SwapGate, var_param_assignment)
return QC
|
class _CRX_operation(_two_qubit_operation):
'class for a controlled rx entangling operation'
def get_circuit(self, var_param_assignment: dict):
QC = QuantumCircuit(self.num_qubits)
QC = self.apply_param_vectors(QC, CRXGate, var_param_assignment)
return QC
|
class _CRY_operation(_two_qubit_operation):
'class for a controlled ry entangling operation'
def get_circuit(self, var_param_assignment: dict):
QC = QuantumCircuit(self.num_qubits)
QC = self.apply_param_vectors(QC, CRYGate, var_param_assignment)
return QC
|
class _CRZ_operation(_two_qubit_operation):
'class for a controlled rz entangling operation'
def get_circuit(self, var_param_assignment: dict):
QC = QuantumCircuit(self.num_qubits)
QC = self.apply_param_vectors(QC, CRZGate, var_param_assignment)
return QC
|
class _CP_operation(_two_qubit_operation):
'class for a controlled phase entangling operation'
def get_circuit(self, var_param_assignment: dict):
QC = QuantumCircuit(self.num_qubits)
QC = self.apply_param_vectors(QC, CPhaseGate, var_param_assignment)
return QC
|
class _RXX_operation(_two_qubit_operation):
'class for a RZX operation'
def get_circuit(self, var_param_assignment: dict):
QC = QuantumCircuit(self.num_qubits)
QC = self.apply_param_vectors(QC, RXXGate, var_param_assignment)
return QC
|
class _RYY_operation(_two_qubit_operation):
'class for a RZX operation'
def get_circuit(self, var_param_assignment: dict):
QC = QuantumCircuit(self.num_qubits)
QC = self.apply_param_vectors(QC, RYYGate, var_param_assignment)
return QC
|
class _RZX_operation(_two_qubit_operation):
'class for a RZX operation'
def get_circuit(self, var_param_assignment: dict):
QC = QuantumCircuit(self.num_qubits)
QC = self.apply_param_vectors(QC, RZXGate, var_param_assignment)
return QC
|
class _RZZ_operation(_two_qubit_operation):
'class for a RZZ operation'
def get_circuit(self, var_param_assignment: dict):
QC = QuantumCircuit(self.num_qubits)
QC = self.apply_param_vectors(QC, RZZGate, var_param_assignment)
return QC
|
class _CU_operation(_two_qubit_operation):
'class for a controlled u entangling operation'
def get_circuit(self, var_param_assignment: dict):
QC = QuantumCircuit(self.num_qubits)
QC = self.apply_param_vectors(QC, CUGate, var_param_assignment)
return QC
def apply_param_vectors(sel... |
class LayeredPQC():
'The main class. Contains a list of operations. With that one can build his circuit.'
def __init__(self, num_qubits: int, variable_groups=None):
'\n Takes number of qubits.\n Attributes:\n -----------\n\n Attributes:\n num_qubits (int): Numbe... |
class LayerPQC(LayeredPQC):
'\n default class for a layer: the user is able to build his one list of operations and this list can be added to the main class LayeredEncodingCircuit\n '
def __init__(self, encoding_circuit: LayeredPQC):
super().__init__(encoding_circuit.num_qubits, encoding_circui... |
class ConvertedLayeredEncodingCircuit(EncodingCircuitBase):
'\n Data structure for converting a LayeredPQC structure into sqlearn encoding circuit structure.\n The programmer specifies, which variable groups are considered as features\n and which are parameters\n\n Args:\n layered_pqc [LayeredP... |
class LayeredEncodingCircuit(EncodingCircuitBase):
'\n A class for a simple creation of layered encoding circuits.\n\n Gates are added to all qubits by calling the associated function similar to Qiskit\'s circuits.\n Single qubit gates are added to all qubits, while two qubits gates can be added with dif... |
class Layer(LayeredEncodingCircuit):
'Class for defining a Layer of the Layered Encoding Circuit'
def __init__(self, encoding_circuit: LayeredEncodingCircuit):
super().__init__(encoding_circuit.num_qubits, encoding_circuit.num_features, encoding_circuit._feature_str, encoding_circuit._parameter_str)
... |
class _operation_layer():
'\n class for the operation_list in LayeredPQC. Stores layers of operations, which are created by the Layer class.\n '
def __init__(self, layer: LayerPQC, num_layers: int=1, layer_number: int=1) -> None:
self.layer = layer
self.num_layers = num_layers
s... |
class TranspiledEncodingCircuit(EncodingCircuitBase):
'\n Class for generated a Encoding Circuit with a transpiled circuit.\n\n **Example:**\n\n .. jupyter-execute::\n\n from squlearn.encoding_circuit import TranspiledEncodingCircuit,ChebyshevRx\n from qiskit.providers.fake_provider import ... |
def _gen_qubit_mapping(circuit: QuantumCircuit) -> dict:
'\n Returns dictionary that maps virtual qubits to the physical ones\n\n Args:\n circuit (QuantumCircuit): quantum circuit (ideally transpiled)\n\n Returns:\n Dictionary which maps virtual to physical qubits\n '
dic = {}
tr... |
class FidelityKernel(KernelMatrixBase):
'\n Fidelity Quantum Kernel.\n\n The Fidelity Quantum Kernel is a based on the overlap of the quantum states.\n These quantum states\n can be defined by a parameterized quantum circuit. The Fidelity Quantum Kernel is defined as:\n\n .. math::\n\n K(x,y... |
def kernel_wrapper(kernel_matrix: KernelMatrixBase):
"\n Wrapper for sQUlearn's KernelMatrixBase to scikit-learn kernel objects.\n\n Args:\n kernel_matrix (KernelMatrixBase) :\n Quantum kernel matrix which is to be wrapped into scikit-learn kernel\n "
class CustomKernel(Kernel):
... |
class OuterKernelBase():
'\n Base Class for creating outer kernels for the projected quantum kernel\n '
def __init__(self):
self._num_hyper_parameters = 0
self._name_hyper_parameters = []
@abstractmethod
def __call__(self, qnn: QNN, parameters: np.ndarray, x: np.ndarray, y: np.... |
class ProjectedQuantumKernel(KernelMatrixBase):
'Projected Quantum Kernel for Quantum Kernel Algorithms\n\n The Projected Quantum Kernel embeds classical data into a quantum Hilbert space first and\n than projects down into a real space by measurements. The real space is than used to\n evaluate a classic... |
class GaussianOuterKernel(OuterKernelBase):
'\n Implementation of the Gaussian outer kernel:\n\n .. math::\n k(x_i, x_j) = \text{exp}\\left(-\\gamma |(QNN(x_i)- QNN(x_j)|^2 \right)\n\n Args:\n gamma (float): hyperparameter :math:`\\gamma` of the Gaussian kernel\n '
def __init__(self... |
class QGPC(GaussianProcessClassifier):
'\n Quantum Gaussian process classification (QGPC), that extends the scikit-learn\n `sklearn.gaussian_process.GaussianProcessClassifier\n <https://scikit-learn.org/stable/modules/generated/sklearn.gaussian_process.GaussianProcessClassifier.html>`_.\n GaussianProc... |
class QKRR(BaseEstimator, RegressorMixin):
'\n Quantum Kernel Ridge Regression.\n\n This class implements the Quantum Kernel Ridge Regression analogous to KRR [1] in scikit-learn\n but is not a wrapper.\n Read more about the theoretical background of KRR in, e.g., the\n `scikit-learn user guide <ht... |
class QSVC(SVC):
'\n Quantum Support Vector Classification\n\n This class is a wrapper of :class:`sklearn.svm.SVC`. It uses a quantum kernel matrix\n to replace the kernel matrix in the :class:`sklearn.svm.SVC` class.\n The parameters of the parent class can be adjusted via ``**kwargs``. See the docum... |
class QSVR(SVR):
'\n Quantum Support Vector Regression\n\n This class is a wrapper of :class:`sklearn.svm.SVR`. It uses a quantum kernel matrix\n to replace the kernel matrix in the :class:`sklearn.svm.SVR` class. The parameters of the\n parent class can be adjusted via ``**kwargs``.\n See the docu... |
class KernelLossBase():
'\n Empty parent class for a kernel loss function.\n\n Args:\n quantum_kernel (KernelMatrixBase) : Specified quantum kernel object (either FQK or PQK)\n '
def __init__(self, quantum_kernel: KernelMatrixBase) -> None:
self._quantum_kernel = quantum_kernel
d... |
class KernelOptimizerBase():
"\n Empty parent class for defining a kernel optimizer object.\n\n Args:\n loss (KernelLossBase) :\n Loss function to be used for the kernel optimization\n optimizer (OptimizerBase) :\n Optimizer from squlearn.optimizers used for finding the m... |
class KernelOptimizer(KernelOptimizerBase):
'\n Quantum kernel optimizer.\n This class can be used to optimize the variational parameters of a quantum kernel.\n\n\n Args:\n loss (KernelLossBase): The loss function to be minimized.\n optimizer (OptimizerBase): The optimizer to be used.\n ... |
class NLL(KernelLossBase):
'\n Negative log likelihood loss function.\n This class can be used to compute the negative log likelihood loss function\n for a given quantum kernel\n :math:`K_{θ}` with variational parameters :math:`θ`.\n The definition of the function is taken from Equation 5.8 Chapter... |
class TargetAlignment(KernelLossBase):
'\n Target alignment loss function.\n This class can be used to compute the target alignment for a given quantum kernel\n :math:`K_{θ}` with variational parameters :math:`θ`.\n The definition of the function is taken from Equation (27,28) of [1].\n The log-lik... |
class ObservableDerivatives():
'Class for calculating derivatives of observables.\n\n The derivatives are calculated by automatic differentiation of parameter in the expectation\n operator. Also, squaring of the operator is implemented.\n The class can either applied on a single operator, or on a list of... |
def operator_differentiation(optree: OpTreeElementBase, parameters: Union[(ParameterVector, list, ParameterExpression)]) -> OpTreeElementBase:
'Function for differentiating a given observable w.r.t. to its parameters\n\n Args:\n optree (OpTreeElementBase): optree structure of the observable, can also be... |
class CustomObservable(ObservableBase):
"\n Class for defining a custom observable.\n\n The operator is supplied as a string of Pauli operators, e.g. ``operator_string='ZI'`` for\n a two qubit operator with a Z operator on the second qubit.\n Note that the index of the qubits is reversed, i.e. the fir... |
class IsingHamiltonian(ObservableBase):
"\n Implementation of Ising type Hamiltonians.\n\n **Equation for a the full Ising Hamiltonian:**\n\n .. math::\n \\hat{H} = a\\hat{I} + \\sum_i b_i \\hat{Z}_i + \\sum_i c_i \\hat{X}_i +\n \\sum_{i>j} d_{ij} \\hat{Z}_i \\hat{Z}_j\n\n where :math:`a... |
class SinglePauli(ObservableBase):
"\n Observable constructed from a single Pauli operator of a single Qubit.\n\n **Equation for Z Pauli operator:**\n\n .. math::\n\n \\hat{H} = \\hat{Z_i} \\qquad \\text{or} \\qquad \\hat{H} = \\theta\\hat{Z_i}~~~~\n \\text{ (parameterized)}\n\n Can be pa... |
class SingleProbability(ObservableBase):
'\n Observable for measuring the probability of being in state 0 or 1 of a specified qubit.\n\n **Equation as the operator is implemented:**\n\n .. math::\n\n \\hat{H} = 0.5(\\hat{I}_i+\\hat{Z}_i) (= \\ket{0}\\bra{0}_i) \\qquad \\text{or} \\qquad\n \\h... |
class SummedPaulis(ObservableBase):
'\n Observable for summation of single Pauli operators.\n\n **Equation for Z Pauli operator:**\n\n .. math::\n \\hat{H} = a\\hat{I} + \\sum_i b_i \\hat{Z}_i\n\n Multiple Pauli operators can be specified by a tuple of strings, e.g. ``op_str=("X","Z")``:\n\n ... |
class SummedProbabilities(ObservableBase):
'\n Observable for summing single Qubit probabilities of binary states.\n\n **Equation for a sum of 0-states:**\n\n .. math::\n \\hat{H} = a\\hat{I} + \\sum_i b_i (\\ket{0}\\bra{0})_i\n\n States are implemented by :math:`\\ket{0}\\bra{0} = 0.5(\\hat{I}... |
class ApproxGradientBase():
'Base class for evaluating approximated gradients'
def gradient(self, x: np.ndarray) -> np.ndarray:
'Function that calculates the approximated gradient for given input x\n\n Args:\n x (np.ndarray): Input location at which the gradient is calculated\n\n ... |
class FiniteDiffGradient(ApproxGradientBase):
"\n Class for evaluating the finite differences gradient.\n\n Possible implementations are:\n\n Forward: [f(x+eps)-f(x)]/eps\n Backwards: [f(x)-f(x-eps)]/eps\n Central (default): [f(x+eps)-f(x-eps)]/2*eps\n Five-point: [-f(x+2eps)+8f(x+eps)-8f(x-eps)... |
class StochasticPerturbationGradient(ApproxGradientBase):
'\n Class for evaluating the stochastic perturbation gradient estimation.\n\n g_i = f(x+eps*r)-f(x-eps*r)/2*eps*r_i with random vector r\n\n This is used in the SPSA optimization.\n\n Args:\n fun (callable): Callable function for the gr... |
def default_callback(*args):
'Default callback function.'
pass
|
class OptimizerResult():
'Class for holding the final result of the optimization'
def __init__(self):
self.x = None
self.nit = 0
self.fun = 0.0
|
class OptimizerBase(abc.ABC):
'Base class for QNN optimizers.'
def minimize(self, fun: callable, x0: np.ndarray, grad: callable=None, bounds=None) -> OptimizerResult:
'Function to minimize a given function.\n\n Args:\n fun (callable): Function to minimize.\n x0 (numpy.nda... |
class IterativeMixin():
'Mixin for iteration based optimizers.'
def __init__(self):
self.iteration = 0
|
class StepwiseMixin(IterativeMixin):
'Mixin for optimizer for which we can execute single steps.'
def step(self, **kwargs):
'Perform one update step.'
raise NotImplementedError()
|
class SGDMixin(StepwiseMixin, abc.ABC):
'Mixin for stochastic gradient descent based optimizers.'
def step(self, **kwargs):
'Perform one update step.\n\n Args:\n x: Current value\n grad: Precomputed gradient\n\n Returns:\n Updated x\n '
if... |
class WrappedOptimizerBase(OptimizerBase, IterativeMixin):
'Base class for wrapped optimizers.\n\n Overwrites the set_callback function to additionally increase the iteration counter.\n '
def set_callback(self, callback):
'Set the callback function with additional iteration counter increasing.'... |
class SLSQP(WrappedOptimizerBase):
"Wrapper class for scipy's SLSQP implementation.\n\n Args:\n options (dict): Options for the SLSQP optimizer.\n The options are the same as for :meth:`scipy.optimize.minimize`\n "
def __init__(self, options: dict=None, callback=default_ca... |
class LBFGSB(WrappedOptimizerBase):
"Wrapper class for scipy's L-BFGS-B implementation.\n\n Args:\n options (dict): Options for the L-BFGS-B optimizer.\n The options are the same as for :meth:`scipy.optimize.minimize`\n "
def __init__(self, options: dict=None, callback=def... |
class SPSA(WrappedOptimizerBase):
"Wrapper class for Qiskit's SPSA implementation.\n\n Args:\n options (dict): Options for the SPSA optimizer.\n The options are the same as for :meth:`qiskit.algorithms.optimizers.SPSA`\n "
def __init__(self, options: dict=None, callback=de... |
def calc_var_dg(qnn, x, param_op, n_sample=100, p_lim=None, p_val=None, p_index=None, verbose=1, seed=0):
'\n Calculates the variance and the mean of the gradient of the given qnn.\n\n Args:\n qnn : QNN object from which the variance of the gradient is calculated\n x : Single value or array of... |
def get_barren_slope(pqc_func, cost_op_func, x, QI, num_qubits, layer_fac=5, n_sample=100):
'\n Calculates the variance of the gradient for different number of qubits.\n Returns a linear regression model to the data\n\n Args:\n pqc_func : function which returns the initialized pqc class for a give... |
def get_barren_slop_from_model(model):
'\n Returns the slop of the linear regression of the barren plateau fit\n\n Args:\n model : linear regression model created by get_barren_slope\n\n Returns:\n slop of the linear regression\n '
return model.coef_[0]
|
def get_barren_plot_from_model(model, plt):
'\n Plots the regression output and the measured numbers into a semilogarithmic plot-\n\n Args:\n model : linear regression model created by get_barren_slope\n plt : matplotplib.pyplot object\n\n Returns:\n matplotlib handles to the two plo... |
def get_barren_layer(pqc_func, cost_op_func, x, QI, num_qubits, num_layers, n_sample=100):
'\n Calculate the variance of the gradient for different number of qubits and layers.\n Can be used to create a plot for visualizing the plateauing for specific number of layers.\n\n Args:\n pqc_func : funct... |
def get_barren_layer_plot(var, num_layers, plt):
'\n Creates a barren plateau visualization with the\n number of layers on the X-axis. Returns a semilogarithmic\n plot of the variance of the gradient (see get_barren_layer).\n\n Args:\n var : dictionary containing the variance connecting qubits\... |
class BaseQNN(BaseEstimator, ABC):
'Base Class for Quantum Neural Networks.\n\n Args:\n encoding_circuit : Parameterized quantum circuit in encoding circuit format\n operator : Operator that are used in the expectation value of the QNN. Can be a list for\n multiple outputs.\n ex... |
class LossBase(abc.ABC):
'Base class implementation for loss functions.'
def __init__(self):
self._opt_param_op = True
def set_opt_param_op(self, opt_param_op: bool=True):
'Sets the `opt_param_op` flag.\n\n Args:\n opt_param_op (bool): True, if operator has trainable pa... |
class _ComposedLoss(LossBase):
'Special class for composed loss functions\n\n Class for addition, multiplication, subtraction, and division of loss functions.\n\n Args:\n l1 (LossBase): First loss function\n l2 (LossBase): Second loss function\n composition (str): Composition of the los... |
class ConstantLoss(LossBase):
'Class for constant or independent loss functions.\n\n Args:\n value (Union[int, float, Callable[[int],float]]): Constant value or function depending\n on the iterations returning a constant value.\n '
def __init__(self, value: Union[(int, float, Callable... |
class SquaredLoss(LossBase):
'Squared loss for regression.'
@property
def loss_variance_available(self) -> bool:
'Returns True since the squared loss function has a variance function.'
return True
@property
def loss_args_tuple(self) -> tuple:
'Returns evaluation tuple for... |
class VarianceLoss(LossBase):
'Variance loss for regression.\n\n Args:\n alpha (float, Callable[[int], float]): Weight value :math:`\\alpha`\n '
def __init__(self, alpha: Union[(float, Callable[([int], float)])]=0.005):
super().__init__()
self._alpha = alpha
@property
de... |
class ParameterRegularizationLoss(LossBase):
'Loss for parameter regularization.\n\n Possible implementations:\n\n * ``"L1"``: :math:`L=\\alpha \\sum_i \\left|p_i\\right|`\n * ``"L2"``: :math:`L=\\alpha \\sum_i p_i^2`\n\n Args:\n alpha (float, Callable[[int], float]): Weight value :math:`\\alph... |
class Expec():
'Data structure that holds the set-up of derivative of the expectation value.\n\n Args:\n wave_function (Union[str, tuple, ParameterVectorElement]): Describes the wave function or\n its derivative. If tuple or ParameterVectorElement the differentiation with respect to\n ... |
class QNN():
'A class for working with QNNs and its derivatives\n\n Args:\n pqc (EncodingCircuitBase) : parameterized quantum circuit in encoding circuit format\n operator (Union[ObservableBase,list]): Operator that is used in the expectation\n value of the QNN. Can be a list for multi... |
class QNNClassifier(BaseQNN, ClassifierMixin):
'Quantum Neural Network for Classification.\n\n This class implements a quantum neural network (QNN) for classification with a scikit-learn\n interface. A parameterized quantum circuit and a possibly parameterized operator are used\n as a ML model. They are ... |
class QNNRegressor(BaseQNN, RegressorMixin):
'Quantum Neural Network for Regression.\n\n This class implements a quantum neural network (QNN) for regression with a scikit-learn interface.\n A parameterized quantum circuit and a possibly parameterized operator are used as a ML model.\n They are trained ac... |
def get_variance_fac(v: float, a: float, b: float, offset: int=0):
'\n Function for adjusting the variance regularization along the iterations.\n\n Based on the sigmoid function, see Ref. [1] for details:\n\n .. math::\n \\alpha_{a,b,v}(i) = (1-v)\\frac{\\exp(a(b-i))}{\\exp(a(b-i))+\\frac{1}{b}}+v... |
def get_lr_decay(lr_start: float, lr_end: float, iter_decay: float, iter_plateau: int=0):
'\n Function for running an Adam optimization with a decay in the learning rate.\n\n Can be inputted to the learning rate of the Adam optimization.\n\n Args:\n lr_start (float): start value of the learning ra... |
class ShotControlBase():
'Base Class for shot control'
def __init__(self) -> None:
self._executor = None
self._initial_shots = None
def set_executor(self, executor: Executor) -> None:
'Function for setting the executor that is used for the shot control.\n\n Args:\n ... |
class ShotsFromRSTD(ShotControlBase):
'Shot control for setting the shots of the gradient evaluation after the RSTD of the loss.\n\n The number of shots in the gradient evaluation is set to:\n\n .. math::\n N_\\text{shots} = \\frac{\\sigma_L^2}{L^2 \\beta^2},\n\n where :math:`\\sigma_L` is the sta... |
def train(qnn: QNN, input_values: Union[(list, np.ndarray)], ground_truth: Union[(list, np.ndarray)], param_ini: Union[(list, np.ndarray)], param_op_ini: Union[(list, np.ndarray)], loss: LossBase, optimizer: OptimizerBase, shot_control: ShotControlBase=None, weights: Union[(list, np.ndarray)]=None, opt_param_op: bool... |
def train_mini_batch(qnn: QNN, input_values: Union[(list, np.ndarray)], ground_truth: Union[(list, np.ndarray)], param_ini: Union[(list, np.ndarray)], param_op_ini: Union[(list, np.ndarray)], loss: LossBase, optimizer: OptimizerBase, shot_control: ShotControlBase=None, weights: Union[(list, np.ndarray)]=None, opt_par... |
def adjust_features(x: Union[(np.ndarray, float)], x_length: int) -> Tuple[(np.ndarray, bool)]:
'Adjust the feature vector to the form [[]] if necessary.\n\n Args:\n x (np.ndarray): Input array.\n x_length (int): Dimension of the input array, e.g. feature dimension.\n\n Return:\n Adjust... |
def adjust_parameters(x: np.ndarray, x_length: int) -> Tuple[(np.ndarray, bool)]:
'Adjust the parameter vector to the form [[]] if necessary.\n\n In contrast to feature vectors, one dimensional parameters are not considered\n as multiple inputs.\n\n Args:\n x (np.ndarray): Input array.\n x_... |
def _adjust_input(x: Union[(float, np.ndarray)], x_length: int, allow_single_array: bool) -> Tuple[(np.ndarray, bool)]:
'Adjust the input to the form [[]] if necessary.\n\n If allow_single_array is True, a one dimensional array is not considered as multiple outputs.\n\n Args:\n x (np.ndarray): Input ... |
class Executor():
'\n A class for executing quantum jobs on IBM Quantum systems or simulators.\n\n The Executor class is the central component of sQUlearn, responsible for running quantum jobs.\n Both high- and low-level methods utilize the Executor class to execute jobs seamlessly.\n It automatically... |
class ExecutorEstimator(BaseEstimator):
'\n Special Estimator Primitive that uses the Executor service.\n\n Usefull for automatic restarting sessions and caching results.\n The object is created by the Executor method get_estimator()\n\n Args:\n executor (Executor): The executor service to use\... |
class ExecutorSampler(BaseSampler):
'\n Special Sampler Primitive that uses the Executor service.\n\n Useful for automatic restarting sessions and caching the results.\n The object is created by the executor method get_sampler()\n\n Args:\n executor (Executor): The executor service to use\n ... |
class ExecutorCache():
'Cache for jobs that are created by Primitives\n\n Args:\n folder (str): Folder to store the cache\n\n '
def __init__(self, logger, folder: str=''):
self._folder = folder
try:
import os
if (not os.path.exists(self._folder)):
... |
class OpTreeElementBase():
'Base class for elements of the OpTree.'
pass
|
class OpTreeNodeBase(OpTreeElementBase):
'Base class for nodes in the OpTree.\n\n Args:\n children_list (list): A list of children of the node.\n factor_list (list): A list of factors for each child.\n operation_list (list): A list of operations that are applied to each child.\n '
... |
class OpTreeList(OpTreeNodeBase):
'A OpTree node that represents its children as a list/array/vector.\n\n Args:\n children_list (list): A list of children of the list.\n factor_list (list): A list of factors for each child.\n operation_list (list): A list of operations that are applied to ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.