Op1QAllLayer#

class torchquantum.layer.Op1QAllLayer(op, n_wires: int, has_params=False, trainable=False)[source]#

Bases: QuantumModule

Quantum layer applying the same single-qubit operation to all wires.

This class represents a quantum layer that applies the same single-qubit operation to all wires in the quantum device.

Parameters:
  • op (tq.Operator) – Single-qubit operation to be applied.

  • n_wires (int) – Number of wires in the quantum device.

  • has_params (bool, optional) – Flag indicating if the operation has parameters. Defaults to False.

  • trainable (bool, optional) – Flag indicating if the operation is trainable. Defaults to False.

__init__(op, n_wires: int, has_params=False, trainable=False)[source]#

Initialize the QuantumModule.

Returns:

None.

Examples

>>> qmodule = QuantumModule()

Methods

forward(q_device)[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#