ecal.calculators.training

Classes

Training(model_name, batch_size, num_epochs, ...)

This class is used to estimate the flops of the model training, which is then used to estimate the energy consumption of the model training.

class ecal.calculators.training.Training(model_name, batch_size, num_epochs, num_samples, processor_flops_per_second, processor_max_power, input_size, evaluation_strategy, k_folds, split_ratio, calculator=None)[source]

Bases: object

This class is used to estimate the flops of the model training, which is then used to estimate the energy consumption of the model training.

Parameters:
__init__(model_name, batch_size, num_epochs, num_samples, processor_flops_per_second, processor_max_power, input_size, evaluation_strategy, k_folds, split_ratio, calculator=None)[source]

Initialize Training class with optional custom FLOP calculator

Parameters:
  • calculator (FLOPCalculator | None) – Optional custom FLOPCalculator implementation

  • input_size (Tuple) – Tuple of input size

  • batch_size (int) – int of batch size

  • num_epochs (int) – int of number of epochs

  • num_samples (int) – int of number of samples

  • processor_flops_per_second (float) – float of processor flops per second

  • processor_max_power (int) – int of processor max power in watts

  • evaluation_strategy (str) – str of evaluation strategy

  • k_folds (int) – int of number of folds for cross-validation

  • split_ratio (float) – float of split ratio for train-test split

  • model_name (str)

calculate_energy()[source]

Calculate the total energy usage of training and evaluation

Returns:

Dictionary with “total_energy” (training + evaluation, in Joules), “training_energy”, “evaluation_energy”, “training_flops”, “evaluation_flops”, “train_time” (seconds), and “eval_time” (seconds)

Return type:

Dict[str, float]

calculate_flops_evaluation()[source]

Calculate total FLOPs required for evaluation

Scales a single forward pass’s FLOPs by the number of samples held out for evaluation, based on the configured evaluation strategy (train/test split or k-fold cross-validation).

Returns:

Total evaluation FLOPs

Return type:

float

calculate_flops_training()[source]

Calculate total FLOPs required for training

Approximates one training pass (forward + backward + weight update) as three times the forward-pass FLOPs, then scales by the number of training samples (per the configured evaluation strategy) and the number of epochs.

Returns:

Total training FLOPs across all epochs

Return type:

float