kosmos.ml.models.vqc.circuit.pennylane_circuit¶
Classes¶
- class PennyLaneParameterizedCircuit(circuit_runner: kosmos.circuit_runner.pennylane_runner.PennyLaneRunner, encoding: kosmos.ml.models.vqc.encoding.encoding.VQCEncoding, num_layers: int, weight_mapping_func: kosmos.ml.typing.TensorMapping | None, input_mapping_func: kosmos.ml.typing.TensorMapping | None, output_scaling_parameter: torch.Tensor | None, bias_parameter: torch.Tensor | None, *, data_reuploading: bool)¶
Bases:
kosmos.ml.models.vqc.circuit.circuit.ParameterizedCircuitParameterized quantum circuit using PennyLane.
Initialize the circuit.
- Parameters:
circuit_runner (PennyLaneRunner) – The PennyLane circuit runner.
encoding (VQCEncoding) – The VQC encoding.
num_layers (int) – The number of variational layers.
weight_mapping_func (TensorMapping | None) – The mapping function for the weights.
input_mapping_func (TensorMapping | None) – The mapping function for the inputs.
output_scaling_parameter (torch.Tensor | None) – The output scaling parameter.
bias_parameter (torch.Tensor | None) – The bias parameter.
data_reuploading (bool) – Whether to use data re-uploading.
Methods
- expect_z(weights: torch.Tensor, x: torch.Tensor) torch.Tensor¶
Execute the circuit and calculate Z expectation values.
- Parameters:
weights (torch.Tensor) – Weights tensor.
x (torch.Tensor) – Input tensor.
- Returns:
Z expectation values.
- Return type:
- forward_circuit(x: torch.Tensor, weights: torch.Tensor) torch.Tensor¶
Compute model outputs for inputs and weights.
- Parameters:
x (torch.Tensor) – Input tensor.
weights (torch.Tensor) – Weights tensor.
- Returns:
Output tensor.
- Return type: