ClassicalInOpAll#
- class torchquantum.layer.ClassicalInOpAll(n_gate: int, op: Operator)[source]#
Bases:
QuantumModule
Quantum module that applies the same quantum operation to all wires of a quantum device, where the parameters of the operation are obtained from a classical input.
- Parameters:
n_gate (int) – Number of gates.
op (tq.Operator) – Quantum operation to be applied.
- 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, x)[source]#
Performs the forward pass of the classical input quantum operation module.
- Parameters:
q_device (tq.QuantumDevice) – Quantum device to apply the operations on.
x (torch.Tensor) – Classical input of shape (batch_size, n_gate).
- Returns:
None
- Raises:
AssertionError – If the number of gates is different from the number of wires in the device.
Attributes