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.ParameterizedCircuit

Parameterized 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:
Returns:

Z expectation values.

Return type:

torch.Tensor

forward_circuit(x: torch.Tensor, weights: torch.Tensor) torch.Tensor

Compute model outputs for inputs and weights.

Parameters:
Returns:

Output tensor.

Return type:

torch.Tensor