kosmos.ml.models.vqc.encoding.qiskit_encoding

Classes

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

Bases: kosmos.ml.models.vqc.encoding.encoding.AngleEmbedding

Angle embedding for the VQC using Qiskit.

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 framework

The framework used for the quantum circuit.

property num_qubits

Number of required qubits.


Methods

apply_operation(features: torch.Tensor, wires: collections.abc.Sequence[int], qc: qiskit.QuantumCircuit | None = None) None

Apply the Qiskit angle embedding operation for encoding.

Parameters:
  • features (Tensor) – Input features.

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

  • qc (QuantumCircuit | None) – The quantum circuit to use for the encoding (only for ‘qiskit’ framework).


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

Bases: kosmos.ml.models.vqc.encoding.encoding.AmplitudeEmbedding

Amplitude embedding for the VQC using Qiskit.

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 framework

The framework used for the quantum circuit.

property num_qubits

Number of required qubits.


Methods

apply_operation(features: torch.Tensor, wires: collections.abc.Sequence[int], qc: qiskit.QuantumCircuit | None = None) None

Apply the Qiskit amplitude embedding operation for encoding.

Parameters:
  • features (Tensor) – Input features.

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

  • qc (QuantumCircuit | None) – The quantum circuit to use for the encoding (only for ‘qiskit’ framework).