scdynomics.utils.trainer

Pytorch lightning trainer associated utilities

Functions

cal_accum_grad_batches(config, ndevices)

Calculate the gradient accumulation batches based on the config file and the number of devices.

make_callbacks(config)

Make callbacks based on the config file.

set_accelerator([accelerator])

Set the accelerator based on the input string and the availability of devices.

scdynomics.utils.trainer.cal_accum_grad_batches(config, ndevices)

Calculate the gradient accumulation batches based on the config file and the number of devices.

Parameters:
config: dict

The config file loaded as a dictionary.

ndevices: int

The number of devices used for training.

Returns: int

The number of gradient accumulation batches to be passed to the trainer.

scdynomics.utils.trainer.make_callbacks(config)

Make callbacks based on the config file. The callback class must be in pytorch_lightning.callbacks and the name must be the same as the one in the config file.

Parameters:
config: dict

The config file loaded as a dictionary.

Returns: list

A list of callbacks to be passed to the trainer.

scdynomics.utils.trainer.set_accelerator(accelerator: str = 'auto')

Set the accelerator based on the input string and the availability of devices.

Parameters:
accelerator: str

The accelerator to be used for training. It can be “auto”, “cuda”, “mps”, or “cpu”.

Returns: str

The accelerator to be passed to the trainer.