kosmos.ml.config.factories.encoding

Classes

class EncodingConfig[source]

Bases: abc.ABC

Abstract base for encoding configurations.

framework

The framework for the encoding.

Type:

QuantumCircuitFramework | None

Initialize the encoding configuration.


Methods

set_framework(framework: kosmos.circuit_runner.typing.QuantumCircuitFramework) None[source]

Set the framework for the encoding.

Parameters:

framework (QuantumCircuitFramework) – The framework to use for the encoding.

get_instance(input_dim: int, output_dim: int) kosmos.ml.models.vqc.encoding.encoding.VQCEncoding[source]

Get the encoding instance.

Parameters:
  • input_dim (int) – Model input dimension.

  • output_dim (int) – Model output dimension.

Returns:

Encoding instance.

Return type:

VQCEncoding


class AngleEmbeddingConfig(rotation: Literal['X', 'Y', 'Z'] = 'X')[source]

Bases: EncodingConfig

Angle embedding configuration.

rotation

The rotation to use for the angle embedding.

Type:

Literal[“X”, “Y”, “Z”]

Initialize the angle embedding configuration.

Parameters:

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


Methods

get_instance(input_dim: int, output_dim: int) kosmos.ml.models.vqc.encoding.encoding.AngleEmbedding[source]

Get the angle embedding instance.

Parameters:
  • input_dim (int) – Model input dimension.

  • output_dim (int) – Model output dimension.

Returns:

Angle embedding instance.

Return type:

AngleEmbedding


class AmplitudeEmbeddingConfig(pad_with: complex = 0.3, *, normalize: bool = True)[source]

Bases: EncodingConfig

Amplitude embedding configuration.

pad_with

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

Type:

complex

normalize

Whether to normalize the features.

Type:

bool

Initialize the amplitude embedding configuration.

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

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


Methods

get_instance(input_dim: int, output_dim: int) kosmos.ml.models.vqc.encoding.encoding.AmplitudeEmbedding[source]

Get the amplitude embedding instance.

Parameters:
  • input_dim (int) – Model input dimension.

  • output_dim (int) – Model output dimension.

Returns:

Amplitude embedding instance.

Return type:

AmplitudeEmbedding