Generic Tools¶
Average Meter¶
Meter¶
Data¶
-
class
common.utils.data.ForeverDataIterator(data_loader, device=None)[source]¶ A data iterator that will never stop producing data
-
class
common.utils.data.CombineDataset(datasets)[source]¶ 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.
- Parameters
datasets (sequence) – List of datasets to be concatenated
-
common.utils.data.send_to_device(tensor, device)[source]¶ Recursively sends the elements in a nested list/tuple/dictionary of tensors to a given device.
- Parameters
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
- Returns
The same data structure as
tensorwith all tensors sent to the proper device.
-
common.utils.data.concatenate(tensors)[source]¶ concatenate multiple batches into one batch.
tensorscan betorch.Tensor, List or Dict, but they must be the same data format.
Logger¶
-
class
common.utils.logger.TextLogger(filename, stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]¶ Writes stream output to external text file.
- Parameters
filename (str) – the file to write stream output
stream – the stream to read from. Default: sys.stdout
-
class
common.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.