CXLayer#

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

Bases: QuantumModule

Quantum layer with a controlled-X (CX) gate applied to two specified wires.

This class represents a quantum layer with a controlled-X (CX) gate applied to two specified 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#