artist.core.core_utils
Functions
|
Compute mean losses for each heliostat with multiple samples. |
|
Scale one loss so that its weighted contribution is a ratio of the reference loss. |
Module Contents
- artist.core.core_utils.per_heliostat_reduction(per_sample_values: torch.Tensor, active_heliostats_mask: torch.Tensor, device: torch.device | None = None) torch.Tensor
Compute mean losses for each heliostat with multiple samples.
If the active heliostats of one group have different amounts of samples to train on, i.e., one heliostat is trained with more samples than another, this function makes sure that each heliostat still contributes equally to the overall loss of the group. This function computes the mean loss for each heliostat.
Parameters
- per_sample_valuestorch.Tensor
The per sample values to be reduced. Tensor of shape [number_of_samples].
- active_heliostats_masktorch.Tensor
A mask defining which heliostats are activated. Tensor of shape [number_of_heliostats].
- devicetorch.device | None
The device on which to perform computations or load tensors and models (default is None). If None,
ARTISTwill automatically select the most appropriate device (CUDA or CPU) based on availability and OS.
Returns
- torch.Tensor
The mean loss per heliostat. Tensor of shape [number_of_heliostats].
- artist.core.core_utils.scale_loss(loss: torch.Tensor, reference: torch.Tensor, weight: float) torch.Tensor
Scale one loss so that its weighted contribution is a ratio of the reference loss.
Parameters
- losstorch.Tensor
The loss to be scaled. Tensor of shape [1].
- referencetorch.Tensor
The reference loss. Tensor of shape [1].
- weightfloat
The weight or ratio used for the scaling.
Returns
- torch.Tensor
The scaled loss. Tensor of shape [1].