LinearWeighting#

Module for the LinearWeighting class.

class LinearWeighting(initial_weights, final_weights, target_epoch)[source]#

Bases: WeightingInterface

A weighting scheme that linearly scales weights from initial values to final values over a specified number of epochs.

Parameters:
  • initial_weights (dict) – The weights to be assigned to each loss term at the beginning of training. The keys are the conditions and the values are the corresponding weights. If a condition is not present in the dictionary, the default value (1) is used.

  • final_weights (dict) – The weights to be assigned to each loss term once the target epoch is reached. The keys are the conditions and the values are the corresponding weights. If a condition is not present in the dictionary, the default value (1) is used.

  • target_epoch (int) – The epoch at which the weights reach their final values.

Raises:

ValueError – If the keys of the two dictionaries are not consistent.

weights_update(losses)[source]#

Update the weighting scheme based on the given losses.

Parameters:

losses (dict) – The dictionary of losses.

Returns:

The updated weights.

Return type:

dict