siml.services.inference package

Subpackages

Submodules

siml.services.inference.core_inferer module

class siml.services.inference.core_inferer.CoreInferer(trainer_setting: TrainerSetting, model_setting: ModelSetting, env_setting: ModelEnvironmentSetting, snapshot_file: Path, prepare_batch_function: Callable, loss_function: ILossCalculator, post_processor: PostProcessor, decrypt_key: bytes | None = None)

Bases: object

run(data_loader: DataLoader) State

siml.services.inference.data_loader_builder module

class siml.services.inference.data_loader_builder.InferenceDataLoaderBuilder(trainer_setting: TrainerSetting, collate_fn: CollateFunctionGenerator, decrypt_key: bytes | None = None)

Bases: object

create(data_directories: list[pathlib.Path] | None = None, raw_dict_x: dict | None = None, answer_raw_dict_y: dict | None = None, allow_no_data: bool = True) DataLoader

siml.services.inference.engine_builder module

class siml.services.inference.engine_builder.InferenceEngineBuilder(env_setting: ModelEnvironmentSetting, prepare_batch_function: Callable, post_processor: PostProcessor, non_blocking: bool)

Bases: object

create(model: Network) Engine

siml.services.inference.inner_setting module

class siml.services.inference.inner_setting.InnerInfererSetting(*, main_setting: MainSetting | Any = None, force_model_path: Path | None = None, force_converter_parameters_pkl: Path | None = None, decrypt_key: bytes | None = None)

Bases: BaseModel

class Config

Bases: object

arbitrary_types_allowed = True
property conversion_setting: ConversionSetting
create_model_env_setting() ModelEnvironmentSetting
decrypt_key: bytes | None
force_converter_parameters_pkl: Path | None
force_model_path: Path | None
get_converter_parameters_pkl_path() Path
get_crypt_key() bytes | None
get_model_name() str
get_output_directory(date_string: str, *, data_directory: Path | None = None) Path
get_snapshot_file_path() Path
get_write_simulation_case_dir(data_directory: Path | None) Path | None
property inferer_setting: InfererSetting
load_scalers() ScalersComposition | None
main_setting: MainSetting | Any
property model_setting: ModelSetting
property perform_inverse: bool
skip_fem_data_creation(data_directory: Path | None = None) bool
property trainer_setting: TrainerSetting

siml.services.inference.metrics_builder module

class siml.services.inference.metrics_builder.LossMetrics(loss_function: ILossCalculator)

Bases: Metric

compute()

Computes the metric based on it’s accumulated state.

This is called at the end of each epoch.

Returns:

the actual quantity of interest.

Return type:

Any

Raises:

NotComputableError – raised when the metric cannot be computed.

reset()

Resets the metric to it’s initial state.

This is called at the start of each epoch.

update(output)

Updates the metric’s state using the passed batch output.

This is called once for each batch.

Parameters:

output – the is the output from the engine’s process function.

class siml.services.inference.metrics_builder.MetricsBuilder(trainer_setting: TrainerSetting, loss_function: ILossCalculator)

Bases: object

create() dict[str, ignite.metrics.metric.Metric]
class siml.services.inference.metrics_builder.PostResultsMetrics

Bases: Metric

compute()

Computes the metric based on it’s accumulated state.

This is called at the end of each epoch.

Returns:

the actual quantity of interest.

Return type:

Any

Raises:

NotComputableError – raised when the metric cannot be computed.

reset()

Resets the metric to it’s initial state.

This is called at the start of each epoch.

update(output)

Updates the metric’s state using the passed batch output.

This is called once for each batch.

Parameters:

output – the is the output from the engine’s process function.

class siml.services.inference.metrics_builder.RawLossMetrics(trainer_setting: TrainerSetting, loss_function: ILossCalculator)

Bases: Metric

compute()

Computes the metric based on it’s accumulated state.

This is called at the end of each epoch.

Returns:

the actual quantity of interest.

Return type:

Any

Raises:

NotComputableError – raised when the metric cannot be computed.

reset()

Resets the metric to it’s initial state.

This is called at the start of each epoch.

update(output)

Updates the metric’s state using the passed batch output.

This is called once for each batch.

Parameters:

output – the is the output from the engine’s process function.

siml.services.inference.record_object module

class siml.services.inference.record_object.PostPredictionRecord(dict_x, dict_y, original_shapes, data_directory, inference_time, inference_start_datetime, dict_answer, loss, raw_loss, output_directory, fem_data)

Bases: NamedTuple

data_directory: Path

Alias for field number 3

dict_answer: dict[str, numpy.ndarray]

Alias for field number 6

dict_x: dict[str, numpy.ndarray]

Alias for field number 0

dict_y: dict[str, numpy.ndarray]

Alias for field number 1

fem_data: FEMData | None

Alias for field number 10

inference_start_datetime: str

Alias for field number 5

inference_time: float

Alias for field number 4

loss: float

Alias for field number 7

original_shapes: tuple

Alias for field number 2

output_directory: Path

Alias for field number 9

raw_loss: float

Alias for field number 8

class siml.services.inference.record_object.PredictionRecord(dict_x, dict_y, original_shapes, data_directory, inference_time, inference_start_datetime, dict_answer)

Bases: NamedTuple

data_directory: Path

Alias for field number 3

dict_answer: dict[str, numpy.ndarray] | None

Alias for field number 6

dict_x: dict[str, numpy.ndarray]

Alias for field number 0

dict_y: dict[str, numpy.ndarray]

Alias for field number 1

inference_start_datetime: str

Alias for field number 5

inference_time: float

Alias for field number 4

original_shapes: tuple

Alias for field number 2

class siml.services.inference.record_object.RawPredictionRecord(y_pred, y, x, original_shapes, inference_time, data_directory)

Bases: NamedTuple

data_directory: Path | None

Alias for field number 5

inference_time: float

Alias for field number 4

original_shapes: tuple

Alias for field number 3

x: ISimlVariables

Alias for field number 2

y: ISimlVariables

Alias for field number 1

y_pred: ISimlVariables

Alias for field number 0

Module contents