artist.optim.training

Classes

EarlyStopping

Initialize the early stopping.

TrainTestSplit

Container holding the train/test split for heliostat reconstruction data.

Functions

exponential(optimizer, parameters) → torch.optim.lr_scheduler.LRScheduler

Create an exponential learning rate scheduler.

cyclic(optimizer, parameters) → torch.optim.lr_scheduler.LRScheduler

Create a cyclic learning rate scheduler.

reduce_on_plateau(optimizer, parameters) → torch.optim.lr_scheduler.LRScheduler

Create learning rate scheduler that reduces on plateaus.

train_test_split(active_heliostats_mask, ...[, ...]) → TrainTestSplit

Split heliostat reconstruction data into training and test subsets.

Module Contents

artist.optim.training.exponential(optimizer: torch.optim.Optimizer, parameters: dict[str, float]) → torch.optim.lr_scheduler.LRScheduler

Create an exponential learning rate scheduler.

Parameters

optimizerOptimizer

The optimizer.

parametersdict[str, float]

The scheduler parameters.

Returns

LRScheduler

An exponential learning rate scheduler.

artist.optim.training.cyclic(optimizer: torch.optim.Optimizer, parameters: dict[str, float]) → torch.optim.lr_scheduler.LRScheduler

Create a cyclic learning rate scheduler.

Parameters

optimizerOptimizer

The optimizer.

parametersdict[str, float]

The scheduler parameters.

Returns

LRScheduler

A cyclic learning rate scheduler.

artist.optim.training.reduce_on_plateau(optimizer: torch.optim.Optimizer, parameters: dict[str, float]) → torch.optim.lr_scheduler.LRScheduler

Create learning rate scheduler that reduces on plateaus.

Parameters

optimizerOptimizer

The optimizer.

parametersdict[str, float]

The scheduler parameters.

Returns

LRScheduler

A learning rate scheduler that reduces on plateaus.

class artist.optim.training.EarlyStopping(window_size: int = 10, patience: int = 20, min_improvement: float = 0.0001, relative: bool = True, eps: float = 1e-08)

Initialize the early stopping.

Parameters

window_sizeint

Number of epochs used to estimate loss trend (default is 10).

patienceint

Number of consecutive non-improving windows before stopping (default is 20).

min_improvementfloat

Minimum required improvement over the window to reset patience (default is 1e-4).

relativebool

Indicates whether improvement is normalized by loss magnitude (default is True).

epsfloat

Small value for stability (default is 1e-8).

window_size = 10
patience = 20
min_improvement = 0.0001
relative = True
eps = 1e-08
loss_history: Deque[float]
counter = 0
step(loss: float) → bool

Update stopping state.

Parameters

lossfloat

Current loss value.

Returns

bool

True if optimization should stop, otherwise False.

class artist.optim.training.TrainTestSplit

Container holding the train/test split for heliostat reconstruction data.

Attributes

flux_measured_traintorch.Tensor

Measured flux distributions for the training set. Shape is [number_of_train_samples_total, height, width].

focal_spots_measured_traintorch.Tensor

Measured focal spot coordinates for the training set. Shape is [number_of_train_samples_total, 4].

incident_ray_directions_traintorch.Tensor

Incident ray directions for the training set. Shape is [number_of_train_samples_total, 4].

motor_positions_traintorch.Tensor

Motor positions for the training set. Shape is [number_of_train_samples_total, 2].

target_area_indices_traintorch.Tensor

Target area indices for the training set. Shape is [number_of_train_samples_total].

flux_measured_testtorch.Tensor

Measured flux distributions for the test set. Shape is [number_of_test_samples_total, height, width].

focal_spots_measured_testtorch.Tensor

Measured focal spot coordinates for the test set. Shape is [number_of_test_samples_total, 4].

incident_ray_directions_testtorch.Tensor

Incident ray directions for the test set. Shape is [number_of_test_samples_total, 4].

motor_positions_testtorch.Tensor

Motor positions for the test set. Shape is [number_of_test_samples_total, 2].

target_area_indices_testtorch.Tensor

Target area indices for the test set. Shape is [number_of_test_samples_total].

active_heliostats_mask_traintorch.Tensor

Mask for active training samples available per heliostat after splitting. Shape is [number_of_heliostats].

active_heliostats_mask_testtorch.Tensor

Mask for active test samples available per heliostat after splitting. Shape is [number_of_heliostats].

train_indicestorch.Tensor

Indices of training samples from the original dataset. Shape is [number_of_train_samples_total].

test_indicestorch.Tensor

Indices of test samples from the original dataset. Shape is [number_of_test_samples_total].

number_of_train_samplesint

Number of training samples per heliostat.

number_of_test_samplesint

Number of test samples per heliostat.

number_of_samples_per_heliostatint

Total number of samples available per heliostat before splitting.

flux_measured_train: torch.Tensor
focal_spots_measured_train: torch.Tensor
incident_ray_directions_train: torch.Tensor
motor_positions_train: torch.Tensor
target_area_indices_train: torch.Tensor
flux_measured_test: torch.Tensor
focal_spots_measured_test: torch.Tensor
incident_ray_directions_test: torch.Tensor
motor_positions_test: torch.Tensor
target_area_indices_test: torch.Tensor
active_heliostats_mask_train: torch.Tensor
active_heliostats_mask_test: torch.Tensor
train_indices: torch.Tensor
test_indices: torch.Tensor
number_of_train_samples: int
number_of_test_samples: int
number_of_samples_per_heliostat: int
artist.optim.training.train_test_split(active_heliostats_mask: torch.Tensor, flux_measured: torch.Tensor, focal_spots_measured: torch.Tensor, incident_ray_directions: torch.Tensor, motor_positions: torch.Tensor, target_area_indices: torch.Tensor, test_fraction: float = 0.25, device: torch.device | None = None) → TrainTestSplit

Split heliostat reconstruction data into training and test subsets.

The split is performed independently for each heliostat while preserving the original ordering of samples. Training samples are taken from the beginning of each heliostat block, while test samples are taken from the end of each heliostat block.

Parameters

active_heliostats_masktorch.Tensor

Mask for active samples available per heliostat. Shape is [number_of_heliostats].

flux_measuredtorch.Tensor

Measured flux distributions for all heliostats. Shape is [total_number_of_samples, height, width].

focal_spots_measuredtorch.Tensor

Measured focal spot coordinates for all samples. Shape is [total_number_of_samples, 4].

incident_ray_directionstorch.Tensor

Incident ray directions for all samples. Shape is [total_number_of_samples, 4].

motor_positionstorch.Tensor

Motor positions for all samples. Shape is [total_number_of_samples, 2].

target_area_indicestorch.Tensor

Integer target area indices for all samples. Shape is [total_number_of_samples].

test_fractionfloat

Fraction of samples per heliostat assigned to the test set (default is 0.35).

devicetorch.device | None

The device on which to perform computations or load tensors and models (default is None). If None, ARTIST will automatically select the most appropriate device (CUDA or CPU) based on availability and OS.

Returns

TrainTestSplit

Dataclass containing: train/test tensors, train/test indices, updated active heliostat masks.