updown.utils.common

updown.utils.common.cycle(dataloader:torch.utils.data.dataloader.DataLoader, device:torch.device) → Generator[Dict[str, torch.Tensor], NoneType, NoneType][source]

A generator which yields a random batch from dataloader perpetually. This generator is used in the constructor.

This is done so because we train for a fixed number of iterations, and do not have the notion of ‘epochs’. Using itertools.cycle with dataloader is harmful and may cause unexpeced memory leaks.