Utils
Lightning utils.
Series
dataclass
An easy to plot series extracting from training log.
epoch
instance-attribute
X-axis values representing training epochs.
value
instance-attribute
Y-axis values representing the quantity recorded over the epoch.
TrainingReport
dataclass
Series extracted from training logs.
learning_rate
instance-attribute
Learning rate.
metrics
instance-attribute
Metrics, can be empty.
train_loss
instance-attribute
Training loss.
val_loss
instance-attribute
Validation loss.
load_config_from_checkpoint(checkpoint_path)
Load a CAREamics config from a checkpoint.
Some fields, if missing, will be populated by defaults. Namely, version,
training_config and experiment_name.
The default for experiment_name will be "loaded_from_<checkpoint_filename>".
Parameters:
-
checkpoint_path(Path) –Path to the PyTorch Lightning checkpoint file.
Returns:
-
Configuration–A CAREamics configuration object.
Raises:
-
ValueErrors:–If certain required information is not found in the checkpoint.
load_module_from_checkpoint(checkpoint_path)
Load a trained CAREamics module from checkpoint.
Automatically detects the algorithm type from the checkpoint and loads the appropriate module with trained weights.
Parameters:
-
checkpoint_path(Path) –Path to the PyTorch Lightning checkpoint file.
Returns:
-
CAREamicsModule–Lightning module with loaded weights.
Raises:
-
ValueError–If the algorithm type cannot be determined from the checkpoint.
read_csv_logger(log_folder, experiment_name, version=None)
Return plottable training curves from Lightning CSV logs.
Parameters:
-
log_folder(Path or str) –Path to the folder containing the csv logs.
-
experiment_name(str) –Name of the experiment.
-
version(int or None, default:= None) –Version number to load, if
Nonethen the latest version is loaded.
Returns:
-
TrainingReport–Dataclass containing train and validation loss, learning rate, and any discovered validation metrics.
Raises:
-
ValueError–If
versionis specified but not found.