kosmos.ml.models.vqc.encoding

Classes

class VQCEncoding(input_dim: int, output_dim: int)

Bases: abc.ABC

Feature encoding for the VQC.

Initialize the encoding.

Parameters:
  • input_dim (int) – The input dimension of the model.

  • output_dim (int) – The output dimension of the model.


Properties

property num_qubits

Number of required qubits.


Methods

apply_operation(features: torch.Tensor, wires: collections.abc.Sequence[int]) None

Apply the PennyLane operation for encoding.

Parameters:
  • features (Tensor) – Input features.

  • wires (Sequence[int]) – Target wires.


class AngleEmbedding(input_dim: int, output_dim: int, rotation: Literal['X', 'Y', 'Z'])

Bases: VQCEncoding

Angle embedding for the VQC.

Initialize the angle embedding.

Parameters:
  • input_dim (int) – The input dimension of the model.

  • output_dim (int) – The output dimension of the model.

  • rotation (Literal["X", "Y", "Z"]) – The rotation to use for the angle embedding.


Properties

property num_qubits

Number of required qubits.


Methods

apply_operation(features: torch.Tensor, wires: collections.abc.Sequence[int]) None

Apply the angle embedding operation.

Parameters:
  • features (Tensor) – Input features.

  • wires (Sequence[int]) – Target wires.


class AmplitudeEmbedding(input_dim: int, output_dim: int, pad_with: complex, *, normalize: bool)

Bases: VQCEncoding

Amplitude embedding for the VQC.

Initialize the amplitude embedding.

Parameters:
  • input_dim (int) – The input dimension of the model.

  • output_dim (int) – The output dimension of the model.

  • pad_with (complex) – The input is padded with this constant to size \(2^n\).

  • normalize (bool) – Whether to normalize the features.


Properties

property num_qubits

Number of required qubits.


Methods

apply_operation(features: torch.Tensor, wires: collections.abc.Sequence[int]) None

Apply the amplitude embedding operation.

Parameters:
  • features (Tensor) – Input features.

  • wires (Sequence[int]) – Target wires.