SWAPSWAPLayer#

class torchquantum.layer.SWAPSWAPLayer(n_wires)[source]#

Bases: QuantumModule

Quantum layer with a sequence of SWAP gates applied to two specified pairs of wires.

This class represents a quantum layer with a sequence of SWAP gates applied to two specified pairs of wires in the quantum device.

Parameters:

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

__init__(n_wires)[source]#

Initialize the QuantumModule.

Returns:

None.

Examples

>>> qmodule = QuantumModule()

Methods

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