Generic Tools

Average Meter

class tllib.utils.meter.AverageMeter(name, fmt=':f')[source]

Computes and stores the average and current value.


>>> # Initialize a meter to record loss
>>> losses = AverageMeter()
>>> # Update meter after every minibatch update
>>> losses.update(loss_value, batch_size)

Progress Meter

class tllib.utils.meter.ProgressMeter(num_batches, meters, prefix='')[source]


class tllib.utils.meter.Meter(name, fmt=':f')[source]

Computes and stores the current value.


class, device=None)[source]

A data iterator that will never stop producing data


Dataset as a combination of multiple datasets. The element of each dataset must be a list, and the i-th element of the combined dataset is a list splicing of the i-th element of each sub dataset. The length of the combined dataset is the minimum of the lengths of all sub datasets.


datasets (sequence) – List of datasets to be concatenated, device)[source]

Recursively sends the elements in a nested list/tuple/dictionary of tensors to a given device.

  • tensor (nested list/tuple/dictionary of torch.Tensor) – The data to send to a given device.

  • device (torch.device) – The device to send the data to


The same data structure as tensor with all tensors sent to the proper device.[source]

concatenate multiple batches into one batch. tensors can be torch.Tensor, List or Dict, but they must be the same data format.


class tllib.utils.logger.TextLogger(filename, stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]

Writes stream output to external text file.

  • filename (str) – the file to write stream output

  • stream – the stream to read from. Default: sys.stdout

class tllib.utils.logger.CompleteLogger(root, phase='train')[source]

A useful logger that

  • writes outputs to files and displays them on the console at the same time.

  • manages the directory of checkpoints and debugging images.

  • root (str) – the root directory of logger

  • phase (str) – the phase of training.


Get the full checkpoint path.


name (optional) – the filename (without file extension) to save checkpoint. If None, when the phase is train, checkpoint will be saved to {epoch}.pth. Otherwise, will be saved to {phase}.pth.


Get the full image path for a specific filename


Set the epoch number. Please use it during training.


Access comprehensive documentation for Transfer Learning Library

View Docs


Get started for Transfer Learning Library

Get Started

Paper List

Get started for transfer learning

View Resources