RandomOp1All#

class torchquantum.layer.RandomOp1All(n_wires: int, op_types=(<class 'torchquantum.operator.standard_gates.rx.RX'>, <class 'torchquantum.operator.standard_gates.ry.RY'>, <class 'torchquantum.operator.standard_gates.rz.RZ'>), op_ratios=None, has_params=True, trainable=True, seed=None)[source]#

Bases: QuantumModule

__init__(n_wires: int, op_types=(<class 'torchquantum.operator.standard_gates.rx.RX'>, <class 'torchquantum.operator.standard_gates.ry.RY'>, <class 'torchquantum.operator.standard_gates.rz.RZ'>), op_ratios=None, has_params=True, trainable=True, seed=None)[source]#

Layer adding a random gate to all wires

Params:

n_wires (int): number of wires/gates in integer format op_types (Iterable): single-wire gates to select from in iterable format op_ratios (Iterable): probabilities to select each gate option in iterable format seed (int): random seed in integer format

Methods

forward(q_device: QuantumDevice)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Attributes

training: bool#