FixedOpAll#

class torchquantum.layer.FixedOpAll(n_gate: int, op: Operator)[source]#

Bases: QuantumModule

Quantum module that applies the same fixed quantum operation to all wires of a quantum device.

Parameters:
  • n_gate (int) – Number of gates.

  • op (tq.Operator) – Quantum operation to be applied.

n_gate#

Number of gates.

Type:

int

gate_all#

List of quantum operations.

Type:

nn.ModuleList

__init__(n_gate: int, op: Operator)[source]#

Initialize the QuantumModule.

Returns:

None.

Examples

>>> qmodule = QuantumModule()

Methods

forward(q_device: QuantumDevice)[source]#

Performs the forward pass of the fixed quantum operation module.

Parameters:

q_device (tq.QuantumDevice) – Quantum device to apply the operations on.

Returns:

None

Raises:

AssertionError – If the number of gates is different from the number of wires in the device.

Attributes

training: bool#