kosmos.ml.config.factories.model

Classes

class ModelConfig[source]

Bases: abc.ABC

Model configuration.


Methods

get_instance(input_dim: int, output_dim: int) kosmos.ml.models.model.Model[source]

Get the model instance.

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

  • output_dim (int) – Model output dimension.

Returns:

Model instance.

Return type:

Model


class NeuralNetworkConfig(hidden_layers: list[int])[source]

Bases: ModelConfig

Neural network configuration.

hidden_layers

Sizes of the hidden layers. The length of the list defines the number of hidden layers, and each element specifies the size of a layer.

Type:

list[int]

Initialize the neural network configuration.

Parameters:

hidden_layers (list[int]) – Sizes of the hidden layers. The length of the list defines the number of hidden layers, and each element specifies the size of a layer.


Methods

get_instance(input_dim: int, output_dim: int) kosmos.ml.models.neural_network.NeuralNetwork[source]

Get the neural network instance.

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

  • output_dim (int) – Model output dimension.

Returns:

Neural network instance.

Return type:

NeuralNetwork


class VQCConfig(circuit_runner: kosmos.circuit_runner.circuit_runner.CircuitRunner, num_layers: int, encoding_config: kosmos.ml.config.factories.encoding.EncodingConfig, weight_mapping_func: kosmos.ml.typing.TensorMapping | None = None, input_mapping_func: kosmos.ml.typing.TensorMapping | None = None, weight_init_range: tuple[float, float] = (-1.0, 1.0), bias_init_range: tuple[float, float] | None = (-0.001, 0.001), *, data_reuploading: bool = False, output_scaling: bool = False)[source]

Bases: ModelConfig

Variational quantum circuit configuration.

circuit_runner

The quantum circuit runner to use for the VQC.

Type:

CircuitRunner

num_layers

The number of variational layers.

Type:

int

encoding_config

The encoding configuration.

Type:

EncodingConfig

weight_mapping_func

The mapping function for the weights.

Type:

TensorMapping | None

input_mapping_func

The mapping function for the input.

Type:

TensorMapping | None

weight_init_range

Lower and upper bounds for initializing the trainable weight parameters.

Type:

tuple[float, float]

bias_init_range

Lower and upper bounds for initializing the trainable bias parameters applied to each output unit. If None, no bias parameters are used.

Type:

tuple[float, float] | None

data_reuploading

Whether to use data re-uploading.

Type:

bool

output_scaling

Whether to use output scaling.

Type:

bool

Initialize the VQC configuration.

Parameters:
  • circuit_runner (CircuitRunner) – The quantum circuit runner to use for the VQC.

  • num_layers (int) – The number of variational layers.

  • encoding_config (EncodingConfig) – The encoding configuration.

  • weight_mapping_func (TensorMapping | None) – The mapping function for the weights. Defaults to None.

  • input_mapping_func (TensorMapping | None) – The mapping function for the input. Defaults to None.

  • weight_init_range (tuple[float, float]) – Lower and upper bounds for initializing the trainable weight parameters. Defaults to (-1.0, 1.0).

  • bias_init_range (tuple[float, float] | None) – Lower and upper bounds for initializing the trainable bias parameters applied to each output unit. If None, no bias parameters are used. Defaults to (-0.001, 0.001).

  • data_reuploading (bool) – Whether to use data re-uploading. Defaults to False.

  • output_scaling (bool) – Whether to use output scaling. Defaults to False.


Methods

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

Get the VQC instance.

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

  • output_dim (int) – Model output dimension.

Returns:

VQC instance.

Return type:

VQC